Fix ci #6
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| env: | |
| BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Setup Node | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: .nvmrc | |
| cache: npm | |
| - name: Upgrade npm | |
| run: npm i -g npm@latest | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Ensure Bugsnag key exists | |
| run: | | |
| if [ -z "${BUGSNAG_API_KEY:-}" ]; then | |
| echo "BUGSNAG_API_KEY secret is required for release publishing." | |
| exit 1 | |
| fi | |
| - name: Inject Bugsnag API key into telemetry source | |
| run: | | |
| node -e ' | |
| const fs = require("fs"); | |
| const filePath = "cli/shared/telemetry/bugsnag-shared.ts"; | |
| const placeholder = "__ASO_PACKAGED_BUGSNAG_API_KEY__"; | |
| const key = (process.env.BUGSNAG_API_KEY || "").trim(); | |
| if (!key) { | |
| throw new Error("BUGSNAG_API_KEY secret is required for release publishing."); | |
| } | |
| const source = fs.readFileSync(filePath, "utf8"); | |
| const count = (source.match(new RegExp(placeholder, "g")) || []).length; | |
| if (count !== 1) { | |
| throw new Error(`Expected exactly 1 placeholder occurrence, found ${count}.`); | |
| } | |
| fs.writeFileSync(filePath, source.replace(placeholder, key), "utf8"); | |
| ' | |
| - name: Validate tag matches package version | |
| run: | | |
| PACKAGE_VERSION="$(node -p "require('./package.json').version")" | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then | |
| echo "Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)." | |
| exit 1 | |
| fi | |
| - name: Run CI checks | |
| run: npm run ci | |
| - name: Verify packaged key placeholder is absent from build artifacts | |
| run: | | |
| if grep -R --line-number "__ASO_PACKAGED_BUGSNAG_API_KEY__" cli/dist; then | |
| echo "Placeholder still present in build artifacts." | |
| exit 1 | |
| fi | |
| - name: Check if version is already published | |
| id: published | |
| run: | | |
| PACKAGE_NAME="$(node -p "require('./package.json').name")" | |
| PACKAGE_VERSION="$(node -p "require('./package.json').version")" | |
| PUBLISHED_VERSION="$(npm view "$PACKAGE_NAME" version 2>/dev/null || true)" | |
| if [ "$PUBLISHED_VERSION" = "$PACKAGE_VERSION" ]; then | |
| echo "already_published=true" >> "$GITHUB_OUTPUT" | |
| echo "$PACKAGE_NAME@$PACKAGE_VERSION is already published. Skipping publish." | |
| else | |
| echo "already_published=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Upload Bugsnag Node sourcemap | |
| if: steps.published.outputs.already_published != 'true' | |
| run: npm run upload-sourcemap | |
| - name: Publish to npm | |
| if: steps.published.outputs.already_published != 'true' | |
| run: npm publish --access public --provenance |