Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: set up NPM auto publish on new package version #150

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/publish-on-version-change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: publish-on-version-change
on:
push:
branches:
- chore/auto_publish # Change this to your default branch
jobs:
check-version-change:
name: check-version-change
runs-on: ubuntu-latest
outputs:
did-version-change: ${{ steps.check.outputs.changed }}
new-version: ${{ steps.check.outputs.version }}
type: ${{ steps.check.outputs.type }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

# Determine if version has changed
- name: Check version changes
uses: EndBug/version-check@v2
id: check

publish-to-npm:
name: publish-to-npm
runs-on: ubuntu-latest
needs: [check-version-change]
if: needs.check-version-change.outputs.did-version-change == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v2

# Draft a release if version name changed
- name: Draft release
run: 'gh release create v${{ needs.check-version-change.outputs.new-version }} -d --title "Release ${{ needs.check-version-change.outputs.new-version }}" --generate-notes'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Node.js for NPM
uses: actions/setup-node@v4
with:
registry-url: "https://registry.npmjs.org"

- name: Build lib
run: "npm i && npm run buildLib"

- name: Publish package to NPM
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
Loading