mirror of
https://github.com/different-ai/openwork
synced 2026-04-25 17:15:34 +02:00
ci: add macos arm64 alpha artifact workflow
This commit is contained in:
191
.github/workflows/alpha-macos-aarch64.yml
vendored
Normal file
191
.github/workflows/alpha-macos-aarch64.yml
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
name: Alpha Desktop Artifact (macOS arm64)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: alpha-macos-aarch64-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-alpha-macos-aarch64:
|
||||
name: Build alpha artifact (aarch64-apple-darwin)
|
||||
runs-on: macos-14
|
||||
timeout-minutes: 180
|
||||
|
||||
env:
|
||||
OPENCODE_GITHUB_REPO: ${{ vars.OPENCODE_GITHUB_REPO || 'anomalyco/opencode' }}
|
||||
OPENCODE_VERSION: ${{ vars.OPENCODE_VERSION || '1.2.20' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 10.27.0
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: "1.3.6"
|
||||
|
||||
- name: Get pnpm store path
|
||||
id: pnpm-store
|
||||
shell: bash
|
||||
run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Cache pnpm store
|
||||
uses: actions/cache@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
path: ${{ steps.pnpm-store.outputs.path }}
|
||||
key: macos-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
macos-pnpm-
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
continue-on-error: true
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
packages/desktop/src-tauri/target
|
||||
key: macos-cargo-${{ hashFiles('packages/desktop/src-tauri/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
macos-cargo-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
|
||||
- name: Create CI Tauri config (no updater artifacts)
|
||||
run: |
|
||||
node -e "const fs=require('fs'); const configPath='packages/desktop/src-tauri/tauri.conf.json'; const ciPath='packages/desktop/src-tauri/tauri.conf.alpha.json'; const config=JSON.parse(fs.readFileSync(configPath,'utf8')); config.bundle={...config.bundle, createUpdaterArtifacts:false}; fs.writeFileSync(ciPath, JSON.stringify(config, null, 2));"
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: aarch64-apple-darwin
|
||||
|
||||
- name: Resolve OpenCode version
|
||||
id: opencode-version
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
node <<'NODE' >> "$GITHUB_OUTPUT"
|
||||
const fs = require('fs');
|
||||
const repo = (process.env.OPENCODE_GITHUB_REPO || 'anomalyco/opencode').trim() || 'anomalyco/opencode';
|
||||
|
||||
async function resolveLatest() {
|
||||
const token = (process.env.GITHUB_TOKEN || '').trim();
|
||||
const headers = {
|
||||
Accept: 'application/vnd.github+json',
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
'User-Agent': 'openwork-ci',
|
||||
};
|
||||
if (token) headers.Authorization = `Bearer ${token}`;
|
||||
|
||||
try {
|
||||
const res = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, { headers });
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
const tag = (typeof data.tag_name === 'string' ? data.tag_name : '').trim();
|
||||
const version = (tag.startsWith('v') ? tag.slice(1) : tag).trim();
|
||||
if (version) return version;
|
||||
}
|
||||
if (res.status !== 403) {
|
||||
throw new Error(`Failed to resolve latest OpenCode version (HTTP ${res.status})`);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
|
||||
const web = await fetch(`https://github.com/${repo}/releases/latest`, {
|
||||
headers: { 'User-Agent': 'openwork-ci' },
|
||||
redirect: 'follow',
|
||||
});
|
||||
const url = web && web.url ? String(web.url) : '';
|
||||
const match = url.match(/\/tag\/v([^/?#]+)/);
|
||||
if (!match) throw new Error('Failed to resolve latest OpenCode version (web redirect).');
|
||||
return match[1];
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const pkg = JSON.parse(fs.readFileSync('./packages/desktop/package.json', 'utf8'));
|
||||
const configuredRaw = (process.env.OPENCODE_VERSION || pkg.opencodeVersion || '').toString().trim();
|
||||
if (configuredRaw && configuredRaw.toLowerCase() !== 'latest') {
|
||||
const resolved = (configuredRaw.startsWith('v') ? configuredRaw.slice(1) : configuredRaw).trim();
|
||||
if (process.env.GITHUB_ENV) {
|
||||
fs.appendFileSync(process.env.GITHUB_ENV, `OPENCODE_VERSION=${resolved}\n`);
|
||||
}
|
||||
console.log('version=' + resolved);
|
||||
return;
|
||||
}
|
||||
const latest = await resolveLatest();
|
||||
if (process.env.GITHUB_ENV) {
|
||||
fs.appendFileSync(process.env.GITHUB_ENV, `OPENCODE_VERSION=${latest}\n`);
|
||||
}
|
||||
console.log('version=' + latest);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
NODE
|
||||
|
||||
- name: Download OpenCode sidecar
|
||||
shell: bash
|
||||
env:
|
||||
OPENCODE_VERSION: ${{ steps.opencode-version.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
repo="${OPENCODE_GITHUB_REPO:-anomalyco/opencode}"
|
||||
opencode_asset="opencode-darwin-arm64.zip"
|
||||
url="https://github.com/${repo}/releases/download/v${OPENCODE_VERSION}/${opencode_asset}"
|
||||
tmp_dir="$RUNNER_TEMP/opencode"
|
||||
extract_dir="$tmp_dir/extracted"
|
||||
rm -rf "$tmp_dir"
|
||||
mkdir -p "$extract_dir"
|
||||
curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 -o "$tmp_dir/$opencode_asset" "$url"
|
||||
unzip -q "$tmp_dir/$opencode_asset" -d "$extract_dir"
|
||||
|
||||
if [ ! -f "$extract_dir/opencode" ]; then
|
||||
echo "OpenCode binary not found in archive" >&2
|
||||
ls -la "$extract_dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p packages/desktop/src-tauri/sidecars
|
||||
cp "$extract_dir/opencode" "packages/desktop/src-tauri/sidecars/opencode-aarch64-apple-darwin"
|
||||
chmod 755 "packages/desktop/src-tauri/sidecars/opencode-aarch64-apple-darwin"
|
||||
|
||||
- name: Build alpha desktop app
|
||||
run: pnpm --filter @different-ai/openwork exec tauri build --config src-tauri/tauri.conf.alpha.json --target aarch64-apple-darwin --bundles dmg,app
|
||||
|
||||
- name: Upload alpha artifact bundle
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openwork-alpha-macos-aarch64-${{ github.sha }}
|
||||
path: |
|
||||
packages/desktop/src-tauri/target/aarch64-apple-darwin/release/bundle/dmg/*.dmg
|
||||
packages/desktop/src-tauri/target/aarch64-apple-darwin/release/bundle/macos/*.app.tar.gz
|
||||
packages/desktop/src-tauri/target/aarch64-apple-darwin/release/bundle/macos/*.app.tar.gz.sig
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
Reference in New Issue
Block a user