Build and Release #95
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-release: | |
| runs-on: lynx-ubuntu-22.04-medium | |
| outputs: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| release_type: ${{ steps.release_type.outputs.RELEASE_TYPE }} | |
| asset_suffix: ${{ steps.release_type.outputs.ASSET_SUFFIX }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set release type | |
| id: release_type | |
| run: | | |
| if [[ ${{ github.ref }} =~ .*-alpha.* ]]; then | |
| echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT | |
| echo "IS_TEMP_VERSION=false" >> $GITHUB_OUTPUT | |
| echo "RELEASE_TYPE=Alpha" >> $GITHUB_OUTPUT | |
| echo "ASSET_SUFFIX=alpha" >> $GITHUB_OUTPUT | |
| elif [[ ${{ github.ref }} =~ .*-beta.* ]]; then | |
| echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT | |
| echo "IS_TEMP_VERSION=false" >> $GITHUB_OUTPUT | |
| echo "RELEASE_TYPE=Beta" >> $GITHUB_OUTPUT | |
| echo "ASSET_SUFFIX=beta" >> $GITHUB_OUTPUT | |
| elif [[ ${{ github.ref }} =~ .*-temp.* ]]; then | |
| echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT | |
| echo "IS_TEMP_VERSION=true" >> $GITHUB_OUTPUT | |
| echo "RELEASE_TYPE=Temp" >> $GITHUB_OUTPUT | |
| echo "ASSET_SUFFIX=temp" >> $GITHUB_OUTPUT | |
| else | |
| echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT | |
| echo "IS_TEMP_VERSION=false" >> $GITHUB_OUTPUT | |
| echo "RELEASE_TYPE=Release" >> $GITHUB_OUTPUT | |
| echo "ASSET_SUFFIX=release" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: ${{ steps.release_type.outputs.RELEASE_TYPE }} ${{ github.ref }} | |
| draft: false | |
| prerelease: ${{ steps.release_type.outputs.IS_PRERELEASE }} | |
| body: | | |
| ${{ steps.release_type.outputs.IS_PRERELEASE == 'true' && '🚧 This is a pre-release version that may contain unstable features. | |
| ### Release Notes | |
| - This is a pre-release version for testing purposes only | |
| - Not recommended for production use' || steps.release_type.outputs.IS_TEMP_VERSION == 'true' && '⚠️ This is a temporary test version. | |
| ### Important Notice | |
| - This version is for testing purposes only | |
| - Only used for DevTool developers to verify branch code | |
| - May contain unstable or incomplete features' || github.ref }} | |
| build-frontend: | |
| needs: create-release | |
| runs-on: lynx-ubuntu-22.04-medium | |
| outputs: | |
| frontend_artifact_name: ${{ steps.artifact_info.outputs.artifact_name }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18.20.2 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 7.33.6 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Ensure python (user bin) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p "$HOME/.local/bin" | |
| PY3=$(which python3) | |
| ln -sf "$PY3" "$HOME/.local/bin/python" | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| python --version | |
| - name: Fetch depot_tools | |
| run: pnpm run fetch:depot_tools | |
| - name: Sync devtools-gn | |
| run: | | |
| export PATH=$(pwd)/packages/devtools-frontend-lynx/buildtools/depot_tools:$PATH | |
| pnpm run sync:devtools-gn | |
| - name: Build devtools-gn | |
| run: pnpm run build:devtools | |
| - name: Sync devtools-dist | |
| run: pnpm run sync:devtools-dist | |
| - name: Find and Upload Frontend to Release | |
| id: upload_frontend | |
| run: | | |
| ARCHIVE_PATH=$(find ./packages/devtools-frontend-lynx/output -name "devtool.frontend.lynx_1.0.*.tar.gz" | head -n 1) | |
| if [ -z "$ARCHIVE_PATH" ]; then | |
| echo "Error: Frontend archive not found" | |
| exit 1 | |
| fi | |
| ARCHIVE_NAME=$(basename "$ARCHIVE_PATH") | |
| echo "Found archive at: ${ARCHIVE_PATH}" | |
| echo "archive_path=${ARCHIVE_PATH}" >> $GITHUB_OUTPUT | |
| echo "archive_name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT | |
| curl \ | |
| -X POST \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Content-Type: application/gzip" \ | |
| --data-binary @"${ARCHIVE_PATH}" \ | |
| "${{ needs.create-release.outputs.upload_url }}?name=devtool.frontend.lynx-${{ needs.create-release.outputs.asset_suffix }}.tar.gz" | |
| - name: Upload Frontend as Artifact | |
| uses: actions/upload-artifact@v3 | |
| id: artifact_info | |
| with: | |
| name: devtools-frontend-lynx | |
| path: ${{ steps.upload_frontend.outputs.archive_path }} | |
| retention-days: 1 | |
| build-and-upload-macos: | |
| needs: [create-release, build-frontend] | |
| runs-on: lynx-darwin-14-medium | |
| strategy: | |
| matrix: | |
| arch: [arm64, x64] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: ln Python | |
| run: ln -s `which python3` /usr/local/bin/python | |
| # Node and pnpm setup steps | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18.20.2 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 7.33.6 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download DevTools Frontend | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: devtools-frontend-lynx | |
| path: temp-frontend | |
| - name: Extract DevTools Frontend | |
| run: | | |
| mkdir -p packages/devtools-frontend-lynx/output | |
| ARCHIVE_PATH=$(find temp-frontend -name "devtool.frontend.lynx_*.tar.gz" | head -n 1) | |
| tar -xzf "$ARCHIVE_PATH" -C packages/devtools-frontend-lynx/output | |
| echo "DevTools Frontend extracted successfully" | |
| - name: Build lynx-trace | |
| run: pnpm run build:lynx-trace | |
| - name: Build all packages | |
| run: pnpm run build:all | |
| - name: Install Apple Certificate | |
| if: matrix.arch == 'arm64' || matrix.arch == 'x64' | |
| env: | |
| BUILD_CERTIFICATE_BASE64: ${{ secrets.MACOS_CERTIFICATE }} | |
| P12_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
| KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} | |
| run: | | |
| security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
| security default-keychain -s build.keychain | |
| security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain | |
| echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode > certificate.p12 | |
| security import certificate.p12 -k build.keychain -P "$P12_PASSWORD" -T /usr/bin/codesign | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain | |
| rm certificate.p12 | |
| # Build and upload platform-specific DMG | |
| - name: Build ${{ matrix.arch }} version | |
| env: | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CSC_IDENTITY_AUTO_DISCOVERY: true | |
| CSC_LINK: ${{ secrets.MACOS_CERTIFICATE }} | |
| CSC_KEY_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PWD }} | |
| run: pnpm run production:mac-${{ matrix.arch }} | |
| - name: Find DMG Path | |
| id: find_dmg | |
| run: | | |
| DMG_PATH=$(find ./dist -name "*.dmg" | head -n 1) | |
| if [ -z "$DMG_PATH" ]; then | |
| echo "Error: DMG file not found" | |
| exit 1 | |
| fi | |
| DMG_FILENAME=$(basename "$DMG_PATH") | |
| echo "Found DMG at: ${DMG_PATH}" | |
| echo "dmg_path=${DMG_PATH}" >> $GITHUB_OUTPUT | |
| echo "dmg_filename=${DMG_FILENAME}" >> $GITHUB_OUTPUT | |
| - name: Upload ${{ matrix.arch }} DMG | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ needs.create-release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_dmg.outputs.dmg_path }} | |
| asset_name: ${{ steps.find_dmg.outputs.dmg_filename }} | |
| asset_content_type: application/x-apple-diskimage | |
| build-and-upload-windows: | |
| needs: [create-release, build-frontend] | |
| runs-on: lynx-windows-2022-large | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # Node and pnpm setup steps | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18.20.2 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: 7.33.6 | |
| - name: Get pnpm store directory | |
| shell: pwsh | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $env:GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download DevTools Frontend | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: devtools-frontend-lynx | |
| path: temp-frontend | |
| - name: Extract DevTools Frontend | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "packages\devtools-frontend-lynx\output" | |
| $archivePath = Get-ChildItem -Path "temp-frontend" -Filter "devtool.frontend.lynx_*.tar.gz" | Select-Object -First 1 -ExpandProperty FullName | |
| tar -xzf "$archivePath" -C "packages\devtools-frontend-lynx\output" | |
| Write-Host "DevTools Frontend extracted successfully" | |
| - name: Skip lynx-trace build on Windows | |
| run: pnpm run build:lynx-trace | |
| - name: Download lynx-trace prebuilt artifact | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: lynx-family/lynx-trace | |
| latest: true | |
| fileName: "perfetto-ui-*.tar.gz" | |
| out-file-path: temp-lynx-trace | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Copy lynx-trace to resources | |
| shell: pwsh | |
| run: | | |
| Write-Host "Copying prebuilt lynx-trace artifact..." -ForegroundColor Cyan | |
| $sourceFile = Get-ChildItem -Path "temp-lynx-trace" -Filter "perfetto-ui-release-*.tar.gz" | Select-Object -First 1 | |
| $destPath = "packages\lynx-devtool-cli\resources\lynx-trace.tar.gz" | |
| if ($sourceFile) { | |
| Copy-Item $sourceFile.FullName $destPath -Force | |
| Write-Host "✓ lynx-trace artifact copied: $($sourceFile.Name) -> lynx-trace.tar.gz" -ForegroundColor Green | |
| } else { | |
| Write-Warning "lynx-trace artifact not found, trace feature will be unavailable" | |
| Get-ChildItem -Path "temp-lynx-trace" -ErrorAction SilentlyContinue | |
| } | |
| - name: Build all packages | |
| run: pnpm run build:all | |
| # Build Windows green package (ZIP - no installer) | |
| - name: Build Windows version | |
| shell: pwsh | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| Write-Host "Starting Windows build..." -ForegroundColor Cyan | |
| pwsh -ExecutionPolicy Bypass -File scripts\build-win.ps1 | |
| - name: Find Windows ZIP file | |
| id: find_zip | |
| shell: pwsh | |
| run: | | |
| $zip = Get-ChildItem -Path ".\dist" -Filter "Lynx-DevTool-*-x64.zip" | Select-Object -First 1 | |
| if ($zip) { | |
| Write-Host "Found ZIP package: $($zip.Name)" -ForegroundColor Green | |
| Write-Host "Size: $([math]::Round($zip.Length/1MB, 2)) MB" -ForegroundColor Green | |
| echo "zip_path=$($zip.FullName)" >> $env:GITHUB_OUTPUT | |
| echo "zip_filename=$($zip.Name)" >> $env:GITHUB_OUTPUT | |
| } else { | |
| Write-Error "No ZIP file found in dist directory" | |
| Get-ChildItem -Path ".\dist" | Format-Table Name | |
| exit 1 | |
| } | |
| - name: Upload Windows ZIP Package | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ needs.create-release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_zip.outputs.zip_path }} | |
| asset_name: ${{ steps.find_zip.outputs.zip_filename }} | |
| asset_content_type: application/zip |