Skip to content

Commit 37475a0

Browse files
committed
feat(builds): improve build speeds and use free arm64 runners
Improves a few things: - Use the free macos-14 runners for arm64 builds. They are not as fast the macos-13-xlarge runners used before, but they are free for public repositories, meaning we can start doing nightly arm64 builds. - Use different nix install and cache actions which are faster, and uses a single action cache key, which avoids cache rate limit errors which was slowing down cache create/restore times. - Generally refactor and tidy up various bits and pieces in workflows.
1 parent bc0082e commit 37475a0

File tree

4 files changed

+123
-121
lines changed

4 files changed

+123
-121
lines changed

.github/workflows/_build.yml

Lines changed: 51 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ name: _build
44
on:
55
workflow_call:
66
inputs:
7-
should_run:
8-
description: Whether or not to run the build job
9-
type: boolean
10-
default: false
11-
artifact_prefix:
12-
description: Artifact prefix
7+
builder_ref:
8+
description: Git ref of build-emacs-for-macos to use
139
type: string
14-
required: false
10+
required: true
1511
os:
1612
description: GitHub Actions runner OS
1713
type: string
1814
required: false
19-
default: "macos-12"
15+
default: "macos-13"
2016
build_os:
2117
description: Target OS to build for
2218
type: string
2319
required: false
24-
default: "macos-12"
20+
default: "macos-13"
21+
artifact_prefix:
22+
description: Artifact prefix for build_os
23+
type: string
24+
required: false
2525
git_ref:
2626
description: Git ref to build
2727
type: string
@@ -65,43 +65,13 @@ on:
6565
AC_SIGN_IDENTITY:
6666
description: Apple Connect Signing Identify
6767
required: true
68-
TAP_REPO_TOKEN:
69-
description: Homebrew Tap Token
70-
required: true
7168
outputs:
7269
package_created:
7370
description: "Whether or not a package was created"
7471
value: ${{ jobs.package.result == 'success' }}
7572

7673
jobs:
77-
prepare:
78-
runs-on: ${{ inputs.os }}
79-
outputs:
80-
builder_sha: ${{ steps.builder_sha.outputs.sha }}
81-
emacs_sha_override: ${{ steps.emacs_sha.outputs.sha }}
82-
test_plan_args: ${{ steps.test_plan_args.outputs.args }}
83-
steps:
84-
- name: Download emacs-builder git SHA artifact
85-
uses: actions/download-artifact@v4
86-
with:
87-
name: emacs-builder-git-sha
88-
path: ./
89-
- name: Store builder Git SHA
90-
id: builder_sha
91-
run: >-
92-
echo "sha=$(cat emacs-builder-git-sha.txt)" >> $GITHUB_OUTPUT
93-
- name: Prepare plan test args
94-
id: test_plan_args
95-
if: ${{ inputs.test_build_name != '' }}
96-
run: >-
97-
echo "args=--test-build '${{ inputs.test_build_name }}' --test-release-type '${{ inputs.test_release_type }}'" >> $GITHUB_OUTPUT
98-
- name: Set git SHA override
99-
id: emacs_sha
100-
if: ${{ inputs.git_sha != '' }}
101-
run: >-
102-
echo "sha=--sha '${{ inputs.git_sha }}'" >> $GITHUB_OUTPUT
10374
plan:
104-
needs: [prepare]
10575
runs-on: ${{ inputs.build_os }}
10676
outputs:
10777
check: ${{ steps.check.outputs.result }}
@@ -110,32 +80,37 @@ jobs:
11080
uses: actions/checkout@v4
11181
with:
11282
repository: jimeh/build-emacs-for-macos
113-
ref: ${{ needs.prepare.outputs.builder_sha }}
114-
- uses: actions/setup-go@v5
115-
if: ${{ inputs.os != inputs.build_os }}
116-
with:
117-
go-version: "1.23"
118-
- name: Build emacs-builder tool
119-
if: ${{ inputs.os != inputs.build_os }}
120-
run: make build
83+
ref: ${{ inputs.builder_ref }}
12184
- name: Download pre-built emacs-builder artifact
122-
if: ${{ inputs.os == inputs.build_os }}
12385
uses: actions/download-artifact@v4
12486
with:
125-
name: emacs-builder
87+
name: emacs-builder-${{ runner.arch }}
12688
path: bin
12789
- name: Ensure emacs-builder is executable
128-
if: ${{ inputs.os == inputs.build_os }}
12990
run: chmod +x bin/emacs-builder
130-
- uses: DeterminateSystems/nix-installer-action@main
131-
- uses: DeterminateSystems/magic-nix-cache-action@main
91+
- uses: nixbuild/nix-quick-install-action@v29
92+
- uses: nix-community/cache-nix-action@v5
93+
with:
94+
primary-key: nix-${{ runner.arch }}-${{ hashFiles('**/flake.*') }}
95+
- name: Install dependencies
96+
run: nix develop --command nix flake metadata
97+
- name: Prepare plan test args
98+
id: test_plan_args
99+
if: inputs.test_build_name != ''
100+
run: >-
101+
echo "args=--test-build '${{ inputs.test_build_name }}' --test-release-type '${{ inputs.test_release_type }}'" >> "$GITHUB_OUTPUT"
102+
- name: Set git SHA override
103+
id: emacs_sha
104+
if: inputs.git_sha != ''
105+
run: >-
106+
echo "sha=--sha '${{ inputs.git_sha }}'" >> "$GITHUB_OUTPUT"
132107
- name: Plan build
133108
run: >-
134109
nix develop --command
135110
bin/emacs-builder -l debug plan --output build-plan.yml
136111
--output-dir '${{ github.workspace }}/builds'
137-
${{ needs.prepare.outputs.test_plan_args }}
138-
${{ needs.prepare.outputs.emacs_sha_override }}
112+
${{ steps.test_plan_args.outputs.args }}
113+
${{ steps.emacs_sha.outputs.sha }}
139114
'${{ inputs.git_ref }}'
140115
env:
141116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -151,35 +126,39 @@ jobs:
151126
id: check
152127
continue-on-error: true
153128
run: |
154-
echo "result=$((bin/emacs-builder -l debug release --plan build-plan.yml check && echo 'ok') || echo 'fail')" >> $GITHUB_OUTPUT
129+
echo "result=$((bin/emacs-builder -l debug release --plan build-plan.yml check && echo 'ok') || echo 'fail')" >> "$GITHUB_OUTPUT"
155130
env:
156131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157132
- run: echo 'Planned release already seems to exist.'
158-
if: ${{ steps.check.outputs.result == 'ok' }}
133+
if: steps.check.outputs.result == 'ok'
159134

160135
build:
161136
runs-on: ${{ inputs.build_os }}
162-
needs: [prepare, plan]
137+
needs: [plan]
163138
# Only run if check for existing release and asset failed.
164-
if: ${{ needs.plan.outputs.check == 'fail' }}
139+
if: needs.plan.outputs.check == 'fail'
165140
steps:
166141
- name: Checkout build-emacs-for-macos repo
167142
uses: actions/checkout@v4
168143
with:
169144
repository: jimeh/build-emacs-for-macos
170-
ref: ${{ needs.prepare.outputs.builder_sha }}
145+
ref: ${{ inputs.builder_ref }}
171146
path: builder
172-
- uses: DeterminateSystems/nix-installer-action@main
173-
- uses: DeterminateSystems/magic-nix-cache-action@main
147+
- uses: nixbuild/nix-quick-install-action@v29
148+
- uses: nix-community/cache-nix-action@v5
149+
with:
150+
primary-key: nix-${{ runner.arch }}-${{ hashFiles('**/flake.*') }}
174151
- name: Download build-plan artifact
175152
uses: actions/download-artifact@v4
176153
with:
177154
name: ${{ inputs.artifact_prefix }}build-plan
178155
path: ./builder/
179156
- name: Install dependencies
157+
run: nix develop --command nix flake metadata
158+
working-directory: builder
159+
- name: Install Ruby dependencies
180160
run: >-
181-
nix develop
182-
--command make bootstrap-ruby
161+
nix develop --command make bootstrap-ruby
183162
working-directory: builder
184163
env:
185164
BUNDLE_WITHOUT: "development"
@@ -209,21 +188,21 @@ jobs:
209188

