Skip to content

Release

Release #7

Workflow file for this run

name: Release
on:
workflow_run:
workflows: ["CI"]
types:
- completed
permissions:
contents: write
packages: write
jobs:
release:
# Only run if CI succeeded AND the ref is a tag
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && startsWith(github.event.workflow_run.head_branch, 'v') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
# Fix npm bug with optional dependencies
# see: https://github.com/hydephp/hyde/issues/289
- name: Remove node_modules and package-lock.json
run: rm -rf node_modules package-lock.json
- name: Clear npm cache
run: npm cache clean --force
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Build package
run: npm run build
- name: Publish to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.workflow_run.head_branch }}
name: Release ${{ github.event.workflow_run.head_branch }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}