Skip to content

Commit

Permalink
feat: add GitHub workflows for version tagging and package publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
barrenechea committed Oct 7, 2024
1 parent 4a366b8 commit cd986d1
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 52 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/tag-and-publish.yml
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 }}
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*
!dist
!dist/**
!package.json
!README.md
!LICENSE
98 changes: 49 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/barrenechea/stk500-esm"
"url": "git+https://github.com/barrenechea/stk500-esm.git"
},
"keywords": [
"arduino",
Expand All @@ -34,6 +34,6 @@
"serialport": "^12.0.0",
"tsx": "^4.19.1",
"typescript": "^5.6.2",
"typescript-eslint": "^8.8.0"
"typescript-eslint": "^8.8.1"
}
}

0 comments on commit cd986d1

Please sign in to comment.