210189
package:
211190
runs-on: ${{ inputs.os }}
212-
needs: [prepare, plan, build]
191+
needs: [plan, build]
213192
steps:
214-
- uses: actions/setup-python@v5
215-
with:
216-
python-version: "3.11"
217-
- name: Install dmgbuild
218-
run: |
219-
$(command -v pip3 || command -v pip) install --upgrade dmgbuild
220193
- name: Download pre-built emacs-builder artifact
221194
uses: actions/download-artifact@v4
222195
with:
223-
name: emacs-builder
196+
name: emacs-builder-${{ runner.arch }}
224197
path: bin
225198
- name: Ensure emacs-builder is executable
226199
run: chmod +x bin/emacs-builder
200+
- uses: actions/setup-python@v5
201+
with:
202+
python-version: "3.11"
203+
- name: Install dmgbuild
204+
run: |
205+
$(command -v pip3 || command -v pip) install --upgrade dmgbuild
227206
- name: Download build-plan artifact
228207
uses: actions/download-artifact@v4
229208
with:
@@ -278,6 +257,6 @@ jobs:
278257
builds/*.sha*
279258
if-no-files-found: error
280259
- name: Clean up keychain used for signing certificate
281-
if: ${{ always() }}
260+
if: always()
282261
run: |
283262
security delete-keychain "$RUNNER_TEMP/app-signing.keychain-db"

.github/workflows/_prepare.yml

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,79 @@ name: _prepare
33
on:
44
workflow_call:
55
inputs:
6-
os:
7-
description: GitHub Actions runner OS
8-
type: string
9-
required: false
10-
default: "macos-12"
116
builder_ref:
127
description: Git ref to checkout of build-emacs-for-macos
138
required: false
149
type: string
15-
default: "v0.6.50"
16-
secrets:
17-
TAP_REPO_TOKEN:
18-
description: Personal Access Token for Homebrew Tap repo
19-
required: true
10+
default: "v0.6.52"
11+
outputs:
12+
builder_sha:
13+
description: Git SHA of build-emacs-for-macos at builder_ref
14+
value: ${{ jobs.builder-sha.outputs.sha }}
2015

2116
jobs:
22-
emacs-builder:
23-
runs-on: ${{ inputs.os }}
17+
builder-sha:
18+
runs-on: "macos-13"
19+
outputs:
20+
sha: ${{ steps.builder_sha.outputs.sha }}
2421
steps:
2522
- name: Checkout build-emacs-for-macos repo
2623
uses: actions/checkout@v4
2724
with:
2825
repository: jimeh/build-emacs-for-macos
2926
ref: ${{ inputs.builder_ref }}
3027
- name: Store builder Git SHA
28+
id: builder_sha
3129
run: |
32-
git rev-parse HEAD > emacs-builder-git-sha.txt
30+
BUILDER_SHA="$(git rev-parse HEAD)"
31+
echo "$BUILDER_SHA" > build-emacs-for-macos-git-sha.txt
32+
echo "sha=$BUILDER_SHA" >> $GITHUB_OUTPUT
33+
echo "Builder ref ${{ inputs.builder_ref }} resolved to" \
34+
"commit SHA: $BUILDER_SHA"
3335
- name: Upload builder git SHA artifact
3436
uses: actions/upload-artifact@v4
3537
with:
36-
name: emacs-builder-git-sha
37-
path: emacs-builder-git-sha.txt
38+
name: build-emacs-for-macos-git-sha
39+
path: build-emacs-for-macos-git-sha.txt
3840
if-no-files-found: error
39-
- uses: actions/setup-go@v5
41+
42+
emacs-builder:
43+
needs: [builder-sha]
44+
strategy:
45+
matrix:
46+
os:
47+
- macos-13 # Only macos-13 and earlier are x86_64.
48+
- macos-14 # Only macos-14 and later are ARM64.
49+
runs-on: ${{ matrix.os }}
50+
steps:
51+
- name: Cache emacs-builder (${{ runner.arch }})
52+
id: cache
53+
uses: actions/cache@v4
54+
with:
55+
path: bin/emacs-builder
56+
key: emacs-builder-${{ runner.arch }}-${{ needs.builder-sha.outputs.sha }}-bin
57+
- name: Checkout build-emacs-for-macos repo
58+
if: steps.cache.outputs.cache-hit != 'true'
59+
uses: actions/checkout@v4
60+
with:
61+
repository: jimeh/build-emacs-for-macos
62+
ref: ${{ inputs.builder_ref }}
63+
fetch-depth: 0
64+
- name: Setup Go
65+
if: steps.cache.outputs.cache-hit != 'true'
66+
uses: actions/setup-go@v5
4067
with:
4168
go-version: "1.23"
4269
- name: Build emacs-builder tool
70+
if: steps.cache.outputs.cache-hit != 'true'
4371
run: make build
72+
- name: Ensure emacs-builder is executable
73+
if: steps.cache.outputs.cache-hit != 'true'
74+
run: chmod +x bin/emacs-builder
75+
- run: bin/emacs-builder --version
4476
- name: Upload emacs-builder artifact
4577
uses: actions/upload-artifact@v4
4678
with:
47-
name: emacs-builder
79+
name: emacs-builder-${{ runner.arch }}
4880
path: bin/emacs-builder
4981
if-no-files-found: error

.github/workflows/_release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ concurrency:
77
on:
88
workflow_call:
99
inputs:
10+
builder_ref:
11+
description: Git ref of build-emacs-for-macos to use
12+
type: string
13+
required: true
1014
os:
1115
description: GitHub Actions runner OS
1216
type: string
@@ -20,10 +24,6 @@ on:
2024
description: Name of artifact containing a *.dmg files to release
2125
type: string
2226
required: true
23-
secrets:
24-
TAP_REPO_TOKEN:
25-
description: Personal Access Token for Homebrew Tap repo
26-
required: true
2727

2828
jobs:
2929
github:
@@ -32,7 +32,7 @@ jobs:
3232
- name: Download pre-built emacs-builder artifact
3333
uses: actions/download-artifact@v4
3434
with:
35-
name: emacs-builder
35+
name: emacs-builder-${{ runner.arch }}
3636
path: bin
3737
- name: Ensure emacs-builder is executable
3838
run: chmod +x bin/emacs-builder
@@ -49,11 +49,11 @@ jobs:
4949
name: ${{ inputs.dmg_artifact }}
5050
path: builds
5151
- name: Publish disk images to a GitHub Release
52-
if: ${{ steps.dmg.outputs.result != 'fail' }}
52+
if: steps.dmg.outputs.result != 'fail'
5353
run: >-
5454
bin/emacs-builder -l debug release --plan build-plan.yml publish
5555
$(find builds -name '*.dmg' -or -name '*.sha256')
5656
env:
5757
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5858
- run: echo 'No DMG artifact available, was there a new commit to build?'
59-
if: ${{ steps.dmg.outputs.result == 'fail' }}
59+
if: steps.dmg.outputs.result == 'fail'

0 commit comments

Comments
 (0)