1+ # This Action will run when a release is published from the LTS branches
2+ # and create new LTS tag, release and publish the image in GHCR
3+
4+ name : Tag and Recreate LTS Release
5+
6+ on :
7+ release :
8+ types : [published]
9+
10+ permissions :
11+ contents : write
12+ packages : write
13+
14+ jobs :
15+ recreate-lts-release :
16+ if : startsWith(github.event.release.tag_name, '1.2.')
17+ name : Recreate LTS Release
18+ runs-on : ubuntu-latest
19+ outputs :
20+ lts_tag : ${{ steps.vars.outputs.LTS_TAG }}
21+
22+ steps :
23+ - name : Checkout repository
24+ uses : actions/checkout@v4
25+ with :
26+ fetch-depth : 0
27+
28+ - name : Set up Git identity
29+ run : |
30+ git config user.name "github-actions"
31+ git config user.email "github-actions@github.com"
32+
33+ - name : Determine LTS tag and update
34+ id : vars
35+ env :
36+ BRANCH_REF : ${{ github.event.release.target_commitish }}
37+ RELEASE_TAG : ${{ github.event.release.tag_name }}
38+ RELEASE_BODY : ${{ github.event.release.body }}
39+ run : |
40+ echo "Release published from branch: $BRANCH_REF"
41+
42+ # Creating a LTS tag from the branch name
43+ SHORT_TAG=$(echo "$RELEASE_TAG" | cut -d. -f1,2)
44+ LTS_TAG="${SHORT_TAG}-lts"
45+ echo "LTS_TAG=$LTS_TAG" >> "$GITHUB_OUTPUT"
46+
47+ # Force update the tag to the current commit
48+ git tag -f "$LTS_TAG" $GITHUB_SHA
49+ git push origin -f "$LTS_TAG"
50+
51+ # Write release notes into env (for multiline input)
52+ echo "RELEASE_BODY<<EOF" >> "$GITHUB_ENV"
53+ echo "${RELEASE_BODY}" >> "$GITHUB_ENV"
54+ echo "EOF" >> "$GITHUB_ENV"
55+
56+ - name : Delete existing LTS release (if any)
57+ continue-on-error : true
58+ env :
59+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60+ LTS_TAG : ${{ steps.vars.outputs.LTS_TAG }}
61+ run : |
62+ echo "Trying to delete existing release for $LTS_TAG"
63+ gh release delete "$LTS_TAG" -y
64+
65+ - name : Create fresh LTS release
66+ env :
67+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68+ LTS_TAG : ${{ steps.vars.outputs.LTS_TAG }}
69+ RELEASE_BODY : ${{ env.RELEASE_BODY }}
70+ run : |
71+ echo "Creating new GitHub release for $LTS_TAG"
72+ gh release create "$LTS_TAG" --title "$LTS_TAG" --notes "$RELEASE_BODY"
73+
74+ call-publish-image :
75+ name : Publish LTS Image in GHCR
76+ needs : recreate-lts-release
77+ uses : ./.github/workflows/publish.yml
78+ with :
79+ tag : ${{ needs.recreate-lts-release.outputs.lts_tag }}
80+ ref : ${{ github.event.release.tag_name }}
81+ platforms : linux/amd64,linux/arm64
0 commit comments