Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Build and Publish package on tags #18

Build and Publish package on tags

Build and Publish package on tags #18

Workflow file for this run

name: Build and Publish package on tags
on:
push:
tags:
- 'v*'
env:
NODE_VERSION: '16.x'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
- name: Install dependencies and build
run: npm ci && npm run build
- name: Prepare Artifact
run: |
mkdir artifact
cp LICENSE README.md package.json artifact
cp -r dist artifact/dist
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: package
path: artifact
publish-to-npm-pkg-github-com:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ build ]
steps:
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: package
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://npm.pkg.github.com'
- name: Publish package to npm.pkg.github.com
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-to-registry-npmjs-org:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [ build ]
steps:
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: package
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Replace npm.pkg.github.com with registry.npmjs.org
run: sed -i 's/npm\.pkg\.github\.com/registry\.npmjs\.org/' package.json
- name: Publish package to registry.npmjs.org
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}