Skip to content

Commit

Permalink
feature: add github workflow for publishing to npm (#60)
Browse files Browse the repository at this point in the history
* feature: add github workflow for publishing to npm
* feature: add release docs
* fix: remove version from "package.json"
  • Loading branch information
Hayden authored Aug 21, 2023
1 parent cb75021 commit 9d6d595
Show file tree
Hide file tree
Showing 5 changed files with 8,270 additions and 32,602 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish to NPM
run-name: Publish release ${{ github.event.release.tag_name }} to NPM

on:
release:
types: [released] # A release was published, or a pre-release was changed to a release. https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads?actionType=released#release

jobs:
publish:
name: Publish to NPM
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Check Input
run: echo "Release Tag - ${{ github.event.release.tag_name }}"

- name: Validate Tag
run: |
if [[ "${{ github.event.release.tag_name }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag ${{ github.event.release.tag_name }} is valid"
else
echo "Tag is invalid"
exit 1
fi
- name: Clean Tag
id: clean-tag
run: |
echo "::set-output name=TAG::$(grep -Eo '[^v]?[0-9]+\.[0-9]+\.[0-9]+$' <<< '${{ github.event.release.tag_name }}')"
- name: Validated Tag
run: echo "package.json version - ${{ steps.clean-tag.outputs.TAG }}"

- name: Setup node
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org/

- name: Update package.json version
run: |
tmp=$(mktemp)
jq '.version = "${{ steps.clean-tag.outputs.TAG }}"' ./package.json > "$tmp" && mv "$tmp" ./package.json
- name: Publish package
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.PLATFORM_SA_NPM_TOKEN }}
access: public
tag: "latest"
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.1
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ git push origin <your-branch-name>
**IMPORTANT**: Please make sure to read through the [cla](cla.txt) file as part of opening a pull request.

9. We will review the pull requests and request any necessary changes. If all the checks (linting, compilation, tests) pass and everything looks good, your code will be merged into the original repository. Congratulations, and thank you for your contribution!

## Releasing
To release the package to NPM, simply create a new GitHub release and the "Publish to NPM" GitHub action will release it to NPM.
Loading

0 comments on commit 9d6d595

Please sign in to comment.