Tag rc3 (#594) #32
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 NPM Package | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Version to simulate, e.g. v0.3.0-rc1" | |
| required: true | |
| dry_run: | |
| description: "Skip actual publish" | |
| type: boolean | |
| default: true | |
| # https://docs.npmjs.com/trusted-publishers | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check versions align | |
| if: github.ref_type == 'tag' || inputs.tag | |
| shell: python | |
| env: | |
| TAG: ${{ inputs.tag || github.ref_name }} | |
| run: | | |
| import json, os, re | |
| from pathlib import Path | |
| tag = os.environ["TAG"].removeprefix("v") | |
| js = json.loads(Path("popcorn/js/package.json").read_text())["version"] | |
| ex = re.search(r'@version\s+"([^"]+)"', Path("popcorn/elixir/mix.exs").read_text()).group(1) | |
| versions = {"tag": tag, "js": js, "elixir": ex} | |
| core = {k: re.split(r"[-+]", v, 1)[0] for k, v in versions.items()} | |
| print(versions) | |
| if len(set(core.values())) != 1: | |
| raise SystemExit(f"version mismatch (ignoring pre-release): {versions}") | |
| - name: Build Docker image | |
| run: docker build -t popcorn-builder -f docker/release.Dockerfile --build-arg GIT_REF=${{ github.ref_name }} . | |
| - name: Run Docker container and extract built artifacts | |
| run: | | |
| docker create --name popcorn-build popcorn-builder | |
| docker cp popcorn-build:/output/ ./popcorn/js/ | |
| docker rm popcorn-build | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Publish to NPM | |
| env: | |
| DRY_RUN_FLAG: ${{ inputs.dry_run && '--dry-run' || '' }} | |
| PROVENANCE_FLAG: ${{ inputs.dry_run && '' || '--provenance' }} | |
| run: | | |
| npm publish "$(ls swmansion-popcorn-*.tgz)" $PROVENANCE_FLAG --access public --tag latest $DRY_RUN_FLAG | |
| working-directory: ./popcorn/js/output |