@@ -3,13 +3,10 @@ name: Publish Action
33on :
44 workflow_dispatch :
55 inputs :
6- version :
7- description : " Semantic version without prefix (example: 1.0.0)"
8- required : true
9- update_major_tag :
10- description : " Also update moving major tag (action-v1, action-v2, ...)"
6+ release_tag :
7+ description : " Rolling action tag to update (example: action-v1)"
118 required : false
12- default : " true "
9+ default : " action-v1 "
1310
1411jobs :
1512 publish :
@@ -23,28 +20,23 @@ jobs:
2320 with :
2421 fetch-depth : 0
2522
26- - name : Validate version and compute tags
23+ - name : Validate and compute tag
2724 id : vars
2825 shell : bash
2926 run : |
3027 set -euo pipefail
3128
32- version="${{ inputs.version }}"
33- if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
34- echo "Invalid version '$version'. Use semantic version format x.y.z." >&2
35- exit 1
29+ release_tag="${{ inputs.release_tag }}"
30+ if [[ -z "$release_tag" ]]; then
31+ release_tag="action-v1"
3632 fi
3733
38- full_tag="action-v${version}"
39- major_tag="action-v${version%%.*}"
40-
41- if git rev-parse "$full_tag" >/dev/null 2>&1; then
42- echo "Tag already exists: $full_tag" >&2
34+ if [[ ! "$release_tag" =~ ^action-v[0-9]+$ ]]; then
35+ echo "Invalid release tag '$release_tag'. Use format action-v<major> (example: action-v1)." >&2
4336 exit 1
4437 fi
4538
46- echo "full_tag=$full_tag" >> "$GITHUB_OUTPUT"
47- echo "major_tag=$major_tag" >> "$GITHUB_OUTPUT"
39+ echo "release_tag=$release_tag" >> "$GITHUB_OUTPUT"
4840
4941 - name : Configure git user
5042 shell : bash
@@ -53,27 +45,29 @@ jobs:
5345 git config user.name "github-actions[bot]"
5446 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
5547
56- - name : Create immutable release tag
57- shell : bash
58- run : |
59- set -euo pipefail
60- git tag -a "${{ steps.vars.outputs.full_tag }}" -m "Action release ${{ steps.vars.outputs.full_tag }}"
61- git push origin "${{ steps.vars.outputs.full_tag }}"
62-
63- - name : Update major moving tag
64- if : ${{ inputs.update_major_tag == 'true' }}
48+ - name : Update rolling release tag
6549 shell : bash
6650 run : |
6751 set -euo pipefail
68- git tag -fa "${{ steps.vars.outputs.major_tag }}" -m "Action major tag -> ${{ steps.vars.outputs.full_tag }}"
69- git push origin "${{ steps.vars.outputs.major_tag }}" --force
52+ git tag -fa "${{ steps.vars.outputs.release_tag }}" -m "Action release ${{ steps.vars.outputs.release_tag }}"
53+ git push origin "${{ steps.vars.outputs.release_tag }}" --force
7054
71- - name : Create GitHub release
55+ - name : Upsert GitHub release
7256 env :
7357 GH_TOKEN : ${{ github.token }}
7458 shell : bash
7559 run : |
7660 set -euo pipefail
77- gh release create "${{ steps.vars.outputs.full_tag }}" \
78- --title "JAIPilot Action ${{ steps.vars.outputs.full_tag }}" \
79- --notes "Release of JAIPilot GitHub Action."
61+ release_tag="${{ steps.vars.outputs.release_tag }}"
62+ release_title="JAIPilot Action ${release_tag}"
63+ release_notes="Rolling release for ${release_tag}. Updated from commit ${GITHUB_SHA::7} on $(date -u +'%Y-%m-%d %H:%M:%S UTC')."
64+
65+ if gh release view "$release_tag" >/dev/null 2>&1; then
66+ gh release edit "$release_tag" \
67+ --title "$release_title" \
68+ --notes "$release_notes"
69+ else
70+ gh release create "$release_tag" \
71+ --title "$release_title" \
72+ --notes "$release_notes"
73+ fi
0 commit comments