Skip to content

Package release

Package release #16

Workflow file for this run

name: Package release
on:
workflow_dispatch:
inputs:
release-type:
description: "Release type (one of): major, minor, patch, premajor, preminor, prepatch, or prerelease"
required: true
type: choice
options:
- major
- minor
- patch
- premajor
- preminor
- prepatch
- prerelease
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: bun install --no-save
- name: Build
run: bun --bun run build
- name: Setup Node.js Env
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Bump Pre-Release Version
if: startsWith(github.event.inputs.release-type, 'pre')
run: |
{
echo 'NEW_VERSION<<EOF'
npm --no-git-tag-version --preid=beta version ${{ env.RELEASE_TYPE }}
echo EOF
} >> "$GITHUB_ENV"
echo "RELEASE_TAG=beta" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
- name: Bump Release Version
if: startsWith(github.event.inputs.release-type, 'pre') != true
run: |
{
echo 'NEW_VERSION<<EOF'
npm --no-git-tag-version version ${{ env.RELEASE_TYPE }}
echo EOF
} >> "$GITHUB_ENV"
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
- name: Update Changelog
uses: superfaceai/release-changelog-action@v3
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
operation: release
- name: Configure Git User's Info
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Git Commit Preceding Changes (package.json & CHANGELOG.md) and Create Git Tag
run: |
git add "package.json"
git add "CHANGELOG.md"
git commit -m "chore: 🤖 release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
- name: Publish Package
run: npm publish --provenance --access public --tag ${{ env.RELEASE_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Git Push Changes to Repository
run: |
git push origin && git push --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Changelog for Upcoming Version
id: get-changelog
uses: superfaceai/release-changelog-action@v3
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
operation: read
- name: Update Github Release Documentation
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.NEW_VERSION }}
body: ${{ steps.get-changelog.outputs.changelog }}
prerelease: ${{ github.event.inputs.release-type == 'prerelease' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}