-
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.
👷 Add CI pipeline for package publishing
- Loading branch information
1 parent
3bdb27b
commit efd3af5
Showing
2 changed files
with
78 additions
and
0 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,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
trim_trailing_whitespace = true |
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,69 @@ | ||
name: Build and publish npm package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Create build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build library | ||
run: | | ||
npm run build | ||
- name: Store build artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build | ||
path: build/ | ||
retention-days: 1 | ||
|
||
publish: | ||
name: Publish the NPM package | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
|
||
# do not publish in forks or non-tag pushes | ||
if: startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'open-formulieren' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: npm | ||
registry-url: 'https://registry.npmjs.org' | ||
scope: '@open-formulieren' | ||
|
||
- name: Download build artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build | ||
path: build/ | ||
|
||
- name: Publish package to NPM | ||
run: | | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
npm publish --access public --new-version=$VERSION | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |