|
| 1 | +name: "@razroo/ray-task-profiles Release to npm" |
| 2 | + |
| 3 | +# Publish when a GitHub Release whose tag starts with `task-profiles-v` is published. |
| 4 | +# |
| 5 | +# Cut releases with the guarded helper from main: |
| 6 | +# bun run release:github -- --dry-run |
| 7 | +# bun run release:github -- --yes |
| 8 | + |
| 9 | +on: |
| 10 | + release: |
| 11 | + types: [published] |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + id-token: write |
| 16 | + |
| 17 | +env: |
| 18 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + working-directory: packages/task-profiles |
| 23 | + |
| 24 | +jobs: |
| 25 | + publish: |
| 26 | + if: github.repository == 'razroo/ray' && startsWith(github.ref_name, 'task-profiles-v') |
| 27 | + runs-on: ubuntu-latest |
| 28 | + timeout-minutes: 60 |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v5 |
| 31 | + |
| 32 | + - uses: actions/setup-node@v5 |
| 33 | + with: |
| 34 | + node-version: "22" |
| 35 | + registry-url: "https://registry.npmjs.org" |
| 36 | + package-manager-cache: false |
| 37 | + |
| 38 | + - uses: oven-sh/setup-bun@v2 |
| 39 | + with: |
| 40 | + bun-version: "1.3.9" |
| 41 | + |
| 42 | + - name: Set version from release tag |
| 43 | + run: | |
| 44 | + VERSION="${GITHUB_REF_NAME#task-profiles-v}" |
| 45 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 46 | +
|
| 47 | + - name: Verify release commit is on main |
| 48 | + working-directory: . |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + SHA="$(git rev-parse HEAD)" |
| 52 | + if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then |
| 53 | + timeout 120s git fetch --no-tags --prune --unshallow origin main:refs/remotes/origin/main |
| 54 | + else |
| 55 | + timeout 120s git fetch --no-tags --prune origin main:refs/remotes/origin/main |
| 56 | + fi |
| 57 | + if ! git merge-base --is-ancestor "$SHA" refs/remotes/origin/main; then |
| 58 | + echo "::error::Release tag ${GITHUB_REF_NAME} (${SHA}) must point at a commit on main." |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Verify Quality checks passed for release commit |
| 63 | + env: |
| 64 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + working-directory: . |
| 66 | + run: | |
| 67 | + SHA=$(git rev-parse HEAD) |
| 68 | + echo "Verifying Quality checks status for $SHA" |
| 69 | + DEADLINE=$(( $(date +%s) + 1800 )) |
| 70 | + STATUS="" |
| 71 | + CONCLUSION="" |
| 72 | + while [ "$(date +%s)" -lt "$DEADLINE" ]; do |
| 73 | + CHECK_RUN="$(timeout 30s gh api "repos/${{ github.repository }}/commits/$SHA/check-runs" \ |
| 74 | + --jq '[.check_runs[] | select(.name == "quality")] | sort_by(.started_at) | last | "\(.status // "missing") \(.conclusion // "null")"' || true)" |
| 75 | + read -r STATUS CONCLUSION <<<"$CHECK_RUN" |
| 76 | + STATUS="${STATUS:-missing}" |
| 77 | + CONCLUSION="${CONCLUSION:-null}" |
| 78 | + echo "quality check-run: status=$STATUS conclusion=$CONCLUSION" |
| 79 | + if [ "$STATUS" = "completed" ]; then |
| 80 | + break |
| 81 | + fi |
| 82 | + sleep 15 |
| 83 | + done |
| 84 | + if [ "$STATUS" != "completed" ]; then |
| 85 | + echo "::error::Quality checks for $SHA never completed within 30min (last status: $STATUS)." |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | + if [ "$CONCLUSION" != "success" ]; then |
| 89 | + echo "::error::Quality checks for $SHA did not succeed (conclusion: $CONCLUSION). Fix before re-releasing." |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | + echo "Quality checks succeeded for $SHA" |
| 93 | +
|
| 94 | + - name: Verify package.json version matches release tag |
| 95 | + working-directory: . |
| 96 | + run: timeout 60s bun ./scripts/release/check-source.mjs "$VERSION" |
| 97 | + |
| 98 | + - name: Install (workspace root) |
| 99 | + run: timeout 300s bun install --frozen-lockfile |
| 100 | + working-directory: . |
| 101 | + |
| 102 | + - name: Build |
| 103 | + run: timeout 300s bun run build |
| 104 | + working-directory: . |
| 105 | + |
| 106 | + - name: Pack package |
| 107 | + id: pack |
| 108 | + run: | |
| 109 | + set -euo pipefail |
| 110 | + PACK_DIR="$RUNNER_TEMP/ray-packs" |
| 111 | + timeout 60s rm -rf "$PACK_DIR" |
| 112 | + timeout 30s mkdir -p "$PACK_DIR" |
| 113 | + timeout 120s bun pm pack --destination "$PACK_DIR" |
| 114 | + TARBALL="$(timeout 30s find "$PACK_DIR" -name '*.tgz' -print -quit)" |
| 115 | + if [ -z "$TARBALL" ]; then |
| 116 | + echo "::error::Bun did not produce a package tarball." |
| 117 | + exit 1 |
| 118 | + fi |
| 119 | + echo "tarball=$TARBALL" >> "$GITHUB_OUTPUT" |
| 120 | +
|
| 121 | + - name: Publish to npm (with provenance) |
| 122 | + working-directory: . |
| 123 | + run: timeout 300s npm publish "${{ steps.pack.outputs.tarball }}" --access public --provenance |
| 124 | + env: |
| 125 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments