| @@ -0,0 +1,78 @@ |
| 1 | +name: Publish Executor Package |
| 2 | +run-name: "${{ format('publish executor {0}', github.ref_name) }}" |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + id-token: write |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: publish-executor-package-${{ github.ref }} |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Require default branch |
| 24 | + if: github.ref_name != github.event.repository.default_branch |
| 25 | + run: | |
| 26 | + echo "Publish from ${GITHUB_REF_NAME} is blocked; use ${DEFAULT_BRANCH}." >&2 |
| 27 | + exit 1 |
| 28 | + env: |
| 29 | + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} |
| 30 | + |
| 31 | + - name: Setup Bun |
| 32 | + uses: oven-sh/setup-bun@v2 |
| 33 | + |
| 34 | + - name: Setup Node |
| 35 | + uses: actions/setup-node@v4 |
| 36 | + with: |
| 37 | + node-version: 22 |
| 38 | + registry-url: https://registry.npmjs.org |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + run: bun install --frozen-lockfile |
| 42 | + |
| 43 | + - name: Resolve package version |
| 44 | + id: version |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + set -euo pipefail |
| 48 | + version="$(node -p "require('./apps/executor/package.json').version")" |
| 49 | + |
| 50 | + if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 51 | + echo "apps/executor/package.json version is not semver: ${version}" >&2 |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + |
| 55 | + echo "version=${version}" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Publishing executor@${version}" |
| 57 | + |
| 58 | + - name: Ensure version is unpublished |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + set -euo pipefail |
| 62 | + |
| 63 | + if npm view "executor@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; then |
| 64 | + echo "executor@${{ steps.version.outputs.version }} is already published" >&2 |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + |
| 68 | + - name: Run executor checks |
| 69 | + run: | |
| 70 | + bun run --cwd apps/executor typecheck |
| 71 | + bun run --cwd apps/executor test |
| 72 | + |
| 73 | + - name: Build distribution package |
| 74 | + run: bun run --cwd apps/executor build:dist |
| 75 | + |
| 76 | + - name: Publish to npm |
| 77 | + working-directory: apps/executor |
| 78 | + run: npm publish ./dist/npm --access public --provenance |