Skip to content

Release

Release #12

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release type (one of): patch, minor, major'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: package.json
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run build
# Needed for creating the tag
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Bump package version
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ github.event.inputs.release-type }})" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
# Update changelog unreleased section with new version
- name: Update changelog
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
operation: release
- name: Commit and tag changes
run: |
git add "package.json"
git add "CHANGELOG.md"
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push origin && git push --tags
- id: get-changelog
name: Get version changelog
uses: superfaceai/release-changelog-action@v1
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
operation: read
- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish npm package
run: |
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
npm publish --verbose --access=public --tag=${{ env.RELEASE_TAG }}
env:
NPM_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}