Merge pull request #38 from chriscarrollsmith/correct-tool-doc #44
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
on: | |
push: | |
branches: | |
- '**' # Run on all branches | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'latest' | |
- run: npm ci | |
- run: npm install -g tsx | |
- run: npm run build | |
- run: npm test | |
publish: | |
needs: test | |
if: github.ref == 'refs/heads/main' # Only run this job on main branch | |
permissions: | |
packages: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for PR message extraction | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'latest' | |
- name: Get PR Message | |
id: pr_message | |
run: | | |
PR_NUMBER=$(git log -1 --pretty=%B | grep -oP '#\K\d+' || echo "") | |
if [ ! -z "$PR_NUMBER" ]; then | |
PR_MESSAGE=$(gh pr view $PR_NUMBER --json body -q .body || echo "") | |
echo "message<<EOF" >> $GITHUB_OUTPUT | |
echo "$PR_MESSAGE" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
else | |
echo "message=No PR message found" >> $GITHUB_OUTPUT | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: npm ci | |
- run: npm install -g tsx | |
- run: npm run build | |
- name: Publish to NPM | |
id: publish | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
- name: Get package version | |
if: steps.publish.outputs.type != 'none' | |
id: package_version | |
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
if: steps.publish.outputs.type != 'none' | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: v${{ steps.package_version.outputs.version }} | |
name: Release v${{ steps.package_version.outputs.version }} | |
body: | | |
${{ steps.pr_message.outputs.message }} | |
Package published to npm: ${{ steps.publish.outputs.version }} | |
draft: false | |
prerelease: false |