1010 description : " Tag to release"
1111 required : true
1212
13+ permissions :
14+ contents : read
15+
1316jobs :
1417 image :
15- runs-on : ubuntu-latest
18+ runs-on : ubuntu-24.04
1619 name : Release Actions
20+ permissions :
21+ contents : read
22+ packages : write
1723 env :
1824 GITHUB_TOKEN : ${{ secrets.RELEASE_GITHUB_TOKEN }}
1925 steps :
2026 - name : Checkout
2127 uses : actions/checkout@v4
28+ with :
29+ persist-credentials : true
2230
2331 - name : Check tofu actions are up to date
2432 run : |
@@ -38,14 +46,14 @@ jobs:
3846
3947 - name : Build action image
4048 id : image_build
49+ env :
50+ RELEASE_TAG : " ${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
4151 run : |
42- RELEASE_TAG="${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
43-
4452 docker buildx build \
4553 --build-arg FETCH_CHECKSUMS=yes \
4654 --build-arg VERSION="${RELEASE_TAG:1}" \
47- --tag danielflook/terraform-github-actions:$RELEASE_TAG \
48- --tag ghcr.io/dflook/terraform-github-actions:$RELEASE_TAG \
55+ --tag " danielflook/terraform-github-actions:$RELEASE_TAG" \
56+ --tag " ghcr.io/dflook/terraform-github-actions:$RELEASE_TAG" \
4957 --platform linux/amd64,linux/arm64 \
5058 --attest type=provenance,mode=max,builder-id=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID \
5159 --push \
@@ -55,29 +63,31 @@ jobs:
5563 echo "digest=$(<manifest-list-digest.txt)" >> "$GITHUB_OUTPUT"
5664
5765 - name : Release actions
66+ env :
67+ RELEASE_TAG : " ${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
68+ IMAGE_DIGEST : ${{ steps.image_build.outputs.digest }}
5869 run : |
59- export RELEASE_TAG="${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
60- export major=$(echo $RELEASE_TAG | cut -d. -f1)
61- export minor=$(echo $RELEASE_TAG | cut -d. -f2)
70+ export major=$(echo "$RELEASE_TAG" | cut -d. -f1)
71+ export minor=$(echo "$RELEASE_TAG" | cut -d. -f2)
6272
6373 git config --global user.name "Daniel Flook"
6474 git config --global user.email "daniel@flook.org"
6575
6676 function prepare_release() {
67- rsync -r $GITHUB_WORKSPACE/$action/ $HOME/$action
68- rm -rf $HOME/$action/.github
69- mkdir $HOME/$action/.github
70- cp $GITHUB_WORKSPACE/.github/FUNDING.yml $HOME/$action/.github/FUNDING.yml
77+ rsync -r " $GITHUB_WORKSPACE/$action/" " $HOME/$action"
78+ rm -rf " $HOME/$action/.github"
79+ mkdir " $HOME/$action/.github"
80+ cp " $GITHUB_WORKSPACE/.github/FUNDING.yml" " $HOME/$action/.github/FUNDING.yml"
7181 }
7282
73- for action in $(cd $GITHUB_WORKSPACE && find . -name action.yaml -printf "%h\n" | sed 's/^.\///'); do
83+ for action in $(cd " $GITHUB_WORKSPACE" && find . -name action.yaml -printf "%h\n" | sed 's/^.\///'); do
7484
75- if git clone https://dflook:$GITHUB_TOKEN@github.com/dflook/$action.git "$HOME/$action"; then
85+ if git clone " https://dflook:$GITHUB_TOKEN@github.com/dflook/$action.git" "$HOME/$action"; then
7686 echo "Releasing dflook/$action@$RELEASE_TAG"
7787
7888 # git tags that use DockerHub for the image
7989 prepare_release
80- sed -i ' s| image:.*| image: docker://danielflook/terraform-github-actions@${{ steps.image_build.outputs.digest }}|' $HOME/$action/action.yaml
90+ sed -i " s| image:.*| image: docker://danielflook/terraform-github-actions@$IMAGE_DIGEST|" " $HOME/$action/action.yaml"
8191
8292 git -C "$HOME/$action" add -A
8393 git -C "$HOME/$action" commit -m "$RELEASE_TAG"
90100 # git tags that use GitHub Container Registry for the image
91101 git -C "$HOME/$action" checkout ghcr || git -C "$HOME/$action" checkout -b ghcr
92102 prepare_release
93- sed -i ' s| image:.*| image: docker://ghcr.io/dflook/terraform-github-actions@${{ steps.image_build.outputs.digest }}|' $HOME/$action/action.yaml
103+ sed -i " s| image:.*| image: docker://ghcr.io/dflook/terraform-github-actions@$IMAGE_DIGEST|" " $HOME/$action/action.yaml"
94104
95105 git -C "$HOME/$action" add -A
96106 git -C "$HOME/$action" commit -m "$RELEASE_TAG-ghcr"
@@ -101,11 +111,11 @@ jobs:
101111 git -C "$HOME/$action" push --force --tags
102112
103113 # Create the github release
104- cat $GITHUB_WORKSPACE/.github/release_template.md \
114+ cat " $GITHUB_WORKSPACE/.github/release_template.md" \
105115 | envsubst \
106116 | jq --slurp --raw-input --arg RELEASE_TAG "$RELEASE_TAG" '{"tag_name": $RELEASE_TAG, "name": $RELEASE_TAG, "body": . }' \
107117 | curl -X POST \
108- --user dflook:$GITHUB_TOKEN \
118+ --user " dflook:$GITHUB_TOKEN" \
109119 --header "Content-Type: application/json" \
110120 --data-binary @- \
111121 "https://api.github.com/repos/dflook/$action/releases"
0 commit comments