Package release #11
This file contains 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
name: Package release | |
on: | |
workflow_dispatch: | |
inputs: | |
release-type: | |
description: "Release type (one of): major, minor, patch, prerelease" | |
required: true | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
- prerelease | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
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 | |
release: | |
needs: build | |
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: Set up Node.js env | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: "https://registry.npmjs.org" | |
- name: Pre-Release Version Upgrade | |
if: github.event.inputs.release-type == 'prerelease' | |
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: Release Version Upgrade | |
if: github.event.inputs.release-type != 'prerelease' | |
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: Changelog Update | |
uses: superfaceai/release-changelog-action@v3 | |
with: | |
path-to-changelog: CHANGELOG.md | |
version: ${{ env.NEW_VERSION }} | |
operation: release | |
- name: Git User Configuration | |
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 for Preceding Changes (package.json & CHANGELOG.md) and Tag Creation | |
run: | | |
git add "package.json" | |
git add "CHANGELOG.md" | |
git commit -m "chore: 🤖 release ${{ env.NEW_VERSION }}" | |
git tag ${{ env.NEW_VERSION }} | |
- name: Package Release | |
run: npm publish --provenance --access public --tag ${{ env.RELEASE_TAG }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Git Push to Repository | |
run: | | |
git push origin && git push --tags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Getting 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: Release Doc Update | |
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 }} |