infra: move more res to cache in release pipeline #68
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: Prepare buildtools directory | |
| run: mkdir -p packages/devtools-frontend-lynx/buildtools | |
| - name: Restore depot_tools cache | |
| id: cache-depot-tools | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/buildtools/depot_tools | |
| key: depot_tools-v1 | |
| restore-keys: | | |
| depot_tools- | |
| - name: Clone depot_tools if missing (Linux) | |
| shell: bash | |
| run: | | |
| if [ -d "packages/devtools-frontend-lynx/buildtools/depot_tools" ]; then | |
| echo "depot_tools already exists, skipping clone" | |
| else | |
| git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "packages/devtools-frontend-lynx/buildtools/depot_tools" --depth=1 | |
| fi | |
| - name: Add depot_tools to PATH (Linux) | |
| shell: bash | |
| run: echo "${{ github.workspace }}/packages/devtools-frontend-lynx/buildtools/depot_tools" >> $GITHUB_PATH | |
| - name: Sync DEPS to materialize buildtools (no hooks) | |
| shell: bash | |
| working-directory: packages/devtools-frontend-lynx | |
| run: | | |
| set -euo pipefail | |
| gclient sync --gclientfile=.gclient --deps=all --nohooks | |
| # Restore caches for third-party resources (Node/mac, clang-format/mac, Chromium/mac) | |
| - name: Restore Node (mac) cache | |
| id: cache-node-mac-linux | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/third_party/node/mac | |
| key: node-mac-14.15.4-v1 | |
| restore-keys: | | |
| node-mac- | |
| - name: Restore clang-format (mac) cache | |
| id: cache-clang-mac-linux | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/buildtools/mac | |
| key: clang-format-mac-v1 | |
| restore-keys: | | |
| clang-format- | |
| - name: Restore Chromium (mac 902866) cache | |
| id: cache-chrome-mac-linux | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/third_party/chrome | |
| key: chrome-mac-902866-v1 | |
| restore-keys: | | |
| chrome-mac- | |
| # Prefetch third-party resources on Linux container to populate caches | |
| - name: Prefetch Node (mac x64) | |
| shell: bash | |
| working-directory: packages/devtools-frontend-lynx | |
| run: | | |
| set -euo pipefail | |
| python3 buildtools/depot_tools/download_from_google_storage.py \ | |
| --no_resume --extract \ | |
| --bucket chromium-nodejs/14.15.4 \ | |
| -s third_party/node/mac/node-darwin-x64.tar.gz.sha1 | |
| - name: Prefetch clang-format (mac) | |
| shell: bash | |
| working-directory: packages/devtools-frontend-lynx | |
| run: | | |
| set -euo pipefail | |
| python3 buildtools/depot_tools/download_from_google_storage.py \ | |
| --no_resume \ | |
| --bucket chromium-clang-format \ | |
| -s buildtools/mac/clang-format.sha1 | |
| - name: Prefetch Chromium (mac 902866) | |
| shell: bash | |
| working-directory: packages/devtools-frontend-lynx | |
| run: | | |
| set -euo pipefail | |
| python3 scripts/deps/download_chromium.py \ | |
| https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/902866/chrome-mac.zip \ | |
| third_party/chrome \ | |
| chrome-mac/Chromium.app/Contents \ | |
| 902866 | |
| - 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: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| tag_name: ${{ github.ref_name }} | |
| name: ${{ steps.release_type.outputs.RELEASE_TYPE }} ${{ github.ref_name }} | |
| 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_name }} | |
| build-and-upload-macos: | |
| needs: create-release | |
| runs-on: lynx-darwin-14-medium | |
| permissions: write-all | |
| strategy: | |
| matrix: | |
| arch: [arm64, x64] | |
| env: | |
| PUPPETEER_SKIP_DOWNLOAD: true | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Prepare buildtools directory | |
| run: mkdir -p packages/devtools-frontend-lynx/buildtools | |
| - name: Restore depot_tools cache | |
| id: cache-depot-tools-macos | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/buildtools/depot_tools | |
| key: depot_tools-v1 | |
| restore-keys: | | |
| depot_tools- | |
| # Restore cached third-party resources to avoid network downloads in hooks | |
| - name: Restore Node (mac) cache | |
| id: cache-node-mac | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/third_party/node/mac | |
| key: node-mac-14.15.4-v1 | |
| restore-keys: | | |
| node-mac- | |
| - name: Restore clang-format (mac) cache | |
| id: cache-clang-mac | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/buildtools/mac | |
| key: clang-format-mac-v1 | |
| restore-keys: | | |
| clang-format- | |
| - name: Restore Chromium (mac 902866) cache | |
| id: cache-chrome-mac | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/third_party/chrome | |
| key: chrome-mac-902866-v1 | |
| restore-keys: | | |
| chrome-mac- | |
| # 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: Fetch depot_tools | |
| run: pnpm run fetch:depot_tools | |
| - name: Add depot_tools to PATH (mac) | |
| shell: bash | |
| run: echo "$(pwd)/packages/devtools-frontend-lynx/buildtools/depot_tools" >> $GITHUB_PATH | |
| - name: Symlink python to python3 (mac) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| which python3 || { | |
| echo "python3 not found in PATH"; exit 1; | |
| } | |
| sudo ln -sf "$(which python3)" /usr/local/bin/python | |
| - 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: Download lynx-trace prebuilt artifact | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: KananSu/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: bash | |
| run: | | |
| set -euo pipefail | |
| echo "Copying prebuilt lynx-trace artifact..." | |
| src=$(find "temp-lynx-trace" -name "perfetto-ui-release-*.tar.gz" | head -n 1 || true) | |
| dest="packages/lynx-devtool-cli/resources/lynx-trace.tar.gz" | |
| if [[ -n "$src" ]]; then | |
| cp -v "$src" "$dest" | |
| echo "✓ lynx-trace artifact copied: $(basename "$src") -> lynx-trace.tar.gz" | |
| else | |
| echo "Warning: lynx-trace artifact not found, trace feature will be unavailable" | |
| ls -la "temp-lynx-trace" || true | |
| fi | |
| - name: Build all packages | |
| run: pnpm run build:all | |
| # Only upload frontend once (in arm64 job) | |
| - name: Find Frontend Archive | |
| id: find_frontend | |
| if: matrix.arch == 'arm64' | |
| 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 | |
| echo "Found archive at: ${ARCHIVE_PATH}" | |
| echo "archive_path=${ARCHIVE_PATH}" >> $GITHUB_OUTPUT | |
| - name: Prepare Frontend Asset | |
| id: prepare_frontend_asset | |
| if: matrix.arch == 'arm64' | |
| run: | | |
| mkdir -p frontend-upload | |
| cp "${{ steps.find_frontend.outputs.archive_path }}" "frontend-upload/devtool.frontend.lynx-${{ needs.create-release.outputs.asset_suffix }}.tar.gz" | |
| echo "upload_path=frontend-upload/devtool.frontend.lynx-${{ needs.create-release.outputs.asset_suffix }}.tar.gz" >> $GITHUB_OUTPUT | |
| - name: Upload Frontend (GH Release) | |
| if: matrix.arch == 'arm64' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: frontend-upload/devtool.frontend.lynx-${{ needs.create-release.outputs.asset_suffix }}.tar.gz | |
| - 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 (GH Release) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: ${{ steps.find_dmg.outputs.dmg_path }} | |
| build-and-upload-windows: | |
| permissions: write-all | |
| needs: create-release | |
| runs-on: lynx-windows-2022-large | |
| env: | |
| PUPPETEER_SKIP_DOWNLOAD: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Prepare buildtools directory | |
| shell: pwsh | |
| run: | | |
| $dir = "packages\devtools-frontend-lynx\buildtools" | |
| if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir | Out-Null } | |
| - name: Restore depot_tools cache | |
| id: cache-depot-tools-windows | |
| uses: lynx-infra/cache@main | |
| with: | |
| path: packages/devtools-frontend-lynx/buildtools/depot_tools | |
| key: depot_tools-v1 | |
| restore-keys: | | |
| depot_tools- | |
| # 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 Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - 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: Fetch depot_tools | |
| run: pnpm run fetch:depot_tools | |
| - name: Add depot_tools & Python to PATH | |
| shell: pwsh | |
| run: | | |
| $depot = "$(Get-Location)\packages\devtools-frontend-lynx\buildtools\depot_tools" | |
| "$depot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| $env:pythonLocation | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| python --version | |
| where.exe python | |
| - name: Sync devtools-gn | |
| shell: pwsh | |
| run: 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: Download lynx-trace prebuilt artifact | |
| uses: robinraju/release-downloader@v1 | |
| with: | |
| repository: KananSu/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 | |
| # Upload frontend (only once) | |
| - name: Find Frontend Archive | |
| id: find_frontend_win | |
| shell: pwsh | |
| run: | | |
| $archivePath = Get-ChildItem -Path ".\packages\devtools-frontend-lynx\output" -Filter "devtool.frontend.lynx_1.0.*.tar.gz" | Select-Object -First 1 -ExpandProperty FullName | |
| if (-not $archivePath) { | |
| Write-Error "Error: Frontend archive not found" | |
| exit 1 | |
| } | |
| Write-Host "Found archive at: $archivePath" | |
| echo "archive_path=$archivePath" >> $env:GITHUB_OUTPUT | |
| - name: Prepare Frontend Asset | |
| id: prepare_frontend_win | |
| shell: pwsh | |
| run: | | |
| $destDir = "frontend-upload" | |
| if (-not (Test-Path $destDir)) { New-Item -ItemType Directory -Path $destDir | Out-Null } | |
| $destPath = Join-Path $destDir "devtool.frontend.lynx-${{ needs.create-release.outputs.asset_suffix }}.tar.gz" | |
| Copy-Item "${{ steps.find_frontend_win.outputs.archive_path }}" $destPath -Force | |
| $uploadPath = (Resolve-Path $destPath).Path -replace '\\','/' | |
| echo "upload_path=$uploadPath" >> $env:GITHUB_OUTPUT | |
| - name: Upload Frontend (GH Release) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: ${{ steps.prepare_frontend_win.outputs.upload_path }} | |
| # 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 | |
| powershell -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: Normalize ZIP path | |
| id: normalize_zip | |
| shell: pwsh | |
| run: | | |
| $p = "${{ steps.find_zip.outputs.zip_path }}" -replace '\\','/' | |
| echo "upload_path=$p" >> $env:GITHUB_OUTPUT | |
| - name: Upload Windows ZIP (GH Release) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| files: ${{ steps.normalize_zip.outputs.upload_path }} |