Skip to content

Manual Cross Platform Release #8

Manual Cross Platform Release

Manual Cross Platform Release #8

name: Manual Cross Platform Release
on:
workflow_dispatch:
inputs:
publish:
description: Publish artifacts to GitHub release
required: true
default: true
type: boolean
jobs:
build:
name: Build ${{ matrix.platform }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: win
build_command: npx electron-builder --win --x64 --publish never
- os: macos-latest
platform: mac
build_command: npx electron-builder --mac --publish never
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build Electron main process
run: npm run electron:build-main
- name: Build renderer assets
run: npm run build
- name: Build release packages
env:
CSC_IDENTITY_AUTO_DISCOVERY: "false"
run: ${{ matrix.build_command }}
shell: bash
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.platform }}
path: |
release/*.exe
release/*.dmg
release/*.zip
release/*.yml
release/*.yaml
release/*.blockmap
if-no-files-found: error
publish:
if: ${{ inputs.publish }}
name: Publish GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Prepare release metadata
id: meta
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="v${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
- name: Create or update release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ steps.meta.outputs.tag }}"
TITLE="Release ${TAG}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists; uploading artifacts."
else
gh release create "$TAG" --title "$TITLE" --notes "Manual cross-platform build artifacts."
fi
while IFS= read -r -d '' file; do
echo "Uploading $(basename "$file")"
gh release upload "$TAG" "$file" --clobber
done < <(
find release-artifacts -type f \
\( -name '*.exe' -o -name '*.dmg' -o -name '*.zip' -o -name '*.yml' -o -name '*.yaml' -o -name '*.blockmap' \) \
-print0
)