-
Notifications
You must be signed in to change notification settings - Fork 275
175 lines (155 loc) · 5.49 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
#
# .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-14
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 }}"
echo "DRY_RUN=false" >>$GITHUB_ENV
echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>${GITHUB_ENV}
echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>${GITHUB_ENV}
echo "RELEASE_COMMIT=${{ github.event.release.target_commitish }}" >>${GITHUB_ENV}
- name: 🔈 Log environment variables
env:
DRY_RUN: ${{ env.DRY_RUN }}
MAS_VERSION: ${{ env.MAS_VERSION }}
RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }}
RELEASE_COMMIT: ${{ env.RELEASE_COMMIT }}
run: |
echo "DRY_RUN: ${DRY_RUN}"
echo "MAS_VERSION: ${MAS_VERSION}"
echo "RELEASE_BRANCH: ${RELEASE_BRANCH}"
echo "RELEASE_COMMIT: ${RELEASE_COMMIT}"
prepare-release:
runs-on: macos-14
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: 🔀 Create release branch
env:
RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }}
run: |
git branch "${RELEASE_BRANCH}"
git switch "${RELEASE_BRANCH}"
- name: 🔖 Update version
env:
MAS_VERSION: ${{ env.MAS_VERSION }}
RELEASE_COMMIT: ${{ env.RELEASE_COMMIT }}
run: |
script/version_bump "${MAS_VERSION}" "${RELEASE_COMMIT}"
- name: 💾 Commit changes
env:
MAS_VERSION: ${{ env.MAS_VERSION }}
run: |
git add \
"Homebrew/mas.rb" \
"Homebrew/mas-tap.rb" \
"Sources/MasKit/Package.swift"
git commit \
--message="🔖 Version ${MAS_VERSION}"
- name: ⤴️ Open PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAS_VERSION: ${{ env.MAS_VERSION }}
RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }}
run: |
gh pr create \
--base main \
--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})."
pkg-installer:
runs-on: macos-14
needs: [prepare-release]
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
# 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:
DRY_RUN: ${{ env.DRY_RUN }}
MAS_VERSION: ${{ env.MAS_VERSION }}
if: ${{ env.DRY_RUN == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/mas.pkg
homebrew-tap:
runs-on: macos-14
needs: [prepare-release]
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: 🚰 Update mas tap formula
env:
DRY_RUN: ${{ env.DRY_RUN }}
MAS_VERSION: ${{ env.MAS_VERSION }}
run: |
DRY_RUN=${DRY_RUN} \
script/brew_tap_update ${MAS_VERSION}
- name: 🚀 Upload Bottles
env:
DRY_RUN: ${{ env.DRY_RUN }}
MAS_VERSION: ${{ env.MAS_VERSION }}
if: ${{ env.DRY_RUN == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/bottles/mas-*.bottle.tar.gz
homebrew-core:
runs-on: macos-14
needs: [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
- name: 👢 Bootstrap
run: |
script/bootstrap -f
- name: 🍺 Update Homebrew mas formula
env:
DRY_RUN: ${{ env.DRY_RUN }}
MAS_VERSION: ${{ env.MAS_VERSION }}
run: |
DRY_RUN=${DRY_RUN} \
script/brew_core_update ${MAS_VERSION}