Skip to content

Publish

Publish #266

Workflow file for this run

name: Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
workflow_dispatch:
jobs:
get_dist_tag:
runs-on: ubuntu-latest
outputs:
DIST_TAG: ${{ steps.get_tag.outputs.DIST_TAG }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Get the tag name
id: get_tag
run: |
tag=$(echo ${GITHUB_REF/refs\/tags\//} | cut -c 2-)
dist_tag=$([[ $tag =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo latest || echo "")
dist_tag=$([[ $tag =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]] && echo rc || echo $dist_tag)
dist_tag=$([[ $tag =~ ^[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+$ ]] && echo beta || echo $dist_tag)
[ -z "$dist_tag" ] && echo "Distribution tag is not set to latest nor to rc or beta" && exit 1
echo ::set-output name=DIST_TAG::$dist_tag
shell: bash
publish:
runs-on: ubuntu-latest
needs: get_dist_tag
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: git status
- name: Publish to npm
run: npm run publish -- --tag ${{ needs.get_dist_tag.outputs.DIST_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
release:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: ${{ !contains(needs.get_dist_tag.outputs.DIST_TAG, '-') }}
prerelease: ${{ contains(needs.get_dist_tag.outputs.DIST_TAG, '-') }}