Skip to content

Commit 305a4ee

Browse files
committed
git ci workflows
1 parent 7c7809b commit 305a4ee

File tree

5 files changed

+432
-0
lines changed

5 files changed

+432
-0
lines changed

.github/workflows/_build.yml

+211
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
# Requires _prepare.yml re-usable workflow to have run.
3+
name: _build
4+
on:
5+
workflow_call:
6+
inputs:
7+
artifact_prefix:
8+
description: Artifact prefix
9+
type: string
10+
required: false
11+
os:
12+
description: GitHub Actions runner OS
13+
type: string
14+
required: true
15+
git_ref:
16+
description: Git ref to build
17+
type: string
18+
required: true
19+
git_sha:
20+
description: Override git SHA to build
21+
type: string
22+
required: false
23+
build_args:
24+
description: Custom arguments passed to build script
25+
type: string
26+
required: false
27+
test_build_name:
28+
description: "Test build name"
29+
type: string
30+
required: false
31+
test_release_type:
32+
description: "prerelease or draft"
33+
type: string
34+
required: false
35+
default: "prerelease"
36+
secrets:
37+
APPLE_DEVELOPER_CERTIFICATE_P12_BASE64:
38+
description: Base64 encoded Apple Developer Certificate
39+
required: true
40+
APPLE_DEVELOPER_CERTIFICATE_PASSWORD:
41+
description: Password for Apple Developer Certificate
42+
required: true
43+
KEYCHAIN_PASSWORD:
44+
description: Password to use for temporary local keychain on runner
45+
required: true
46+
AC_USERNAME:
47+
description: Apple Connect Username
48+
required: true
49+
AC_PASSWORD:
50+
description: Apple Connect Password
51+
required: true
52+
AC_PROVIDER:
53+
description: Apple Connect Provider
54+
required: true
55+
AC_SIGN_IDENTITY:
56+
description: Apple Connect Signing Identify
57+
required: true
58+
TAP_REPO_TOKEN:
59+
description: Homebrew Tap Token
60+
required: true
61+
62+
jobs:
63+
prepare:
64+
runs-on: ${{ inputs.os }}
65+
outputs:
66+
builder_sha: ${{ steps.builder_sha.outputs.sha }}
67+
emacs_sha_override: ${{ steps.emacs_sha.outputs.sha }}
68+
test_plan_args: ${{ steps.test_plan_args.outputs.args }}
69+
steps:
70+
- name: Download emacs-builder git SHA artifact
71+
uses: actions/download-artifact@v3
72+
with:
73+
name: emacs-builder-git-sha
74+
path: ./
75+
- name: Store builder Git SHA
76+
id: builder_sha
77+
run: >-
78+
echo "sha=$(cat emacs-builder-git-sha.txt)" >> $GITHUB_OUTPUT
79+
- name: Prepare plan test args
80+
id: test_plan_args
81+
if: ${{ inputs.test_build_name != '' }}
82+
run: >-
83+
echo "args=--test-build '${{ inputs.test_build_name }}' --test-release-type '${{ inputs.test_release_type }}'" >> $GITHUB_OUTPUT
84+
- name: Set git SHA override
85+
id: emacs_sha
86+
if: ${{ inputs.git_sha != '' }}
87+
run: >-
88+
echo "sha=--sha '${{ inputs.git_sha }}'" >> $GITHUB_OUTPUT
89+
plan:
90+
needs: [prepare]
91+
runs-on: ${{ inputs.os }}
92+
outputs:
93+
check: ${{ steps.check.outputs.result }}
94+
steps:
95+
- name: Download pre-built emacs-builder artifact
96+
uses: actions/download-artifact@v3
97+
with:
98+
name: emacs-builder
99+
path: bin
100+
- name: Ensure emacs-builder is executable
101+
run: chmod +x bin/emacs-builder
102+
- name: Plan build
103+
run: >-
104+
bin/emacs-builder -l debug plan --output build-plan.yml
105+
--output-dir '${{ github.workspace }}/builds'
106+
${{ needs.prepare.outputs.test_plan_args }}
107+
${{ needs.prepare.outputs.emacs_sha_override }}
108+
'${{ inputs.git_ref }}'
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
- name: Show plan
112+
run: cat build-plan.yml
113+
- name: Upload build-plan artifact
114+
uses: actions/upload-artifact@v3
115+
with:
116+
name: ${{ inputs.artifact_prefix }}build-plan
117+
path: build-plan.yml
118+
if-no-files-found: error
119+
- name: Check if planned release and asset already exist
120+
id: check
121+
continue-on-error: true
122+
run: |
123+
echo "result=$((bin/emacs-builder -l debug release --plan build-plan.yml check && echo 'ok') || echo 'fail')" >> $GITHUB_OUTPUT
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
- run: echo 'Planned release already seems to exist.'
127+
if: ${{ steps.check.outputs.result == 'fail' }}
128+
129+
build:
130+
runs-on: ${{ inputs.os }}
131+
needs: [prepare, plan]
132+
# Only run if check for existing release and asset failed.
133+
if: ${{ needs.plan.outputs.check == 'fail' }}
134+
steps:
135+
- name: Checkout build-emacs-wr-for-macos repo
136+
uses: actions/checkout@v2
137+
with:
138+
repository: declantsien/build-emacs-wr-for-macos
139+
ref: ${{ needs.prepare.outputs.builder_sha }}
140+
path: builder
141+
- uses: ruby/setup-ruby@v1
142+
with:
143+
ruby-version: 2.7
144+
- name: Update homebrew
145+
run: brew update
146+
- name: Install dependencies
147+
run: make bootstrap-ci
148+
working-directory: builder
149+
- name: Download build-plan artifact
150+
uses: actions/download-artifact@v3
151+
with:
152+
name: ${{ inputs.artifact_prefix }}build-plan
153+
path: ./
154+
- name: Build Emacs
155+
run: >-
156+
./builder/build-emacs-for-macos --plan build-plan.yml
157+
--native-full-aot
158+
${{ inputs.build_args }}
159+
env:
160+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
161+
- name: Upload unsigned app artifact
162+
uses: actions/upload-artifact@v3
163+
with:
164+
name: ${{ inputs.artifact_prefix }}unsigned-app
165+
path: builds/*.tbz
166+
if-no-files-found: error
167+
- name: Upload Emacs source artifact
168+
uses: actions/upload-artifact@v3
169+
with:
170+
name: ${{ inputs.artifact_prefix }}emacs-source
171+
path: builder/tarballs/*.tgz
172+
173+
package:
174+
runs-on: ${{ inputs.os }}
175+
needs: [prepare, plan, build]
176+
# Only run if check for existing release and asset failed.
177+
steps:
178+
- uses: actions/setup-python@v4
179+
with:
180+
python-version: "3.11"
181+
- name: Install dmgbuild
182+
run: |
183+
$(command -v pip3 || command -v pip) install --upgrade dmgbuild
184+
- name: Download pre-built emacs-builder artifact
185+
uses: actions/download-artifact@v3
186+
with:
187+
name: emacs-builder
188+
path: bin
189+
- name: Ensure emacs-builder is executable
190+
run: chmod +x bin/emacs-builder
191+
- name: Download build-plan artifact
192+
uses: actions/download-artifact@v3
193+
with:
194+
name: ${{ inputs.artifact_prefix }}build-plan
195+
path: ./
196+
- name: Download unsigned app artifact
197+
uses: actions/download-artifact@v3
198+
with:
199+
name: ${{ inputs.artifact_prefix }}unsigned-app
200+
path: builds
201+
- name: Extract unsigned app archive
202+
run: |
203+
find * -name '*.tbz' -exec tar xvjf "{}" \;
204+
working-directory: builds
205+
- name: Upload disk image artifacts
206+
uses: actions/upload-artifact@v3
207+
with:
208+
name: tbz
209+
path: |
210+
builds/*.tbz
211+
if-no-files-found: error

.github/workflows/_prepare.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: _prepare
3+
on:
4+
workflow_call:
5+
inputs:
6+
builder_ref:
7+
description: Git ref to checkout of build-emacs-for-macos
8+
required: false
9+
type: string
10+
default: "master"
11+
secrets:
12+
TAP_REPO_TOKEN:
13+
description: Personal Access Token for Homebrew Tap repo
14+
required: true
15+
16+
jobs:
17+
emacs-builder:
18+
# Use oldest version of macOS to ensure emacs-bulder binary is compatible
19+
# with later versions of macOS.
20+
runs-on: macos-11
21+
steps:
22+
- name: Checkout build-emacs-for-macos repo
23+
uses: actions/checkout@v3
24+
with:
25+
repository: declantsien/build-emacs-wr-for-macos
26+
ref: ${{ inputs.builder_ref }}
27+
path: builder
28+
- name: Store builder Git SHA
29+
run: |
30+
git rev-parse HEAD > emacs-builder-git-sha.txt
31+
working-directory: builder
32+
- name: Upload builder git SHA artifact
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: emacs-builder-git-sha
36+
path: builder/emacs-builder-git-sha.txt
37+
if-no-files-found: error
38+
- uses: actions/setup-go@v2
39+
with:
40+
go-version: 1.16
41+
- uses: actions/cache@v3
42+
with:
43+
path: ~/go/pkg/mod
44+
key: ${{ runner.os }}-go-${{ hashFiles('builder/**/go.sum') }}
45+
restore-keys: ${{ runner.os }}-go-
46+
- name: Build emacs-builder tool
47+
run: make build
48+
working-directory: builder
49+
- name: Upload emacs-builder artifact
50+
uses: actions/upload-artifact@v3
51+
with:
52+
name: emacs-builder
53+
path: builder/bin/emacs-builder
54+
if-no-files-found: error

.github/workflows/_release.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
# Requires _prepare.yml and _build.yml re-usable workflows to have run.
3+
name: _release
4+
on:
5+
workflow_call:
6+
inputs:
7+
plan_artifact:
8+
description: Name of artifact containing a emacs-builder plan yaml file
9+
type: string
10+
required: true
11+
tbz_artifact:
12+
description: Name of artifact containing a *.dmg files to release
13+
type: string
14+
required: true
15+
secrets:
16+
TAP_REPO_TOKEN:
17+
description: Personal Access Token for Homebrew Tap repo
18+
required: true
19+
20+
jobs:
21+
github:
22+
runs-on: macos-11
23+
steps:
24+
- name: Download pre-built emacs-builder artifact
25+
uses: actions/download-artifact@v3
26+
with:
27+
name: emacs-builder
28+
path: bin
29+
- name: Ensure emacs-builder is executable
30+
run: chmod +x bin/emacs-builder
31+
- name: Download build-plan.yml artifact
32+
uses: actions/download-artifact@v3
33+
with:
34+
name: ${{ inputs.plan_artifact }}
35+
path: ./
36+
- name: Download disk image artifacts
37+
id: dmg
38+
continue-on-error: true
39+
uses: actions/download-artifact@v3
40+
with:
41+
name: ${{ inputs.tbz_artifact }}
42+
path: builds
43+
- name: Publish tbz archive to a GitHub Release
44+
if: ${{ steps.dmg.outputs.result != 'fail' }}
45+
run: >-
46+
bin/emacs-builder -l debug release --plan build-plan.yml publish
47+
$(find builds -name '*.tbz')
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
name: Build
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
git_ref:
7+
description: Emacs git ref to build
8+
required: true
9+
default: "master"
10+
git_sha:
11+
description: Override Emacs git commit SHA to build
12+
required: false
13+
builder_ref:
14+
description: "Git ref to checkout of build-emacs-for-macos"
15+
required: true
16+
default: "master"
17+
builder_args:
18+
description: Custom arguments passed to build script
19+
required: false
20+
default: ""
21+
os:
22+
description: 'Runner OS ("macos-11", "macos-12", or "macos-latest")'
23+
required: true
24+
default: "macos-11"
25+
test_build_name:
26+
description: "Test build name"
27+
required: false
28+
default: ""
29+
test_release_type:
30+
description: "prerelease or draft"
31+
required: false
32+
default: ""
33+
34+
jobs:
35+
prepare:
36+
name: Prepare
37+
uses: ./.github/workflows/_prepare.yml
38+
with:
39+
builder_ref: ${{ github.event.inputs.builder_ref }}
40+
secrets:
41+
TAP_REPO_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}
42+
43+
build:
44+
name: Build
45+
needs: [prepare]
46+
uses: ./.github/workflows/_build.yml
47+
with:
48+
os: ${{ github.event.inputs.os }}
49+
git_ref: ${{ github.event.inputs.git_ref }}
50+
git_sha: ${{ github.event.inputs.git_sha }}
51+
build_args: ${{ github.event.inputs.builder_args }}
52+
test_build_name: ${{ github.event.inputs.test_build_name }}
53+
test_release_type: ${{ github.event.inputs.test_release_type }}
54+
secrets:
55+
APPLE_DEVELOPER_CERTIFICATE_P12_BASE64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
56+
APPLE_DEVELOPER_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
57+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
58+
AC_USERNAME: ${{ secrets.AC_USERNAME }}
59+
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
60+
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
61+
AC_SIGN_IDENTITY: ${{ secrets.AC_SIGN_IDENTITY }}
62+
TAP_REPO_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}
63+
64+
release:
65+
name: Release
66+
needs: [build]
67+
uses: ./.github/workflows/_release.yml
68+
with:
69+
plan_artifact: build-plan
70+
tbz_artifact: tbz
71+
secrets:
72+
TAP_REPO_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}

0 commit comments

Comments
 (0)