Skip to content

Commit

Permalink
infra: add publish workflow (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Mar 2, 2024
1 parent 7df5c6c commit ba23dec
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish

on:
workflow_dispatch:

jobs:
release:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: Release
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0

- name: Set node version to 20
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: 20
cache: 'pnpm'

- name: Prepare
run: pnpm install --frozen-lockfile

- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish
run: |
PACKAGE_DIST_TAG=$(node -e "console.log(/^\d+\.\d+\.\d+(\-(\w+)\.\d+)$/.exec(require('./package.json').version)?.[2] || 'latest')")
pnpm publish --access public --tag $PACKAGE_DIST_TAG

0 comments on commit ba23dec

Please sign in to comment.