Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/update_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Update Version File After Release

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Get version
id: get_version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
fi

# Remove 'v' prefix if present
VERSION="${VERSION#v}"

echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "version=${VERSION}" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}

- name: Write version to version.txt
run: echo "${{ env.VERSION }}" > version.txt

- name: Check if changes exist
id: check_changes
run: |
git add version.txt
if git diff --staged --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi

- name: Create PR for version.txt update
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
commit-message: "chore: update version.txt to ${{ env.VERSION }}"
branch: update-version-txt-${{ github.run_id }}
title: "chore: update version to ${{ env.VERSION }}"
body: |
This PR updates version.txt to the latest release version.

**Version**: ${{ env.VERSION }}
**Release**: ${{ github.event_name == 'release' && github.event.release.html_url || format('https://github.com/{0}/releases/tag/{1}', github.repository, env.VERSION) }}
**Triggered by**: ${{ github.event_name }}
labels: automation,version-update
delete-branch: true

trigger-changelog:
needs: update-version
permissions:
contents: write # create temporary branch to store changelog changes
pull-requests: write # create PR with changelog changes
uses: ./.github/workflows/reusable_publish_changelog.yml