10
10
description : " Tag to release"
11
11
required : true
12
12
13
+ permissions :
14
+ contents : read
15
+
13
16
jobs :
14
17
image :
15
- runs-on : ubuntu-latest
18
+ runs-on : ubuntu-24.04
16
19
name : Release Actions
20
+ permissions :
21
+ contents : read
22
+ packages : write
17
23
env :
18
24
GITHUB_TOKEN : ${{ secrets.RELEASE_GITHUB_TOKEN }}
19
25
steps :
20
26
- name : Checkout
21
27
uses : actions/checkout@v4
28
+ with :
29
+ persist-credentials : true
22
30
23
31
- name : Check tofu actions are up to date
24
32
run : |
@@ -38,14 +46,14 @@ jobs:
38
46
39
47
- name : Build action image
40
48
id : image_build
49
+ env :
50
+ RELEASE_TAG : " ${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
41
51
run : |
42
- RELEASE_TAG="${{ github.event.release.tag_name }}${{ github.event.inputs.tag_name }}"
43
-
44
52
docker buildx build \
45
53
--build-arg FETCH_CHECKSUMS=yes \
46
54
--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" \
49
57
--platform linux/amd64,linux/arm64 \
50
58
--attest type=provenance,mode=max,builder-id=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID \
51
59
--push \
@@ -55,29 +63,31 @@ jobs:
55
63
echo "digest=$(<manifest-list-digest.txt)" >> "$GITHUB_OUTPUT"
56
64
57
65
- 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 }}
58
69
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)
62
72
63
73
git config --global user.name "Daniel Flook"
64
74
git config --global user.email "[email protected] "
65
75
66
76
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"
71
81
}
72
82
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
74
84
75
- if git clone https://dflook:[email protected] /dflook/$action.git "$HOME/$action"; then
85
+ if git clone " https://dflook:[email protected] /dflook/$action.git" "$HOME/$action"; then
76
86
echo "Releasing dflook/$action@$RELEASE_TAG"
77
87
78
88
# git tags that use DockerHub for the image
79
89
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"
81
91
82
92
git -C "$HOME/$action" add -A
83
93
git -C "$HOME/$action" commit -m "$RELEASE_TAG"
90
100
# git tags that use GitHub Container Registry for the image
91
101
git -C "$HOME/$action" checkout ghcr || git -C "$HOME/$action" checkout -b ghcr
92
102
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"
94
104
95
105
git -C "$HOME/$action" add -A
96
106
git -C "$HOME/$action" commit -m "$RELEASE_TAG-ghcr"
@@ -101,11 +111,11 @@ jobs:
101
111
git -C "$HOME/$action" push --force --tags
102
112
103
113
# Create the github release
104
- cat $GITHUB_WORKSPACE/.github/release_template.md \
114
+ cat " $GITHUB_WORKSPACE/.github/release_template.md" \
105
115
| envsubst \
106
116
| jq --slurp --raw-input --arg RELEASE_TAG "$RELEASE_TAG" '{"tag_name": $RELEASE_TAG, "name": $RELEASE_TAG, "body": . }' \
107
117
| curl -X POST \
108
- --user dflook:$GITHUB_TOKEN \
118
+ --user " dflook:$GITHUB_TOKEN" \
109
119
--header "Content-Type: application/json" \
110
120
--data-binary @- \
111
121
"https://api.github.com/repos/dflook/$action/releases"
0 commit comments