name: Release Alpha on: issue_comment: types: - created concurrency: group: release-alpha-pr-${{ github.event.issue.number }} cancel-in-progress: true permissions: contents: read pull-requests: write jobs: publish-alpha: name: Publish alpha to npm if: | github.event.issue.pull_request && ( github.event.comment.body == 'release-alpha' || github.event.comment.body == '/release-alpha' ) && ( github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' ) runs-on: ubuntu-latest steps: - name: Get PR details id: pr uses: actions/github-script@v9 with: script: | const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number, }); if (pr.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`) { core.setFailed("Alpha releases from fork PRs are not supported."); return; } core.setOutput("sha", pr.head.sha); core.setOutput("number", String(pr.number)); - name: Checkout uses: actions/checkout@v7 with: ref: ${{ steps.pr.outputs.sha }} - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24 cache: npm registry-url: https://registry.npmjs.org - name: Install dependencies run: npm ci - name: Test run: npm test - name: Build run: npm run build - name: Resolve alpha version id: version run: | BASE_VERSION=$(node -p "require('./package.json').version") ALPHA_VERSION="${BASE_VERSION}-alpha.pr${{ steps.pr.outputs.number }}.${GITHUB_RUN_NUMBER}" echo "version=${ALPHA_VERSION}" >> "$GITHUB_OUTPUT" - name: Publish alpha run: | npm version "${{ steps.version.outputs.version }}" --no-git-tag-version npm publish --tag alpha --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Add install instructions to job summary run: | { echo "## Alpha release published" echo "" echo "Install this PR build:" echo "" echo '```bash' echo "npm install @thiagopi/ts-utils-kit@${{ steps.version.outputs.version }}" echo '```' echo "" echo "Or install the latest alpha tag:" echo "" echo '```bash' echo "npm install @thiagopi/ts-utils-kit@alpha" echo '```' } >> "$GITHUB_STEP_SUMMARY" - name: Comment alpha install instructions on PR uses: peter-evans/create-or-update-comment@v5 with: issue-number: ${{ steps.pr.outputs.number }} edit-mode: replace commit-sha: ${{ steps.pr.outputs.sha }} body: | ## Alpha release published Triggered by `@${{ github.event.comment.user.login }}` with \`release-alpha\`. Install this PR build: ```bash npm install @thiagopi/ts-utils-kit@${{ steps.version.outputs.version }} ``` Or install the latest alpha tag: ```bash npm install @thiagopi/ts-utils-kit@alpha ```