|
| 1 | +name: Beta Release Build & Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*-beta.*' # Only beta tags |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build & Release Beta - ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: macos-latest |
| 21 | + platform: darwin |
| 22 | + arch: arm64 |
| 23 | + - os: windows-latest |
| 24 | + platform: win32 |
| 25 | + arch: x64 |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: '22.20.0' |
| 35 | + |
| 36 | + - name: Setup Python 3.11 |
| 37 | + uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: '3.11' |
| 40 | + |
| 41 | + - name: Setup pnpm |
| 42 | + uses: pnpm/action-setup@v2 |
| 43 | + with: |
| 44 | + version: 9.4.0 |
| 45 | + |
| 46 | + - name: Get pnpm store directory |
| 47 | + shell: bash |
| 48 | + run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 49 | + |
| 50 | + - name: Setup pnpm cache |
| 51 | + uses: actions/cache@v4 |
| 52 | + with: |
| 53 | + path: ${{ env.STORE_PATH }} |
| 54 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 55 | + restore-keys: | |
| 56 | + ${{ runner.os }}-pnpm-store- |
| 57 | +
|
| 58 | + - name: Install dependencies |
| 59 | + run: pnpm install --frozen-lockfile |
| 60 | + |
| 61 | + # macOS signing (required for signed builds) |
| 62 | + - name: Import Apple certificate (macOS) |
| 63 | + if: matrix.platform == 'darwin' |
| 64 | + env: |
| 65 | + APPLE_CERTIFICATE_BASE64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }} |
| 66 | + APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} |
| 67 | + run: | |
| 68 | + security create-keychain -p actions temp.keychain |
| 69 | + security default-keychain -s temp.keychain |
| 70 | + security unlock-keychain -p actions temp.keychain |
| 71 | + security set-keychain-settings -t 3600 -u temp.keychain |
| 72 | +
|
| 73 | + echo "$APPLE_CERTIFICATE_BASE64" | base64 --decode > certificate.p12 |
| 74 | + security import certificate.p12 -k temp.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign |
| 75 | + security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k actions temp.keychain |
| 76 | +
|
| 77 | + rm certificate.p12 |
| 78 | +
|
| 79 | + - name: Build and package application |
| 80 | + env: |
| 81 | + # Only set signing env vars if secrets exist, otherwise build unsigned |
| 82 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 83 | + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} |
| 84 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 85 | + run: pnpm run make |
| 86 | + |
| 87 | + - name: Package & Publish Beta (macOS) |
| 88 | + if: matrix.platform == 'darwin' |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 91 | + # Notarization env vars needed for electron-forge publish |
| 92 | + APPLE_ID: ${{ secrets.APPLE_ID }} |
| 93 | + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} |
| 94 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 95 | + run: pnpm run publish |
| 96 | + |
| 97 | + - name: Package & Publish Beta (Windows) |
| 98 | + if: matrix.platform == 'win32' |
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 101 | + run: pnpm run publish |
| 102 | + |
| 103 | + - name: Cleanup keychain (macOS) |
| 104 | + if: matrix.platform == 'darwin' && always() |
| 105 | + run: security delete-keychain temp.keychain || true |
| 106 | + |
| 107 | + # Mark as pre-release |
| 108 | + - name: Mark as pre-release |
| 109 | + if: success() |
| 110 | + uses: actions/github-script@v7 |
| 111 | + with: |
| 112 | + github-token: ${{ secrets.GH_TOKEN }} |
| 113 | + script: | |
| 114 | + const tag = context.ref.replace('refs/tags/', ''); |
| 115 | + const releases = await github.rest.repos.listReleases({ |
| 116 | + owner: context.repo.owner, |
| 117 | + repo: context.repo.repo |
| 118 | + }); |
| 119 | +
|
| 120 | + const release = releases.data.find(r => r.tag_name === tag); |
| 121 | + if (release) { |
| 122 | + await github.rest.repos.updateRelease({ |
| 123 | + owner: context.repo.owner, |
| 124 | + repo: context.repo.repo, |
| 125 | + release_id: release.id, |
| 126 | + prerelease: true |
| 127 | + }); |
| 128 | + console.log(`Marked release ${tag} as pre-release`); |
| 129 | + } |
0 commit comments