Skip to content

Commit 1138f92

Browse files
authored
Merge pull request #1018 from aws-powertools/chore/version-update-automation
chore: version update automation
2 parents 3a6cf65 + 5bb9736 commit 1138f92

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Update Version File After Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
update-version:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20+
21+
- name: Get version
22+
id: get_version
23+
run: |
24+
if [ "${{ github.event_name }}" = "release" ]; then
25+
VERSION="${{ github.event.release.tag_name }}"
26+
else
27+
VERSION=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
28+
fi
29+
30+
# Remove 'v' prefix if present
31+
VERSION="${VERSION#v}"
32+
33+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
34+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
38+
- name: Write version to version.txt
39+
run: echo "${{ env.VERSION }}" > version.txt
40+
41+
- name: Check if changes exist
42+
id: check_changes
43+
run: |
44+
git add version.txt
45+
if git diff --staged --quiet; then
46+
echo "has_changes=false" >> $GITHUB_OUTPUT
47+
else
48+
echo "has_changes=true" >> $GITHUB_OUTPUT
49+
fi
50+
51+
- name: Create PR for version.txt update
52+
if: steps.check_changes.outputs.has_changes == 'true'
53+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
54+
with:
55+
commit-message: "chore: update version.txt to ${{ env.VERSION }}"
56+
branch: update-version-txt-${{ github.run_id }}
57+
title: "chore: update version to ${{ env.VERSION }}"
58+
body: |
59+
This PR updates version.txt to the latest release version.
60+
61+
**Version**: ${{ env.VERSION }}
62+
**Release**: ${{ github.event_name == 'release' && github.event.release.html_url || format('https://github.com/{0}/releases/tag/{1}', github.repository, env.VERSION) }}
63+
**Triggered by**: ${{ github.event_name }}
64+
labels: automation,version-update
65+
delete-branch: true
66+
67+
trigger-changelog:
68+
needs: update-version
69+
permissions:
70+
contents: write # create temporary branch to store changelog changes
71+
pull-requests: write # create PR with changelog changes
72+
uses: ./.github/workflows/reusable_publish_changelog.yml

0 commit comments

Comments
 (0)