-
Notifications
You must be signed in to change notification settings - Fork 1
178 lines (162 loc) · 6.22 KB
/
promote-packages.yml
File metadata and controls
178 lines (162 loc) · 6.22 KB
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
name: promote-packages
on:
workflow_dispatch:
inputs:
version:
description: "Release tag (e.g. v0.72.0). Must already exist as a non-draft Release."
required: true
type: string
publish_brew:
description: "Push formula update to leifericf/homebrew-mino main"
type: boolean
default: false
publish_scoop:
description: "Push manifest update to leifericf/scoop-mino main"
type: boolean
default: false
permissions:
contents: read
jobs:
validate:
name: validate release
runs-on: ubuntu-22.04
outputs:
version_number: ${{ steps.parse.outputs.version_number }}
sha_darwin_amd64: ${{ steps.checksums.outputs.sha_darwin_amd64 }}
sha_darwin_arm64: ${{ steps.checksums.outputs.sha_darwin_arm64 }}
sha_linux_amd64: ${{ steps.checksums.outputs.sha_linux_amd64 }}
sha_linux_arm64: ${{ steps.checksums.outputs.sha_linux_arm64 }}
sha_windows_amd64: ${{ steps.checksums.outputs.sha_windows_amd64 }}
env:
VERSION: ${{ inputs.version }}
GH_TOKEN: ${{ github.token }}
steps:
- name: Validate tag format
run: |
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.]+)?$ ]]; then
echo "Version must be vX.Y.Z or vX.Y.Z-suffix; got: $VERSION" >&2
exit 1
fi
- name: Parse version number
id: parse
run: echo "version_number=${VERSION#v}" >> "$GITHUB_OUTPUT"
- name: Look up release
run: |
gh release view "$VERSION" --repo "${GITHUB_REPOSITORY}" --json tagName,isDraft > release.json
if [ "$(jq -r '.isDraft' release.json)" = "true" ]; then
echo "Release $VERSION is still a draft; un-draft it before promoting" >&2
exit 1
fi
echo "Release $VERSION is published"
- name: Download checksums.txt and assets
run: |
gh release download "$VERSION" --repo "${GITHUB_REPOSITORY}" --pattern checksums.txt --dir .
gh release download "$VERSION" --repo "${GITHUB_REPOSITORY}" --pattern 'mino_*' --dir .
- name: Verify checksums
run: shasum -a 256 -c checksums.txt
- name: Extract per-asset SHA256s
id: checksums
run: |
while IFS= read -r line; do
sha=$(echo "$line" | awk '{print $1}')
name=$(echo "$line" | awk '{print $2}' | sed 's|^[*]||')
case "$name" in
*darwin_amd64*) echo "sha_darwin_amd64=$sha" >> "$GITHUB_OUTPUT" ;;
*darwin_arm64*) echo "sha_darwin_arm64=$sha" >> "$GITHUB_OUTPUT" ;;
*linux_amd64*) echo "sha_linux_amd64=$sha" >> "$GITHUB_OUTPUT" ;;
*linux_arm64*) echo "sha_linux_arm64=$sha" >> "$GITHUB_OUTPUT" ;;
*windows_amd64*) echo "sha_windows_amd64=$sha" >> "$GITHUB_OUTPUT" ;;
esac
done < checksums.txt
brew:
name: update homebrew-mino main
needs: validate
if: ${{ inputs.publish_brew }}
runs-on: ubuntu-22.04
env:
VERSION: ${{ inputs.version }}
VERSION_NUMBER: ${{ needs.validate.outputs.version_number }}
SHA_DARWIN_AMD64: ${{ needs.validate.outputs.sha_darwin_amd64 }}
SHA_DARWIN_ARM64: ${{ needs.validate.outputs.sha_darwin_arm64 }}
SHA_LINUX_AMD64: ${{ needs.validate.outputs.sha_linux_amd64 }}
SHA_LINUX_ARM64: ${{ needs.validate.outputs.sha_linux_arm64 }}
GH_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}
steps:
- name: Checkout mino (for templates)
uses: actions/checkout@v4
with:
path: mino
- name: Checkout homebrew-mino main
uses: actions/checkout@v4
with:
repository: leifericf/homebrew-mino
ref: main
token: ${{ secrets.TAP_REPO_TOKEN }}
path: tap
- name: Render formula
working-directory: tap
run: |
mkdir -p Formula
sed \
-e "s|__VERSION_NUMBER__|${VERSION_NUMBER}|g" \
-e "s|__SHA_DARWIN_AMD64__|${SHA_DARWIN_AMD64}|g" \
-e "s|__SHA_DARWIN_ARM64__|${SHA_DARWIN_ARM64}|g" \
-e "s|__SHA_LINUX_AMD64__|${SHA_LINUX_AMD64}|g" \
-e "s|__SHA_LINUX_ARM64__|${SHA_LINUX_ARM64}|g" \
../mino/.github/release-templates/brew-formula.rb > Formula/mino.rb
cat Formula/mino.rb
- name: Commit and push main
working-directory: tap
run: |
git config user.name "mino-bot"
git config user.email "noreply@github.com"
git add Formula/mino.rb
if git diff --cached --quiet; then
echo "Formula/mino.rb already matches main; nothing to push."
exit 0
fi
git commit -m "mino ${VERSION}"
git push origin main
scoop:
name: update scoop-mino main
needs: validate
if: ${{ inputs.publish_scoop }}
runs-on: ubuntu-22.04
env:
VERSION: ${{ inputs.version }}
VERSION_NUMBER: ${{ needs.validate.outputs.version_number }}
HASH_WINDOWS_AMD64: ${{ needs.validate.outputs.sha_windows_amd64 }}
GH_TOKEN: ${{ secrets.BUCKET_REPO_TOKEN }}
steps:
- name: Checkout mino (for templates)
uses: actions/checkout@v4
with:
path: mino
- name: Checkout scoop-mino main
uses: actions/checkout@v4
with:
repository: leifericf/scoop-mino
ref: main
token: ${{ secrets.BUCKET_REPO_TOKEN }}
path: bucket-repo
- name: Render manifest
working-directory: bucket-repo
run: |
mkdir -p bucket
sed \
-e "s|__VERSION_NUMBER__|${VERSION_NUMBER}|g" \
-e "s|__HASH_WINDOWS_AMD64__|${HASH_WINDOWS_AMD64}|g" \
../mino/.github/release-templates/scoop-manifest.json > bucket/mino.json
cat bucket/mino.json
- name: Commit and push main
working-directory: bucket-repo
run: |
git config user.name "mino-bot"
git config user.email "noreply@github.com"
git add bucket/mino.json
if git diff --cached --quiet; then
echo "bucket/mino.json already matches main; nothing to push."
exit 0
fi
git commit -m "mino ${VERSION}"
git push origin main