Skip to content

Merge pull request #2 from Tracktor/fix/change-to-gh #1

Merge pull request #2 from Tracktor/fix/change-to-gh

Merge pull request #2 from Tracktor/fix/change-to-gh #1

Workflow file for this run

name: Release
on:
push:
branches:
- main
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Run lint & tests
run: bun run test
- name: Bump version & generate changelog
run: npx standard-version --release-as auto
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push changes & tags
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git push --follow-tags origin main
- name: Build project
run: bun run build
- name: Check if version already exists on npm
run: |
PKG_NAME=$(jq -r .name package.json)
VERSION=$(jq -r .version package.json)
if npm view $PKG_NAME versions --json | grep -q "\"$VERSION\""; then
echo "⚠️ Version $VERSION already exists on npm. Skipping publish."
exit 0
fi
- name: Get version from package.json
id: get_version
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.version }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to npm
run: bun publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}