blob: e7b25a97346a913f7336ac1eed0712e3068ec343 (
plain)
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
|
name: "Publish Images"
on:
workflow_call:
inputs:
git_ref:
required: true
type: string
artifact_id:
required: true
type: string
artifact_file:
required: true
type: string
dry_run:
required: false
type: boolean
default: false
jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
VERSION: "${{ inputs.git_ref }}"
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "${{ env.VERSION }}"
- name: "Download artifact"
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact_id }}
path: artifacts
- name: "Publish artifact"
env:
IMG: "${{ inputs.artifact_file }}"
run: |
set -ex
mkdir -p publish
mv artifacts/${{ inputs.artifact_file }} publish/
cd publish
asset="${IMG}"
[[ "$IMG" =~ .*".img" ]] && {
zip "${IMG%.img}.zip" "${IMG?}"
asset="${IMG%.img}.zip"
}
checksum="$(md5sum "$asset")"
echo "Artifact Checksum:
$checksum"
[[ "${{ inputs.dry_run }}" == "true" ]] && {
echo "Dry run only. Skipping release..."
exit 0
}
title="$(hub release show -f "%t" "${VERSION}")
body="$(hub release show -f "%b" "${VERSION}")"
if ! [[ "$body" =~ .*'**Checksums:**'.* ]]
then
body="${body}
**Checksums:**
\`\`\`
\`\`\`"
fi
body="${body%$'\n```'*}
$checksum
```"
hub release edit -a "${IMG?}" -m "${title?}" -m "$body" "${VERSION?}"
|