-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create CD workflow for publishing to NPM registry
- Loading branch information
1 parent
3a057d9
commit bd6239b
Showing
2 changed files
with
44 additions
and
1 deletion.
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,43 @@ | ||
// .github/workflows.yml | ||
name: NPM publish CD workflow | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.release.target_commitish }} | ||
# install Node.js | ||
- name: Use Node.js 12 | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
- run: yarn install | ||
# set up git since we will later push to the repo | ||
- run: git config --global user.name "tsamantanis" | ||
- run: git config --global user.email "philip.tsamantanis@icloud.com" | ||
# upgrade npm version in package.json to the tag used in the release. | ||
- run: npm version ${{ github.event.release.tag_name }} | ||
# build the project | ||
- run: npm run build | ||
# run tests just in case | ||
- run: npm test | ||
- run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}" | ||
# publish to NPM -> there is one caveat, continue reading for the fix | ||
- run: npm publish --tag ${{ github.event.release.target_commitish }} | ||
# deploy example to GH pages | ||
- run: npm deploy | ||
env: | ||
# Use a token to publish to NPM. See below for how to set it up | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# push the version changes to GitHub | ||
- run: git push | ||
env: | ||
# The secret is passed automatically. Nothing to configure. | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.