Skip to content

📦 Fix distributing the build files #3

📦 Fix distributing the build files

📦 Fix distributing the build files #3

Workflow file for this run

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 }}