Publish Package #2
This file contains hidden or 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
# This workflow will run tests using node and then publish a package to GitHub Packages when a tag is pushed | |
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
name: Publish Package | |
on: | |
push: | |
tags: ['*'] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Write .npmrc file | |
run: | | |
echo //npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }} > $HOME/.npmrc | |
echo @rundown-studio:registry=https://npm.pkg.github.com >> $HOME/.npmrc | |
- name: Install Dependencies | |
run: npm ci --loglevel=error | |
- name: Compile Typescript | |
run: npm run build | |
- name: Upload Build Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
timezone: [UTC, America/Los_Angeles, Europe/Berlin, Australia/Sydney] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Write .npmrc file | |
run: | | |
echo //npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }} > $HOME/.npmrc | |
echo @rundown-studio:registry=https://npm.pkg.github.com >> $HOME/.npmrc | |
- name: Install Dependencies | |
run: npm install | |
- name: Run Unit Tests | |
run: npm run test:ci 2>&1 | tee $GITHUB_STEP_SUMMARY; exit ${PIPESTATUS[0]} | |
env: | |
TZ: ${{ matrix.timezone }} | |
NODE_OPTIONS: --experimental-vm-modules | |
publish: | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: https://npm.pkg.github.com/ | |
- name: Publish Package | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |