feat(build): allow running build job on separate OS

This should help reduce costs for Apple Silicon builds, as they are not
available on any form of free tier of GitHub Actions at the moment.

The build step that actually runs Emacs' configure script, and compiles
Emacs, is the only step that actually needs to run on the target
hardware architecture. The rest should be architecture agnostic.
This commit is contained in:
2023-11-19 00:05:04 +00:00
parent e65fc8f4f0
commit ff1b573f43
4 changed files with 34 additions and 5 deletions

View File

@@ -11,7 +11,13 @@ on:
os:
description: GitHub Actions runner OS
type: string
required: true
required: false
default: "macos-11"
build_os:
description: Target OS to build for
type: string
required: false
default: "macos-11"
git_ref:
description: Git ref to build
type: string
@@ -88,16 +94,31 @@ jobs:
echo "sha=--sha '${{ inputs.git_sha }}'" >> $GITHUB_OUTPUT
plan:
needs: [prepare]
runs-on: ${{ inputs.os }}
runs-on: ${{ inputs.build_os }}
outputs:
check: ${{ steps.check.outputs.result }}
steps:
- name: Checkout build-emacs-for-macos repo
if: ${{ inputs.os != inputs.build_os }}
uses: actions/checkout@v4
with:
repository: jimeh/build-emacs-for-macos
ref: ${{ needs.prepare.outputs.builder_sha }}
- uses: actions/setup-go@v4
if: ${{ inputs.os != inputs.build_os }}
with:
go-version: "1.21"
- name: Build emacs-builder tool
if: ${{ inputs.os != inputs.build_os }}
run: make build
- name: Download pre-built emacs-builder artifact
if: ${{ inputs.os == inputs.build_os }}
uses: actions/download-artifact@v3
with:
name: emacs-builder
path: bin
- name: Ensure emacs-builder is executable
if: ${{ inputs.os == inputs.build_os }}
run: chmod +x bin/emacs-builder
- name: Plan build
run: >-
@@ -127,7 +148,7 @@ jobs:
if: ${{ steps.check.outputs.result == 'fail' }}
build:
runs-on: ${{ inputs.os }}
runs-on: ${{ inputs.build_os }}
needs: [prepare, plan]
# Only run if check for existing release and asset failed.
if: ${{ needs.plan.outputs.check == 'fail' }}
@@ -162,6 +183,7 @@ jobs:
--log-level debug
--plan build-plan.yml
--native-full-aot
--no-self-sign
${{ inputs.build_args }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -6,7 +6,8 @@ on:
os:
description: GitHub Actions runner OS
type: string
required: true
required: false
default: "macos-11"
builder_ref:
description: Git ref to checkout of build-emacs-for-macos
required: false

View File

@@ -7,7 +7,8 @@ on:
os:
description: GitHub Actions runner OS
type: string
required: true
required: false
default: "macos-11"
plan_artifact:
description: Name of artifact containing a emacs-builder plan yaml file
type: string

View File

@@ -22,6 +22,10 @@ on:
description: 'Runner OS ("macos-11", "macos-12", or "macos-latest")'
required: true
default: "macos-11"
build_os:
description: "Build OS used to build Emacs"
required: false
default: "macos-11"
test_build_name:
description: "Test build name"
required: false
@@ -47,6 +51,7 @@ jobs:
uses: ./.github/workflows/_build.yml
with:
os: ${{ github.event.inputs.os }}
build_os: ${{ github.event.inputs.build_os }}
git_ref: ${{ github.event.inputs.git_ref }}
git_sha: ${{ github.event.inputs.git_sha }}
build_args: ${{ github.event.inputs.builder_args }}