Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(release): mac_only dispatch adds the Mac app to an existing release

purple31b110ddde80
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7082a4dd..b9d6f7ef 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -30,6 +30,11 @@ on:
type: boolean
required: false
default: false
+ mac_only:
+ description: 'Mac only, for a release that already has its Windows and Linux files: build, sign, notarize and attach the Mac app to the release of the tag above, and add darwin-aarch64 to its latest.json. The gate, Windows and Linux are not run again and their files are not touched. The Mac lane has to be switched on for releases.'
+ type: boolean
+ required: false
+ default: false
permissions:
contents: write
@@ -179,7 +184,7 @@ jobs:
# Skipped in either dry run. In a Mac dry run build-tauri is skipped with
# it; in a full dry run build-tauri goes ahead without it (see there).
# `inputs` is empty on the `release` trigger, so this is true there.
- if: ${{ !inputs.mac_dry_run && !inputs.dry_run }}
+ if: ${{ !inputs.mac_dry_run && !inputs.dry_run && !inputs.mac_only }}
uses: ./.github/workflows/ci.yml
with:
ref: ${{ github.event.release.tag_name || github.event.inputs.tag }}
@@ -1238,7 +1243,11 @@ jobs:
# scripts/macos-release-signing.sh that need no private key.
build-tauri-macos:
needs: build-tauri
- if: ${{ !cancelled() && (inputs.mac_dry_run || (inputs.dry_run && inputs.dry_run_mac) || (!inputs.dry_run && vars.LU_MAC_RELEASE == '1' && needs.build-tauri.result == 'success')) }}
+ # mac_only is the fourth way in: a release whose Windows and Linux files
+ # are attached and checked already (the step after the secret check
+ # proves that), and whose Mac half failed. build-tauri is skipped then,
+ # not green, because the gate is not run again for a tag it passed.
+ if: ${{ !cancelled() && (inputs.mac_dry_run || (inputs.dry_run && inputs.dry_run_mac) || (!inputs.dry_run && vars.LU_MAC_RELEASE == '1' && (needs.build-tauri.result == 'success' || (inputs.mac_only && needs.build-tauri.result == 'skipped')))) }}
# macos-15 is an Apple Silicon image (arm64). macos-14 is deprecated and
# macos-latest moves; a pinned label keeps the toolchain a decision.
runs-on: macos-15
@@ -1247,6 +1256,8 @@ jobs:
# Dry run or release, for every step of this job (see "DRY RUN" above).
# `inputs` is empty on the `release` trigger, which makes this 'false'.
MAC_DRY_RUN: ${{ (inputs.mac_dry_run || (inputs.dry_run && inputs.dry_run_mac)) && 'true' || 'false' }}
+ # 'true' only for a Mac-only run on an existing release (input mac_only).
+ MAC_ONLY: ${{ inputs.mac_only && 'true' || 'false' }}
# The oldest macOS LU supports (VOICE.md, bundle.macOS
# .minimumSystemVersion in tauri.macos.conf.json). Without it cmake
# stamps the llama-server sidecar with the RUNNER's OS version as its
@@ -1333,6 +1344,38 @@ jobs:
echo "OK: the six Apple secrets and the updater key are set, the runner is arm64."
fi
+ # A Mac-only run adds to a release, it does not make one. The release
+ # has to exist, be published, and carry the Windows and Linux files and
+ # a latest.json of its own version, or there is nothing to add to: the
+ # gate that would otherwise judge the tag is not run in this mode. Read
+ # through the public API, without a token (no step before the upload
+ # holds one).
+ - name: "Mac only: the release is there, with its Windows and Linux files"
+ if: ${{ env.MAC_ONLY == 'true' && env.MAC_DRY_RUN != 'true' }}
+ shell: bash
+ timeout-minutes: 5
+ run: |
+ set -euo pipefail
+ rel="$RUNNER_TEMP/release.json"
+ curl -fsSL --retry 3 "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$RELEASE_TAG" -o "$rel" \
+ || { echo "::error::no published release for $RELEASE_TAG; mac_only adds to an existing release" >&2; exit 1; }
+ node - "$rel" "$RELEASE_TAG" <<'JS'
+ const fs = require('fs')
+ const [file, tag] = process.argv.slice(2)
+ const rel = JSON.parse(fs.readFileSync(file, 'utf8'))
+ const names = (rel.assets || []).map((a) => a.name)
+ const fail = (m) => { console.error('::error::' + m); process.exit(1) }
+ if (rel.draft) fail(tag + ' is a draft')
+ for (const [what, re] of [['the Windows installer', /_x64-setup\.exe$/], ['the AppImage', /_amd64\.AppImage$/], ['latest.json', /^latest\.json$/]]) {
+ if (!names.some((n) => re.test(n))) fail(tag + ' has no ' + what + '; run the whole release, not mac_only')
+ }
+ if (names.some((n) => /_aarch64\.dmg$/.test(n))) console.log('::warning::' + tag + ' already has a disk image; this run replaces the Mac files')
+ console.log('OK: ' + tag + ' is published with ' + names.length + ' files; the Mac app is added to it.')
+ JS
+ json="$RUNNER_TEMP/latest.json"
+ curl -fsSL --retry 3 "https://github.com/$GITHUB_REPOSITORY/releases/download/$RELEASE_TAG/latest.json" -o "$json"
+ node -e 'const d=JSON.parse(require("fs").readFileSync(process.argv[1],"utf8"));const want=process.argv[2].replace(/^v/,"");if(d.version!==want){console.error("::error::latest.json of "+process.argv[2]+" says version "+d.version);process.exit(1)}console.log("OK: latest.json is version "+d.version+" with "+Object.keys(d.platforms||{}).join(", "))' "$json" "$RELEASE_TAG"
+
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
@@ -1941,7 +1984,7 @@ jobs:
# the files (--clobber).
sbom-and-checksums:
needs: [build-tauri, build-tauri-macos]
- if: ${{ always() && !inputs.mac_dry_run && !inputs.dry_run && needs.build-tauri.result == 'success' }}
+ if: ${{ always() && !inputs.mac_dry_run && !inputs.dry_run && (needs.build-tauri.result == 'success' || (inputs.mac_only && needs.build-tauri-macos.result == 'success')) }}
runs-on: ubuntu-22.04
timeout-minutes: 30
env:
diff --git a/src/lib/__tests__/mac-release-lane.test.ts b/src/lib/__tests__/mac-release-lane.test.ts
index e3096268..9a699429 100644
--- a/src/lib/__tests__/mac-release-lane.test.ts
+++ b/src/lib/__tests__/mac-release-lane.test.ts
@@ -107,6 +107,7 @@ const DRY = "${{ env.MAC_DRY_RUN == 'true' }}"
const NOT_DRY = "${{ env.MAC_DRY_RUN != 'true' }}"
/** What only the full dry run adds to this job. */
const FULL_DRY = '${{ inputs.dry_run }}'
+const MAC_ONLY = "${{ env.MAC_ONLY == 'true' && env.MAC_DRY_RUN != 'true' }}"
const lane = withoutComments(jobBlock(RELEASE_YML, 'build-tauri-macos'))
const gate = withoutComments(jobBlock(CI_YML, 'macos-gate'))
@@ -139,14 +140,15 @@ describe('release.yml, the Mac lane can be skipped as a whole', () => {
})
it('is switched by a repository variable in the job condition', () => {
- // Three ways in, and only three: the Mac dry run, a full dry run that
- // asks for the Mac, or a release with the switch on whose Windows and
- // Linux build is green. `!cancelled()` replaces the implicit `success()`,
+ // Four ways in, and only four: the Mac dry run, a full dry run that
+ // asks for the Mac, a release with the switch on whose Windows and
+ // Linux build is green, or, with the switch on, a Mac-only run for a
+ // release that has its Windows and Linux files already. `!cancelled()` replaces the implicit `success()`,
// so the release branch has to ask for the green build-tauri itself, and
// it has to rule the full dry run out: build-tauri is green there too.
const condition = lane.match(/^ {4}if:\s*(.*?)\s*$/m)?.[1] ?? ''
expect(condition).toBe(
- "${{ !cancelled() && (inputs.mac_dry_run || (inputs.dry_run && inputs.dry_run_mac) || (!inputs.dry_run && vars.LU_MAC_RELEASE == '1' && needs.build-tauri.result == 'success')) }}",
+ "${{ !cancelled() && (inputs.mac_dry_run || (inputs.dry_run && inputs.dry_run_mac) || (!inputs.dry_run && vars.LU_MAC_RELEASE == '1' && (needs.build-tauri.result == 'success' || (inputs.mac_only && needs.build-tauri.result == 'skipped')))) }}",
)
// `secrets` is not available in a job level `if:`; a condition that names
// one is always false or a syntax error, depending on the day.
@@ -455,7 +457,7 @@ describe('release.yml, a Mac dry run reaches no release and no other platform',
it('skips the gate, and with it the Windows and Linux build', () => {
const gateJob = withoutComments(jobBlock(RELEASE_YML, 'gate'))
- expect(gateJob).toMatch(/^ {4}if:\s*\$\{\{ !inputs\.mac_dry_run && !inputs\.dry_run \}\}\s*$/m)
+ expect(gateJob).toMatch(/^ {4}if:\s*\$\{\{ !inputs\.mac_dry_run && !inputs\.dry_run && !inputs\.mac_only \}\}\s*$/m)
// build-tauri needs the gate and nothing else, and the one condition
// that lets it build past a skipped gate asks for `dry_run`, which a Mac
// dry run does not carry. release-dry-run.test.ts holds the whole line.
@@ -476,7 +478,7 @@ describe('release.yml, a Mac dry run reaches no release and no other platform',
it('attaches the SBOMs and checksums only to a real release', () => {
expect(withoutComments(jobBlock(RELEASE_YML, 'sbom-and-checksums')))
- .toMatch(/^ {4}if:\s*\$\{\{ always\(\) && !inputs\.mac_dry_run && !inputs\.dry_run && needs\.build-tauri\.result == 'success' \}\}\s*$/m)
+ .toMatch(/^ {4}if:\s*\$\{\{ always\(\) && !inputs\.mac_dry_run && !inputs\.dry_run && \(needs\.build-tauri\.result == 'success' \|\| \(inputs\.mac_only && needs\.build-tauri-macos\.result == 'success'\)\) \}\}\s*$/m)
})
it('has no job besides these six, so none is left unaccounted for', () => {
@@ -514,10 +516,63 @@ describe('release.yml, a Mac dry run reaches no release and no other platform',
it('runs every build and judgement step in both modes', () => {
// The dry run adds its key, its marker and its artifact and leaves out
// the two release steps. The full dry run adds two more, for the updater
- // of the build. Everything else is the same code path in a dry run and
- // in a release, which is the point.
+ // of the build, and a Mac-only run one, which checks the release it adds
+ // to. Everything else is the same code path in a dry run and in a
+ // release, which is the point.
const conditional = laneSteps.filter((s) => stepIf(s) !== '').map(stepIf)
- expect(conditional.sort()).toEqual(['always()', DRY, DRY, DRY, NOT_DRY, NOT_DRY, FULL_DRY, FULL_DRY].sort())
+ expect(conditional.sort()).toEqual(
+ ['always()', DRY, DRY, DRY, NOT_DRY, NOT_DRY, FULL_DRY, FULL_DRY, MAC_ONLY].sort(),
+ )
+ })
+})
+
+describe('release.yml, a Mac-only run adds to an existing release and touches nothing else', () => {
+ const dispatch = RELEASE_YML.slice(RELEASE_YML.indexOf(' workflow_dispatch:'), RELEASE_YML.indexOf('\npermissions:'))
+ const check = stepIndex(laneSteps, (s) => stepIf(s) === MAC_ONLY)
+ const checkout = stepIndex(laneSteps, (s) => s.includes('name: Checkout repository'))
+ const upload = stepIndex(laneSteps, isUpload)
+
+ it('is a boolean input that is off unless someone ticks it', () => {
+ const input = dispatch.slice(dispatch.indexOf(' mac_only:'))
+ expect(input).toMatch(/^ {8}type:\s*boolean\s*$/m)
+ expect(input).toMatch(/^ {8}default:\s*false\s*$/m)
+ expect(input).toMatch(/^ {8}required:\s*false\s*$/m)
+ })
+
+ it('runs neither the gate nor the Windows and Linux build', () => {
+ // build-tauri builds only past a green gate, or past a skipped one in a
+ // full dry run; a Mac-only run is neither, so build-tauri is skipped.
+ expect(withoutComments(jobBlock(RELEASE_YML, 'gate'))).toContain('!inputs.mac_only')
+ const condition = withoutComments(jobBlock(RELEASE_YML, 'build-tauri')).match(/^ {4}if:\s*(.*?)\s*$/m)?.[1] ?? ''
+ expect(condition).toBe(
+ "${{ !cancelled() && (needs.gate.result == 'success' || (inputs.dry_run && needs.gate.result == 'skipped')) }}",
+ )
+ })
+
+ it('first proves the release is there, with its files, and holds no token for it', () => {
+ expect(check).toBeGreaterThan(0)
+ expect(check).toBeLessThan(checkout)
+ const step = laneSteps[check]
+ expect(step).toContain('releases/tags/$RELEASE_TAG')
+ expect(step).toContain('_x64-setup')
+ expect(step).toContain('AppImage')
+ expect(step).toContain('latest.json')
+ expect(step).toMatch(/rel\.draft/)
+ expect(step).not.toMatch(/GITHUB_TOKEN|GH_TOKEN|secrets\./)
+ expect(step).not.toMatch(/\|\|\s*true/)
+ })
+
+ it('attaches through the one upload step, which proves darwin and the other platforms in latest.json', () => {
+ // No upload of its own: the Mac-only run uses the release path of the lane.
+ expect(laneSteps.filter(isUpload)).toHaveLength(1)
+ expect(laneSteps[upload + 1]).toContain('kept the other platforms')
+ })
+
+ it('leaves the Latest flag alone and rebuilds the checksums', () => {
+ // enforce-prerelease reads PUBLISHED_TAG, which a dispatch does not set.
+ expect(withoutComments(jobBlock(RELEASE_YML, 'enforce-prerelease'))).toContain('PUBLISHED_TAG: ${{ github.event.release.tag_name }}')
+ expect(withoutComments(jobBlock(RELEASE_YML, 'sbom-and-checksums')))
+ .toContain("inputs.mac_only && needs.build-tauri-macos.result == 'success'")
})
})
diff --git a/src/lib/__tests__/release-dry-run.test.ts b/src/lib/__tests__/release-dry-run.test.ts
index 555a3aae..26a8457a 100644
--- a/src/lib/__tests__/release-dry-run.test.ts
+++ b/src/lib/__tests__/release-dry-run.test.ts
@@ -95,7 +95,7 @@ describe('release.yml, the dry run inputs', () => {
describe('release.yml, which jobs a full dry run starts', () => {
it('skips the gate', () => {
- expect(jobIf('gate')).toBe('${{ !inputs.mac_dry_run && !inputs.dry_run }}')
+ expect(jobIf('gate')).toBe('${{ !inputs.mac_dry_run && !inputs.dry_run && !inputs.mac_only }}')
})
it('builds past the skipped gate, and a release still only after a green one', () => {