-
Notifications
You must be signed in to change notification settings - Fork 274
244 lines (214 loc) Β· 8.11 KB
/
release.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
#
# .github/workflows/release.yml
#
---
name: release
defaults:
run:
# Prefixes all `run` commands with the following command to force them to run outside Rosetta.
shell: arch -arm64 bash --noprofile --norc -eo pipefail {0}
on:
release:
types: [published]
jobs:
start:
runs-on: macos-15
outputs:
dry_run: ${{ steps.dry_run.outputs.dry_run }}
mas_version: ${{ steps.mas_version.outputs.mas_version }}
release_branch: ${{ steps.release_branch.outputs.release_branch }}
steps:
# Logs event details and sets `DRY_RUN` env var
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
# https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=published#release
- name: π Log release event
# This step will only run for a real 'release' event.
if: ${{ github.event.release.name != '' }}
run: |
echo "Triggered by a release publication event (wet run)"
echo "release.name: ${{ github.event.release.name }}"
echo "release.tag_name: ${{ github.event.release.tag_name }}"
echo "release.target_commitish: ${{ github.event.release.target_commitish }}"
echo -e "release.body: \n${{ github.event.release.body }}"
- id: dry_run
run: |
echo "DRY_RUN=false" >>"$GITHUB_OUTPUT"
- id: mas_version
run: |
echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
- id: release_branch
run: |
echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
prepare-release:
runs-on: macos-15
needs: [start]
steps:
- uses: actions/checkout@v4
with:
# A fetch-depth of 0 includes all history and tags for script/version
fetch-depth: 0
- name: π’ Bootstrap
run: |
script/bootstrap -f
- name: π Create mas release branch
env:
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
run: |
git branch "${RELEASE_BRANCH}"
git switch "${RELEASE_BRANCH}"
- name: π Update version
env:
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
run: |
script/version_bump "${MAS_VERSION}"
- name: π§ Configure Git Author
run: |
git config --global user.name 'masclibot'
git config --global user.email '[email protected]'
- name: πΎ Commit changes
env:
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
run: |
git add \
"Homebrew/mas.rb" \
"Homebrew/mas-tap.rb" \
"Package.swift"
git commit \
--message="π Version ${MAS_VERSION}"
git push \
--set-upstream origin "${RELEASE_BRANCH}"
pkg-installer:
runs-on: macos-15
needs: [start, prepare-release]
steps:
- uses: actions/checkout@v4
with:
# A fetch-depth of 0 includes all history and tags for script/version
fetch-depth: 0
ref: ${{ needs.start.outputs.release_branch }}
- name: π’ Bootstrap
run: |
script/bootstrap -f
# Important to trigger a universal build first as package just works with
# the `mas` binary in finds in the build dir.
- name: ποΈ Build Universal
run: |
script/build --universal
- name: π¦ macOS Package
run: |
script/package
- name: π Upload mas.pkg
env:
GH_TOKEN: ${{ github.token }}
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
if: ${{ needs.start.outputs.dry_run == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/mas.pkg
homebrew-tap:
runs-on: macos-15
needs: [start, prepare-release]
steps:
- name: πΊ Checkout mas repo
uses: actions/checkout@v4
with:
# A fetch-depth of 0 includes all history and tags for script/version
fetch-depth: 0
ref: ${{ needs.start.outputs.release_branch }}
- name: π’ Bootstrap
run: |
script/bootstrap -f
# The mas-cli/homebrew-tap repo needs to be checked out using the current
# GitHub credentials in order to open a PR. However, the `brew tap` command
# must be run for Homebrew to see the dir as a tap.
# This is necessary to avoid the following error:
# Error: No available formula or cask with the name "mas-cli/tap/mas".
- name: π° Checkout mas tap
run: |
rm -rf /opt/homebrew/Library/Taps
mkdir Taps
ln -s $(realpath Taps) /opt/homebrew/Library/Taps
ls -l /opt/homebrew/Library/Taps
brew tap mas-cli/tap
brew tap
# Checkout with a token for write access
- name: π° Re-clone mas tap
uses: actions/checkout@v4
with:
repository: mas-cli/homebrew-tap
token: ${{ secrets.DEPLOY_TOKEN }}
# brew --repository mas-cli/tap
path: Taps/mas-cli/homebrew-tap
- name: π§ Configure Git Author
run: |
git config --global user.name 'masclibot'
git config --global user.email '[email protected]'
- name: β€΄οΈ Open mas tap PR
env:
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
DRY_RUN: ${{ needs.start.outputs.dry_run }}
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
working-directory: /opt/homebrew/Library/Taps/mas-cli/homebrew-tap
run: |
git branch "${RELEASE_BRANCH}"
git switch "${RELEASE_BRANCH}"
cp -v \
${GITHUB_WORKSPACE}/Homebrew/mas-tap.rb \
Formula/mas.rb
git add Formula/mas.rb
git commit --message="π Version ${MAS_VERSION}"
git push \
--set-upstream origin "${RELEASE_BRANCH}"
gh pr create \
--assignee phatblat \
--base main \
--draft \
--head "${RELEASE_BRANCH}" \
--title "π Version ${MAS_VERSION}" \
--body "This PR contains the changes from releasing version \
[${MAS_VERSION}](https://github.com/mas-cli/mas/releases/tag/${MAS_VERSION})."
- name: π° Update mas tap formula
env:
GH_TOKEN: ${{ github.token }}
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
run: |
DRY_RUN=${DRY_RUN} \
script/brew_tap_update ${MAS_VERSION}
- name: π Upload Bottles
env:
GH_TOKEN: ${{ github.token }}
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
if: ${{ needs.start.outputs.dry_run == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/bottles/mas-*.bottle.tar.gz
homebrew-core:
runs-on: macos-15
needs: [start, prepare-release, homebrew-tap]
steps:
- uses: actions/checkout@v4
with:
# A fetch-depth of 0 includes all history and tags for script/version
fetch-depth: 0
ref: ${{ needs.start.outputs.release_branch }}
- name: π’ Bootstrap
run: |
script/bootstrap -f
- name: π§ Configure Git Author
run: |
git config --global user.name 'masclibot'
git config --global user.email '[email protected]'
- name: πΊ Update Homebrew mas formula
env:
GH_TOKEN: ${{ github.token }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
DRY_RUN: ${{ needs.start.outputs.dry_run }}
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
run: |
DRY_RUN=${DRY_RUN} \
script/brew_core_update ${MAS_VERSION}