Skip to content

Release CommitReel to npm #4

Release CommitReel to npm

Release CommitReel to npm #4

name: Release CommitReel to npm
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (build but do not publish)'
required: false
type: boolean
default: false
push:
tags:
- 'commitreel-v*'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Determine workdir
run: |
if [ -f repl-tape/package.json ]; then
echo "WORKDIR=repl-tape" >> $GITHUB_ENV
else
echo "WORKDIR=." >> $GITHUB_ENV
fi
- name: Install dependencies
run: npm ci
working-directory: ${{ env.WORKDIR }}
- name: Sanity check
run: node ./bin/commitreel.js --help
working-directory: ${{ env.WORKDIR }}
- name: Package dry run
run: npm pack --dry-run
working-directory: ${{ env.WORKDIR }}
release:
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Determine workdir
run: |
if [ -f repl-tape/package.json ]; then
echo "WORKDIR=repl-tape" >> $GITHUB_ENV
else
echo "WORKDIR=." >> $GITHUB_ENV
fi
- name: Install dependencies
run: npm ci
working-directory: ${{ env.WORKDIR }}
- name: Publish to npm
if: ${{ !inputs.dry_run }}
run: npm publish --provenance --access public
working-directory: ${{ env.WORKDIR }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Dry run publish
if: ${{ inputs.dry_run }}
run: npm publish --dry-run
working-directory: ${{ env.WORKDIR }}
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/commitreel-v')
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}