forked from jacobrosenthal/js-stk500v1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add GitHub workflows for version tagging and package publishing
- Loading branch information
1 parent
4a366b8
commit cd986d1
Showing
4 changed files
with
116 additions
and
52 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Tag and Publish Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
tag: | ||
name: Tag new version | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_tag: ${{ steps.tag.outputs.new_tag }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get current version from package.json | ||
id: version | ||
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT | ||
|
||
- name: Check if tag already exists | ||
id: check | ||
run: | | ||
if git rev-list -n 1 "v${{ steps.version.outputs.version }}"; then | ||
echo "exists=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "exists=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Tag new version | ||
id: tag | ||
if: ${{ steps.check.outputs.exists == 'false' }} | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
custom_tag: ${{ steps.version.outputs.version }} | ||
|
||
build-and-publish: | ||
name: Build and publish package | ||
runs-on: ubuntu-latest | ||
needs: tag | ||
if: ${{ needs.tag.outputs.new_tag }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: .nvmrc | ||
registry-url: https://registry.npmjs.org | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Publish to the npm registry | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
* | ||
!dist | ||
!dist/** | ||
!package.json | ||
!README.md | ||
!LICENSE |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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