yao/.github/workflows/release-macos.yml
Max ac8cdaeda9 refactor(workflows): remove license root certificate injection from build process
- Eliminated the steps for injecting commercial license root certificates from GitHub Secrets in both Linux and macOS workflows, streamlining the build process.
- Updated the `inspect` command to load commercial license information directly, enhancing the application's licensing capabilities without relying on external secrets during the build.
2026-03-27 15:46:01 +08:00

219 lines
6.8 KiB
YAML

name: Release macOS
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
# ===================================================================
# Build Yao macOS binaries (arm64 + amd64) — one job, both arches
# ===================================================================
build:
runs-on: macos-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install pnpm
run: npm install -g pnpm
- name: Setup Cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout Kun
uses: actions/checkout@v4
with:
repository: yaoapp/kun
path: kun
- name: Checkout Xun
uses: actions/checkout@v4
with:
repository: yaoapp/xun
path: xun
- name: Checkout Gou
uses: actions/checkout@v4
with:
repository: yaoapp/gou
path: gou
- name: Checkout V8Go
uses: actions/checkout@v4
with:
repository: yaoapp/v8go
path: v8go
- name: Unzip libv8
run: |
files=$(find ./v8go -name "libv8*.zip")
for file in $files; do
dir=$(dirname "$file")
echo "Extracting $file to directory $dir"
unzip -o -d $dir $file
rm -rf $dir/__MACOSX
done
- name: Checkout CUI v1.0
uses: actions/checkout@v4
with:
repository: yaoapp/cui
path: cui-v1.0
- name: Checkout Yao-Init
uses: actions/checkout@v4
with:
repository: yaoapp/yao-init
path: yao-init
- name: Move Dependencies
run: |
mv kun ../
mv xun ../
mv gou ../
mv v8go ../
mv cui-v1.0 ../
mv yao-init ../
rm -f ../cui-v1.0/packages/setup/vite.config.ts.*
- name: Checkout Yao
uses: actions/checkout@v4
- name: Set Version from Tag
run: |
if [[ "$GITHUB_REF" != refs/tags/v* ]]; then
echo "::error::This workflow requires a tag (refs/tags/v*). Got: $GITHUB_REF"
exit 1
fi
TAG="${GITHUB_REF#refs/tags/v}"
echo "Setting VERSION to $TAG"
sed -i.bak "s/const VERSION = \".*\"/const VERSION = \"${TAG}\"/g" share/const.go
rm -f share/const.go.bak
grep 'const VERSION' share/const.go
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
- name: Setup Go Tools
run: make tools
- name: Make Artifacts macOS
run: make artifacts-macos
- name: Get Version
id: version
run: |
VERSION=$(grep 'const VERSION =' share/const.go | awk '{print $4}' | sed 's/"//g')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: List Build Output
run: ls -lh dist/release/
- name: Install Certificates
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
mkdir -p certs
echo "${{ secrets.APPLE_DEVELOPERIDG2CA }}" | base64 --decode > certs/DeveloperIDG2CA.cer
echo "${{ secrets.APPLE_DISTRIBUTION }}" | base64 --decode > certs/distribution.cer
echo "${{ secrets.APPLE_PRIVATE_KEY }}" | base64 --decode > certs/private_key.p12
security verify-cert -c certs/DeveloperIDG2CA.cer
security verify-cert -c certs/distribution.cer
- name: Import Certificates
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security import ./certs/DeveloperIDG2CA.cer -k $KEYCHAIN_PATH -T /usr/bin/codesign
security import ./certs/distribution.cer -k $KEYCHAIN_PATH -T /usr/bin/codesign
security import ./certs/private_key.p12 -k $KEYCHAIN_PATH -P "${{ secrets.APPLE_PRIVATE_KEY_PASSWORD }}" -T /usr/bin/codesign
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Sign Yao Binaries
run: |
VERSION="${{ steps.version.outputs.version }}"
IDENTITY="Developer ID Application: ${{ secrets.APPLE_SIGN }}"
for ARCH in arm64 amd64; do
for SUFFIX in "" "-prod"; do
BIN="dist/release/yao-${VERSION}-darwin-${ARCH}${SUFFIX}"
codesign --force --verbose --timestamp --options runtime \
--entitlements .github/codesign/entitlements.plist \
--sign "$IDENTITY" "$BIN"
codesign --verify --deep --strict --verbose=2 "$BIN"
done
done
- name: Prepare Output and Checksums
run: |
VERSION="${{ steps.version.outputs.version }}"
for ARCH in arm64 amd64; do
for VARIANT in dev prod; do
if [ "$VARIANT" = "dev" ]; then
SRC="dist/release/yao-${VERSION}-darwin-${ARCH}"
else
SRC="dist/release/yao-${VERSION}-darwin-${ARCH}-prod"
fi
DIR="/tmp/yao-output-${ARCH}-${VARIANT}"
mkdir -p "$DIR"
cp "$SRC" "$DIR/yao"
chmod +x "$DIR/yao"
done
done
mkdir -p /tmp/checksums
for ARCH in arm64 amd64; do
for VARIANT in dev prod; do
shasum -a 256 "/tmp/yao-output-${ARCH}-${VARIANT}/yao" | awk '{print $1" yao"}' > "/tmp/checksums/yao-darwin-${ARCH}-${VARIANT}.sha256"
done
done
cat /tmp/checksums/*.sha256
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: yao-darwin-arm64
path: /tmp/yao-output-arm64-prod/yao
- name: Upload arm64 Dev Binary
uses: actions/upload-artifact@v4
with:
name: yao-darwin-arm64-dev
path: /tmp/yao-output-arm64-dev/yao
- name: Upload amd64 Binary
uses: actions/upload-artifact@v4
with:
name: yao-darwin-amd64
path: /tmp/yao-output-amd64-prod/yao
- name: Upload amd64 Dev Binary
uses: actions/upload-artifact@v4
with:
name: yao-darwin-amd64-dev
path: /tmp/yao-output-amd64-dev/yao
- name: Upload Checksums
uses: actions/upload-artifact@v4
with:
name: yao-darwin-checksums
path: /tmp/checksums/*.sha256