|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - release/cli/** |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: cli-build-${{ github.ref }} |
| 12 | + cancel-in-progress: false |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + |
| 18 | +env: |
| 19 | + SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID || 'ci-release-dummy' }} |
| 20 | + NODE_VERSION_20: "20.20.2" |
| 21 | + NODE_VERSION_22: "22.23.1" |
| 22 | + NODE_VERSION_24: "24.18.0" |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-binary: |
| 26 | + name: Build Binary (${{ matrix.target }}) |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/cli/')) && 'production' || '' }} |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - target: darwin-arm64 |
| 34 | + os: macos-latest |
| 35 | + - target: darwin-x64 |
| 36 | + os: ubuntu-latest |
| 37 | + - target: linux-x64 |
| 38 | + os: ubuntu-latest |
| 39 | + - target: linux-arm64 |
| 40 | + os: ubuntu-latest |
| 41 | + - target: windows-x64 |
| 42 | + os: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - uses: pnpm/action-setup@v4 |
| 46 | + - uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: ${{ env.NODE_VERSION_22 }} |
| 49 | + cache: pnpm |
| 50 | + - name: Install dependencies |
| 51 | + run: pnpm install --frozen-lockfile |
| 52 | + - name: Setup codesign dependencies |
| 53 | + env: |
| 54 | + APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }} |
| 55 | + APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + if [[ "$RUNNER_OS" == "macOS" && "$RUNNER_ARCH" == "ARM64" ]]; then |
| 59 | + RCODESIGN_ARCHIVE="apple-codesign-0.29.0-aarch64-apple-darwin.tar.gz" |
| 60 | + RCODESIGN_SHA256="d1a532150adaf90048260d76359261aa716abafc45c53c5dc18845029184334a" |
| 61 | + elif [[ "$RUNNER_OS" == "macOS" ]]; then |
| 62 | + RCODESIGN_ARCHIVE="apple-codesign-0.29.0-x86_64-apple-darwin.tar.gz" |
| 63 | + RCODESIGN_SHA256="14ef11bedd51a8d95eafd767939ae96d5900e5a61511bef75bb21db6e7c74140" |
| 64 | + else |
| 65 | + RCODESIGN_ARCHIVE="apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz" |
| 66 | + RCODESIGN_SHA256="dbe85cedd8ee4217b64e9a0e4c2aef92ab8bcaaa41f20bde99781ff02e600002" |
| 67 | + fi |
| 68 | + if [[ "$RUNNER_OS" == "macOS" ]]; then |
| 69 | + BASE64_DECODE="-D" |
| 70 | + else |
| 71 | + BASE64_DECODE="--decode" |
| 72 | + fi |
| 73 | + curl -fsSL "https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/${RCODESIGN_ARCHIVE}" -o rcodesign.tar.gz |
| 74 | + echo "${RCODESIGN_SHA256} rcodesign.tar.gz" | shasum -a 256 -c |
| 75 | + tar -xzf rcodesign.tar.gz --strip-components=1 |
| 76 | + sudo mv rcodesign /usr/local/bin/rcodesign |
| 77 | + rm rcodesign.tar.gz |
| 78 | + if [[ -n "$APPLE_CERT_DATA" ]]; then |
| 79 | + echo "$APPLE_CERT_DATA" | base64 "$BASE64_DECODE" > /tmp/certs.p12 |
| 80 | + { |
| 81 | + echo 'APPLE_CERT_PATH=/tmp/certs.p12' |
| 82 | + } >> "$GITHUB_ENV" |
| 83 | + fi |
| 84 | + if [[ -n "$APPLE_API_KEY" ]]; then |
| 85 | + echo "$APPLE_API_KEY" | base64 "$BASE64_DECODE" > /tmp/apple_key.json |
| 86 | + jq -r .private_key /tmp/apple_key.json > /tmp/apple_key.pem |
| 87 | + { |
| 88 | + echo "APPLE_API_KEY_ISSUER_ID=$(jq -r .issuer_id /tmp/apple_key.json | tr -d '\n\r')" |
| 89 | + echo "APPLE_API_KEY_ID=$(jq -r .key_id /tmp/apple_key.json | tr -d '\n\r')" |
| 90 | + echo 'APPLE_API_KEY_P8_PATH=/tmp/apple_key.pem' |
| 91 | + echo 'APPLE_API_KEY_PATH=/tmp/apple_key.json' |
| 92 | + } >> "$GITHUB_ENV" |
| 93 | + fi |
| 94 | + - name: Build |
| 95 | + env: |
| 96 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 97 | + RELEASE_BUILD: "1" |
| 98 | + FOSSILIZE_SIGN: ${{ (github.ref_name == 'main' || startsWith(github.ref_name, 'release/cli/')) && 'y' || 'n' }} |
| 99 | + APPLE_CERT_PASSWORD: ${{ secrets.APPLE_CERT_PASSWORD }} |
| 100 | + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} |
| 101 | + run: pnpm --filter sentry run build -- --target ${{ matrix.target }} |
| 102 | + - name: Smoke test |
| 103 | + if: matrix.target == 'linux-x64' |
| 104 | + env: |
| 105 | + SENTRY_AUTH_TOKEN: "" |
| 106 | + SENTRY_TOKEN: "" |
| 107 | + SENTRY_CONFIG_DIR: ${{ runner.temp }}/.sentry-smoke |
| 108 | + run: | |
| 109 | + packages/cli/dist-bin/sentry-linux-x64 --help |
| 110 | + output=$(packages/cli/dist-bin/sentry-linux-x64 auth status 2>&1) && status=$? || status=$? |
| 111 | + test "$status" -eq 10 |
| 112 | + printf '%s\n' "$output" | grep -qi 'not authenticated' |
| 113 | + - name: Upload binary artifact |
| 114 | + uses: actions/upload-artifact@v4 |
| 115 | + with: |
| 116 | + name: sentry-${{ matrix.target }} |
| 117 | + path: | |
| 118 | + packages/cli/dist-bin/sentry-* |
| 119 | + !packages/cli/dist-bin/*.gz |
| 120 | + - name: Upload compressed artifact |
| 121 | + uses: actions/upload-artifact@v4 |
| 122 | + with: |
| 123 | + name: sentry-${{ matrix.target }}-gz |
| 124 | + path: packages/cli/dist-bin/*.gz |
| 125 | + |
| 126 | + build-npm: |
| 127 | + name: Build npm Package |
| 128 | + runs-on: ubuntu-latest |
| 129 | + environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/cli/')) && 'production' || '' }} |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v4 |
| 132 | + - uses: pnpm/action-setup@v4 |
| 133 | + - uses: actions/setup-node@v4 |
| 134 | + with: |
| 135 | + node-version: ${{ env.NODE_VERSION_22 }} |
| 136 | + cache: pnpm |
| 137 | + - name: Install dependencies |
| 138 | + run: pnpm install --frozen-lockfile |
| 139 | + - name: Bundle |
| 140 | + env: |
| 141 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 142 | + run: pnpm --filter sentry run bundle |
| 143 | + - name: Smoke test |
| 144 | + env: |
| 145 | + SENTRY_AUTH_TOKEN: "" |
| 146 | + SENTRY_TOKEN: "" |
| 147 | + SENTRY_CONFIG_DIR: ${{ runner.temp }}/.sentry-smoke |
| 148 | + run: node packages/cli/dist/bin.cjs --help |
| 149 | + - name: Pack |
| 150 | + working-directory: packages/cli |
| 151 | + run: npm pack |
| 152 | + - name: Upload npm artifact |
| 153 | + uses: actions/upload-artifact@v4 |
| 154 | + with: |
| 155 | + name: npm-package |
| 156 | + path: packages/cli/*.tgz |
| 157 | + |
| 158 | + test-npm: |
| 159 | + name: Test npm Package (Node ${{ matrix.node }}) |
| 160 | + needs: build-npm |
| 161 | + runs-on: ubuntu-latest |
| 162 | + strategy: |
| 163 | + fail-fast: false |
| 164 | + matrix: |
| 165 | + node: [20, 22, 24] |
| 166 | + steps: |
| 167 | + - uses: actions/checkout@v4 |
| 168 | + - uses: actions/setup-node@v4 |
| 169 | + with: |
| 170 | + node-version: ${{ matrix.node == 24 && env.NODE_VERSION_24 || matrix.node == 20 && env.NODE_VERSION_20 || env.NODE_VERSION_22 }} |
| 171 | + - name: Download npm artifact |
| 172 | + uses: actions/download-artifact@v4 |
| 173 | + with: |
| 174 | + name: npm-package |
| 175 | + path: packages/cli |
| 176 | + - name: Test packaged CLI |
| 177 | + env: |
| 178 | + SENTRY_AUTH_TOKEN: "" |
| 179 | + SENTRY_TOKEN: "" |
| 180 | + SENTRY_CONFIG_DIR: ${{ runner.temp }}/.sentry-smoke |
| 181 | + run: | |
| 182 | + package_file=$(find packages/cli -maxdepth 1 -name 'sentry-*.tgz' -print -quit) |
| 183 | + test -n "$package_file" |
| 184 | + npm install --ignore-scripts --prefix "$RUNNER_TEMP/npm-smoke" "$GITHUB_WORKSPACE/$package_file" |
| 185 | + node "$RUNNER_TEMP/npm-smoke/node_modules/sentry/dist/bin.cjs" --help |
| 186 | +
|
| 187 | + build-docs: |
| 188 | + name: Build Docs |
| 189 | + needs: build-binary |
| 190 | + runs-on: ubuntu-latest |
| 191 | + environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/cli/')) && 'production' || '' }} |
| 192 | + env: |
| 193 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 194 | + steps: |
| 195 | + - uses: actions/checkout@v4 |
| 196 | + - uses: pnpm/action-setup@v4 |
| 197 | + - uses: actions/setup-node@v4 |
| 198 | + with: |
| 199 | + node-version: ${{ env.NODE_VERSION_24 }} |
| 200 | + cache: pnpm |
| 201 | + - name: Install dependencies |
| 202 | + run: pnpm install --frozen-lockfile |
| 203 | + - name: Generate CLI docs |
| 204 | + run: pnpm --filter sentry run generate:schema && pnpm --filter sentry run generate:docs |
| 205 | + - name: Build docs |
| 206 | + run: pnpm --filter sentry-cli-docs run build |
| 207 | + - name: Download Linux binary |
| 208 | + uses: actions/download-artifact@v4 |
| 209 | + with: |
| 210 | + name: sentry-linux-x64 |
| 211 | + path: dist-bin |
| 212 | + - name: Inject debug IDs and upload sourcemaps |
| 213 | + if: github.event_name == 'push' && env.SENTRY_AUTH_TOKEN != '' |
| 214 | + env: |
| 215 | + SENTRY_ORG: sentry |
| 216 | + SENTRY_PROJECT: cli-website |
| 217 | + run: | |
| 218 | + chmod +x dist-bin/sentry-linux-x64 |
| 219 | + ./dist-bin/sentry-linux-x64 sourcemap inject apps/cli-docs/dist/ |
| 220 | + # shellcheck disable=SC2088 |
| 221 | + ./dist-bin/sentry-linux-x64 sourcemap upload apps/cli-docs/dist/ \ |
| 222 | + --release "$(node -p 'require("./packages/cli/package.json").version')" \ |
| 223 | + --url-prefix "~/" |
| 224 | + - name: Remove sourcemaps |
| 225 | + run: find apps/cli-docs/dist -name '*.map' -delete |
| 226 | + - name: Package docs |
| 227 | + run: | |
| 228 | + output_dir="$RUNNER_TEMP/vercel-output" |
| 229 | + rm -rf "$output_dir" |
| 230 | + mkdir -p "$output_dir/.vercel/output/static" |
| 231 | + cp -R apps/cli-docs/dist/. "$output_dir/.vercel/output/static/" |
| 232 | + printf '%s\n' '{"version":3}' > "$output_dir/.vercel/output/config.json" |
| 233 | + (cd "$output_dir" && zip -qr "$GITHUB_WORKSPACE/vercel.zip" .vercel) |
| 234 | + - name: Upload docs artifact |
| 235 | + uses: actions/upload-artifact@v4 |
| 236 | + with: |
| 237 | + name: vercel |
| 238 | + path: vercel.zip |
0 commit comments