This repository has been archived by the owner on May 16, 2024. It is now read-only.
Publish to NPM #70
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
name: Publish to NPM | |
on: | |
push: | |
tags: | |
- 'v[0-9] .[0-9] .[0-9] *' | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to publish' | |
required: true | |
type: string | |
jobs: | |
packages: | |
name: Packages | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Check Input | |
run: echo "Version - ${{github.event.inputs.tag}}" | |
- name: Read .nvmrc | |
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | |
id: nvm | |
- name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ steps.nvm.outputs.NODE_VERSION }} | |
registry-url: https://registry.npmjs.org/ | |
- name: Install yarn | |
run: npm install -g yarn | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build | |
- name: Update package.json version for alpha, beta releases | |
if: ${{ contains(github.event.inputs.tag, 'alpha') || contains(github.event.inputs.tag, 'beta') }} | |
run: | | |
tmp=$(mktemp) | |
jq '.version = "${{github.event.inputs.tag}}"' ./package.json > "$tmp" && mv "$tmp" ./package.json | |
- name: Publish package | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.PLATFORM_SA_NPM_TOKEN }} | |
access: public | |
tag: ${{ (contains(github.event.inputs.tag, 'alpha') && 'alpha') || (contains(github.event.inputs.tag, 'beta') && 'beta') || 'latest' }} |