-
Notifications
You must be signed in to change notification settings - Fork 2.4k
259 lines (226 loc) · 8.91 KB
/
release-artifacts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: Upload Release Artifacts
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Release version to build and upload (e.g. "v9.8.7")'
required: true
dryrun:
description: 'Perform all the steps except uploading to the release page'
required: true
default: "true" # 'choice' type requires string value
type: choice
options:
- "true" # Must be quoted string, boolean value not supported.
- "false"
permissions:
contents: write
actions: write
jobs:
build:
runs-on: ubuntu-24.04
steps:
# If the job fails, these details are all but impossible to observe.yy
- name: Provide github event JSON for examination
run: |
echo "::group::Event JSON"
jq --color-output "." "${{ github.event_path }}"
echo "::endgroup::"
- name: Determine Version
id: getversion
run: |
if [[ -z "${{ inputs.version }}" ]]
then
VERSION=${{ github.event.release.tag_name }}
else
VERSION=${{ inputs.version }}
fi
if ! grep -Eq 'v[0-9]+(\.[0-9]+(\.[0-9]+(-.+)?)?)?$' <<<"$VERSION"
then
echo "Unable to parse release version '$VERSION' from github event JSON, or workflow 'version' input."
exit 1
fi
if grep -Eq '.+-dev$' <<<"$VERSION"
then
echo "Refusing to process a "-dev" version '$VERSION'"
exit 1
fi
echo
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Consolidate dryrun setting to always be true or false
id: actual_dryrun
run: |
# The 'release' trigger will not have a 'dryrun' input set. Handle
# this case in a readable/maintainable way.
if [[ -z "${{ inputs.dryrun }}" ]]
then
echo "dryrun=false" >> $GITHUB_OUTPUT
else
echo "dryrun=${{ inputs.dryrun }}" >> $GITHUB_OUTPUT
fi
- name: Dry Run Status
run: |
echo "::notice::This workflow execution will be a dry-run: ${{ steps.actual_dryrun.outputs.dryrun }}"
- name: Check uploads
id: check
run: |
URI="https://github.com/containers/podman/releases/download/${{steps.getversion.outputs.version}}"
for artifact in "podman-remote-release-darwin_amd64.zip darwin_amd" \
'podman-remote-release-darwin_arm64.zip darwin_arm' \
'podman-remote-release-windows_amd64.zip windows_amd' \
'podman-remote-static-linux_amd64.tar.gz linux_amd' \
'podman-remote-static-linux_arm64.tar.gz linux_arm'
do
set -- $artifact # Convert the "tuple" into the param args $1 $2...
status=$(curl -s -o /dev/null -w "%{http_code}" "${URI}/${1:?}")
if [[ "$status" == "404" ]] ; then
echo "${1:?} will be built"
needsbuild=true
echo "${2:?}=true" >> $GITHUB_OUTPUT
else
echo "::warning::${1:?} already exists, skipping"
fi
done
if [ "$needsbuild" = true ]; then
echo "buildartifacts=true" >> $GITHUB_OUTPUT
else
echo "No new artifacts need to be built."
fi
- name: Checkout Version
uses: actions/checkout@v4
with:
ref: ${{steps.getversion.outputs.version}}
- name: Set up Go
if: >-
steps.check.outputs.buildartifacts == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
uses: actions/setup-go@v5
with:
go-version: stable
- name: Setup artifact directory
if: >-
steps.check.outputs.buildartifacts == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: mkdir -p release/
- name: Build Darwin AMD
if: >-
steps.check.outputs.darwin_amd == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: |
make podman-remote-release-darwin_amd64.zip
mv podman-remote-release-darwin_amd64.zip release/
- name: Build Darwin ARM
if: >-
steps.check.outputs.darwin_arm == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: |
make podman-remote-release-darwin_arm64.zip
mv podman-remote-release-darwin_arm64.zip release/
- name: Build Linux AMD
if: >-
steps.check.outputs.linux_amd == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: |
make podman-remote-static-linux_amd64
tar -cvzf podman-remote-static-linux_amd64.tar.gz bin/podman-remote-static-linux_amd64
mv podman-remote-static-linux_amd64.tar.gz release/
- name: Build Linux ARM
if: >-
steps.check.outputs.linux_arm == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: |
make podman-remote-static-linux_arm64
tar -cvzf podman-remote-static-linux_arm64.tar.gz bin/podman-remote-static-linux_arm64
mv podman-remote-static-linux_arm64.tar.gz release/
- name: Build Windows AMD
if: >-
steps.check.outputs.windows_amd == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: |
sudo apt-get install -y pandoc
make podman-remote-release-windows_amd64.zip
mv podman-remote-release-windows_amd64.zip release/
- name: shasums
if: >-
steps.check.outputs.buildartifacts == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
run: |
pushd release
sha256sum *.zip *.tar.gz > shasums
popd
- name: Upload to Actions as artifact
if: >-
steps.check.outputs.buildartifacts == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'true'
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
release/*
- name: Upload to Release
id: upload
if: >-
steps.check.outputs.buildartifacts == 'true' &&
steps.actual_dryrun.outputs.dryrun == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
(gh release download ${{steps.getversion.outputs.version}} -p "shasums" || exit 0)
cat release/shasums >> shasums
gh release upload ${{steps.getversion.outputs.version}} release/*.zip release/*.tar.gz
gh release upload ${{steps.getversion.outputs.version}} --clobber shasums
# WARNING: This should only be set when 'notification' job should be triggered
echo "complete=true" >> $GITHUB_OUTPUT
- name: Trigger Windows Installer
if: >-
steps.check.outputs.windows_amd == 'true' ||
steps.actual_dryrun.outputs.dryrun == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run upload-win-installer.yml -f version=${{steps.getversion.outputs.version}} -f dryrun=false
outputs:
uploaded: ${{ steps.upload.outputs.complete }}
version: ${{ steps.getversion.outputs.version }}
notification:
if: needs.build.outputs.uploaded == 'true'
runs-on: ubuntu-24.04
needs: build
steps:
- name: Format release email
id: format
env:
VERSION: ${{ needs.build.outputs.version }}
run: |
if grep -Eq '.+-rc' <<<"$VERSION"
then
RC_PREFIX="candidate "
fi
echo "mail_subj=Podman ${RC_PREFIX}${VERSION} Released" >> $GITHUB_OUTPUT
cat <<EOF>email_body.txt
Hi all,
Podman ${RC_PREFIX}${VERSION} is now available. You may view the full details at
https://github.com/${{ github.repository }}/releases/tag/$VERSION
Release ${RC_PREFIX}Notes:
--------------
EOF
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh release view $VERSION \
--repo ${{ github.repository }} --json=body --jq '.body' >> email_body.txt
# If job fails, permit operator to observe contents in case helpful.
- name: Provide release e-mail contents for examination
run: cat email_body.txt
- name: Send release notification e-mail
# Ref: https://github.com/dawidd6/action-send-mail
uses: dawidd6/[email protected]
with:
server_address: ${{secrets.ACTION_MAIL_SERVER}}
server_port: 465
username: ${{secrets.ACTION_MAIL_USERNAME}}
password: ${{secrets.ACTION_MAIL_PASSWORD}}
subject: ${{ steps.format.outputs.mail_subj }}
to: Podman List <[email protected]>
from: ${{secrets.ACTION_MAIL_SENDER}}
body: file://./email_body.txt