refactor(workflow): unify macOS and Windows client build steps into a single desktop client build job
This commit is contained in:
@@ -353,15 +353,17 @@ jobs:
|
|||||||
echo "Use sudo on NAS: ${nas_use_sudo}"
|
echo "Use sudo on NAS: ${nas_use_sudo}"
|
||||||
echo "NAS output: ${nas_user}@${nas_host}:${output_dir}/${release_name}"
|
echo "NAS output: ${nas_user}@${nas_host}:${output_dir}/${release_name}"
|
||||||
|
|
||||||
build-mac:
|
build-client:
|
||||||
name: Build macOS Client
|
name: Build Desktop Client
|
||||||
needs: resolve
|
needs: resolve
|
||||||
if: needs.resolve.outputs.build_mac == 'true'
|
runs-on: ubuntu-latest
|
||||||
runs-on: macos-latest
|
|
||||||
timeout-minutes: 120
|
timeout-minutes: 120
|
||||||
env:
|
env:
|
||||||
|
BUILD_MAC: ${{ needs.resolve.outputs.build_mac }}
|
||||||
|
BUILD_WIN: ${{ needs.resolve.outputs.build_win }}
|
||||||
CLIENT_VERSION: ${{ needs.resolve.outputs.client_version }}
|
CLIENT_VERSION: ${{ needs.resolve.outputs.client_version }}
|
||||||
MAC_ARCH_FLAGS: ${{ needs.resolve.outputs.mac_arch_flags }}
|
MAC_ARCH_FLAGS: ${{ needs.resolve.outputs.mac_arch_flags }}
|
||||||
|
WIN_ARCH_FLAGS: ${{ needs.resolve.outputs.win_arch_flags }}
|
||||||
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -381,124 +383,74 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Build unsigned macOS package
|
- name: Build unsigned desktop packages
|
||||||
working-directory: apps/desktop-client
|
working-directory: apps/desktop-client
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
unset CSC_LINK CSC_NAME CSC_KEY_PASSWORD APPLE_ID APPLE_APP_SPECIFIC_PASSWORD APPLE_TEAM_ID
|
unset CSC_LINK CSC_NAME CSC_KEY_PASSWORD APPLE_ID APPLE_APP_SPECIFIC_PASSWORD APPLE_TEAM_ID WIN_CSC_LINK WIN_CSC_KEY_PASSWORD
|
||||||
export CSC_IDENTITY_AUTO_DISCOVERY=false
|
export CSC_IDENTITY_AUTO_DISCOVERY=false
|
||||||
|
|
||||||
node -e 'const fs = require("fs"); const p = "package.json"; const pkg = JSON.parse(fs.readFileSync(p, "utf8")); pkg.version = process.env.CLIENT_VERSION; fs.writeFileSync(p, `${JSON.stringify(pkg, null, 2)}\n`); console.log(`Desktop client version: ${pkg.version}`);'
|
node -e 'const fs = require("fs"); const p = "package.json"; const pkg = JSON.parse(fs.readFileSync(p, "utf8")); pkg.version = process.env.CLIENT_VERSION; fs.writeFileSync(p, `${JSON.stringify(pkg, null, 2)}\n`); console.log(`Desktop client version: ${pkg.version}`);'
|
||||||
|
|
||||||
rm -rf release
|
rm -rf release
|
||||||
pnpm run build:obf
|
pnpm run build:obf
|
||||||
pnpm exec electron-builder --mac zip ${MAC_ARCH_FLAGS} --publish never -c.mac.target=zip -c.extraMetadata.version="${CLIENT_VERSION}"
|
|
||||||
|
|
||||||
- name: Collect macOS artifacts
|
if [ "${BUILD_MAC}" = "true" ]; then
|
||||||
|
pnpm exec electron-builder --mac zip ${MAC_ARCH_FLAGS} --publish never -c.mac.target=zip -c.extraMetadata.version="${CLIENT_VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${BUILD_WIN}" = "true" ]; then
|
||||||
|
pnpm exec electron-builder --win zip ${WIN_ARCH_FLAGS} --publish never -c.win.target=zip -c.extraMetadata.version="${CLIENT_VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Collect desktop artifacts
|
||||||
working-directory: apps/desktop-client
|
working-directory: apps/desktop-client
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
artifact_dir="${RUNNER_TEMP}/desktop-client-mac"
|
artifact_root="${RUNNER_TEMP}/desktop-client-artifacts"
|
||||||
mkdir -p "${artifact_dir}"
|
mkdir -p "${artifact_root}"
|
||||||
|
|
||||||
zip_count="$(find release -maxdepth 1 -type f -name "*.zip" | wc -l | tr -d ' ')"
|
if [ "${BUILD_MAC}" = "true" ]; then
|
||||||
if [ "${zip_count}" = "0" ]; then
|
mkdir -p "${artifact_root}/mac"
|
||||||
echo "::error::No macOS artifacts found"
|
mac_zip_count="$(find release -maxdepth 1 -type f -name "*.zip" ! -iname "*win*" ! -iname "*windows*" | wc -l | tr -d ' ')"
|
||||||
exit 1
|
if [ "${mac_zip_count}" = "0" ]; then
|
||||||
|
echo "::error::No macOS zip artifact found"
|
||||||
|
find release -maxdepth 1 -type f -name "*.zip" -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${mac_zip_count}" != "1" ]; then
|
||||||
|
echo "::error::Expected exactly one macOS zip artifact, found ${mac_zip_count}."
|
||||||
|
find release -maxdepth 1 -type f -name "*.zip" -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mac_zip="$(find release -maxdepth 1 -type f -name "*.zip" ! -iname "*win*" ! -iname "*windows*" | head -n1)"
|
||||||
|
cp -p "${mac_zip}" "${artifact_root}/mac/省心推-mac-${CLIENT_VERSION}.zip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${zip_count}" != "1" ]; then
|
if [ "${BUILD_WIN}" = "true" ]; then
|
||||||
echo "::error::Expected exactly one macOS zip artifact for this build, found ${zip_count}."
|
mkdir -p "${artifact_root}/win"
|
||||||
find release -maxdepth 1 -type f -name "*.zip" -print
|
win_zip_count="$(find release -maxdepth 1 -type f -name "*.zip" \( -iname "*win*" -o -iname "*windows*" \) | wc -l | tr -d ' ')"
|
||||||
exit 1
|
if [ "${win_zip_count}" = "0" ]; then
|
||||||
|
echo "::error::No Windows zip artifact found"
|
||||||
|
find release -maxdepth 1 -type f -name "*.zip" -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${win_zip_count}" != "1" ]; then
|
||||||
|
echo "::error::Expected exactly one Windows zip artifact, found ${win_zip_count}."
|
||||||
|
find release -maxdepth 1 -type f -name "*.zip" -print
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
win_zip="$(find release -maxdepth 1 -type f -name "*.zip" \( -iname "*win*" -o -iname "*windows*" \) | head -n1)"
|
||||||
|
cp -p "${win_zip}" "${artifact_root}/win/省心推-win-${CLIENT_VERSION}.zip"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mac_zip="$(find release -maxdepth 1 -type f -name "*.zip" | head -n1)"
|
find "${artifact_root}" -maxdepth 3 -type f -print
|
||||||
cp -p "${mac_zip}" "${artifact_dir}/省心推-mac-${CLIENT_VERSION}.zip"
|
|
||||||
ls -lh "${artifact_dir}"
|
|
||||||
|
|
||||||
- name: Upload macOS artifacts
|
- name: Upload desktop artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: mac
|
name: desktop-client
|
||||||
path: ${{ runner.temp }}/desktop-client-mac
|
path: ${{ runner.temp }}/desktop-client-artifacts
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 14
|
|
||||||
|
|
||||||
build-win:
|
|
||||||
name: Build Windows Client
|
|
||||||
needs: resolve
|
|
||||||
if: needs.resolve.outputs.build_win == 'true'
|
|
||||||
runs-on: windows-latest
|
|
||||||
timeout-minutes: 120
|
|
||||||
env:
|
|
||||||
CLIENT_VERSION: ${{ needs.resolve.outputs.client_version }}
|
|
||||||
WIN_ARCH_FLAGS: ${{ needs.resolve.outputs.win_arch_flags }}
|
|
||||||
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "20"
|
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
corepack enable
|
|
||||||
corepack prepare pnpm@$env:PNPM_VERSION --activate
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
- name: Build unsigned Windows package
|
|
||||||
working-directory: apps/desktop-client
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
Remove-Item Env:CSC_LINK -ErrorAction SilentlyContinue
|
|
||||||
Remove-Item Env:CSC_NAME -ErrorAction SilentlyContinue
|
|
||||||
Remove-Item Env:CSC_KEY_PASSWORD -ErrorAction SilentlyContinue
|
|
||||||
Remove-Item Env:WIN_CSC_LINK -ErrorAction SilentlyContinue
|
|
||||||
Remove-Item Env:WIN_CSC_KEY_PASSWORD -ErrorAction SilentlyContinue
|
|
||||||
$env:CSC_IDENTITY_AUTO_DISCOVERY = "false"
|
|
||||||
|
|
||||||
node -e "const fs = require('fs'); const p = 'package.json'; const pkg = JSON.parse(fs.readFileSync(p, 'utf8')); pkg.version = process.env.CLIENT_VERSION; fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + '\n'); console.log('Desktop client version: ' + pkg.version);"
|
|
||||||
|
|
||||||
Remove-Item -Recurse -Force release -ErrorAction SilentlyContinue
|
|
||||||
pnpm run build:obf
|
|
||||||
|
|
||||||
$archFlags = $env:WIN_ARCH_FLAGS -split " " | Where-Object { $_ }
|
|
||||||
pnpm exec electron-builder --win zip @archFlags --publish never "-c.win.target=zip" "-c.extraMetadata.version=$env:CLIENT_VERSION"
|
|
||||||
|
|
||||||
- name: Collect Windows artifacts
|
|
||||||
working-directory: apps/desktop-client
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
$artifactDir = Join-Path $env:RUNNER_TEMP "desktop-client-win"
|
|
||||||
New-Item -ItemType Directory -Force -Path $artifactDir | Out-Null
|
|
||||||
|
|
||||||
$files = Get-ChildItem -Path release -Filter "*.zip" -File -ErrorAction SilentlyContinue
|
|
||||||
|
|
||||||
if (-not $files) {
|
|
||||||
throw "No Windows artifacts found"
|
|
||||||
}
|
|
||||||
|
|
||||||
$zipFiles = $files | Sort-Object FullName -Unique
|
|
||||||
if ($zipFiles.Count -ne 1) {
|
|
||||||
$zipFiles | Format-Table FullName
|
|
||||||
throw "Expected exactly one Windows zip artifact for this build, found $($zipFiles.Count)."
|
|
||||||
}
|
|
||||||
|
|
||||||
Copy-Item -Path $zipFiles[0].FullName -Destination (Join-Path $artifactDir "省心推-win-$env:CLIENT_VERSION.zip") -Force
|
|
||||||
Get-ChildItem $artifactDir | Format-Table Name, Length
|
|
||||||
|
|
||||||
- name: Upload Windows artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: win
|
|
||||||
path: ${{ runner.temp }}/desktop-client-win
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
@@ -506,13 +458,11 @@ jobs:
|
|||||||
name: Publish Client Artifacts to NAS
|
name: Publish Client Artifacts to NAS
|
||||||
needs:
|
needs:
|
||||||
- resolve
|
- resolve
|
||||||
- build-mac
|
- build-client
|
||||||
- build-win
|
|
||||||
if: >-
|
if: >-
|
||||||
always() &&
|
always() &&
|
||||||
needs.resolve.result == 'success' &&
|
needs.resolve.result == 'success' &&
|
||||||
(needs.build-mac.result == 'success' || needs.build-mac.result == 'skipped') &&
|
needs.build-client.result == 'success'
|
||||||
(needs.build-win.result == 'success' || needs.build-win.result == 'skipped')
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
env:
|
env:
|
||||||
@@ -536,6 +486,7 @@ jobs:
|
|||||||
- name: Download client artifacts
|
- name: Download client artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
name: desktop-client
|
||||||
path: desktop-artifacts
|
path: desktop-artifacts
|
||||||
|
|
||||||
- name: Write manifest
|
- name: Write manifest
|
||||||
|
|||||||
Reference in New Issue
Block a user