yao/.github/workflows/release-macos.yml
Max d6e5afd26b refactor(workflow): consolidate build steps and remove redundant release processes
- Merged the Linux build job into a single 'build' job for improved clarity and efficiency.
- Removed redundant version retrieval steps from both Linux and macOS workflows, streamlining the release process.
- Updated dependencies and artifact handling to ensure compatibility with the new workflow structure.
- Enhanced the macOS workflow to trigger on version tags, improving version management during releases.

Made-with: Cursor
2026-03-15 17:47:07 +08:00

198 lines
6.3 KiB
YAML

name: Release macOS
on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. 1.0.0 or 1.0.0-alpha). Leave empty to read from share/const.go."
required: false
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: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
- name: Setup Go Tools
run: make tools
- name: Get Version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
else
VERSION=$(cat share/const.go | grep 'const VERSION' | awk '{print $4}' | sed 's/"//g')
echo "version=${VERSION}" >> $GITHUB_OUTPUT
fi
- name: Make Artifacts macOS
run: make artifacts-macos
env:
VERSION: ${{ steps.version.outputs.version }}
- 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
BIN="dist/release/yao-${VERSION}-unstable-darwin-${ARCH}"
codesign --force --verbose --timestamp --options runtime --sign "$IDENTITY" "$BIN"
codesign --verify --deep --strict --verbose=2 "$BIN"
done
- name: Prepare Output and Checksums
run: |
VERSION="${{ steps.version.outputs.version }}"
for ARCH in arm64 amd64; do
mkdir -p /tmp/yao-output-${ARCH}
cp "dist/release/yao-${VERSION}-unstable-darwin-${ARCH}" "/tmp/yao-output-${ARCH}/yao"
chmod +x "/tmp/yao-output-${ARCH}/yao"
done
mkdir -p /tmp/checksums
shasum -a 256 /tmp/yao-output-arm64/yao | awk '{print $1" yao"}' > /tmp/checksums/yao-darwin-arm64.sha256
shasum -a 256 /tmp/yao-output-amd64/yao | awk '{print $1" yao"}' > /tmp/checksums/yao-darwin-amd64.sha256
cat /tmp/checksums/*.sha256
- name: Upload arm64 Binary
uses: actions/upload-artifact@v4
with:
name: yao-darwin-arm64
path: /tmp/yao-output-arm64/yao
- name: Upload amd64 Binary
uses: actions/upload-artifact@v4
with:
name: yao-darwin-amd64
path: /tmp/yao-output-amd64/yao
- name: Upload arm64 Checksum
uses: actions/upload-artifact@v4
with:
name: yao-darwin-arm64-sha256
path: /tmp/checksums/yao-darwin-arm64.sha256
- name: Upload amd64 Checksum
uses: actions/upload-artifact@v4
with:
name: yao-darwin-amd64-sha256
path: /tmp/checksums/yao-darwin-amd64.sha256