Build, Release and Publish #4
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
name: Build, Release and Publish | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'package.json' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
packages: read | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: latest | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install dependencies | |
run: bun install | |
- name: Build package | |
run: bun run build | |
- name: Extract version from package.json | |
id: get_version | |
run: | | |
version=$(node -p 'require("./package.json").version') | |
echo "current-version=$version" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ steps.get_version.outputs.current-version }} | |
name: Release v${{ steps.get_version.outputs.current-version }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to NPM | |
run: bun run publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |