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

publish to github package repo on new version #77

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
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
46 changes: 40 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,51 @@ jobs:
with:
node-version: latest

- run: npm ci
- run: npm run compile
- run: npm run lint
- run: npm test
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Compile the typescript
run: npm run compile

- name: Lint the code
run: npm run lint

- name: Run the tests
run: npm test

- name: Check for version change
id: version-check
run: |
[ "$(git show head^:package.json | jq .version)" = "$(cat package.json| jq .version)" ] && echo "::set-output name=version_changed::true" || echo "::set-output name=version_changed::false"

- name: Copy relevant documentation into the build folder
if: steps.version-check.outputs.version_changed == 'true'
run: cp package.json README.md LICENSE-APACHE LICENSE-MIT ./build
- name: publish to npmjs

- name: Publish to npmjs
uses: JS-DevTools/npm-publish@v1
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/master' && steps.version-check.outputs.version_changed == 'true'
with:
token: ${{ secrets.NPM_TOKEN }}
package: build/package.json
# don't try and deploy if versions haven't changed
check-version: true

- name: Create tag variable
id: tagging
if: github.ref == 'refs/heads/master' && steps.version-check.outputs.version_changed == 'true'
run: echo "::set-output name=new_tag::v$(cat package.json | jq .version | sed "s/['\"]//g")"

- name: Create a GitHub release
if: github.ref == 'refs/heads/master' && steps.version-check.outputs.version_changed == 'true'
uses: ncipollo/release-action@v1
with:
custom_tag: ${{ steps.tagging.outputs.new_tag }}
name: Release ${{ steps.tagging.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"clean": "rm -rf ./build/* && rm -rf lib/version.ts",
"precompile": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > lib/version.ts",
"compile": "npm run precompile && tsc --project tsconfig.json",
"publish:github": "npm publish --registry https://npm.pkg.github.com",
"test": "jest --verbose ./test/**.test.ts",
"lint": "eslint ./{lib,test}/*.ts",
"lint:fix": "eslint ./{lib,test}/*.ts --fix"
Expand Down
Loading