extends/.github/workflows/publish.yml

39 lines
1.0 KiB
YAML

name: Publish package
on:
release:
types: [ published ]
jobs:
publishpackage:
runs-on: ubuntu-latest
name: Publish
steps:
- uses: actions/checkout@v4
name: Code checkout
with:
persist-credentials: true
ref: main
fetch-depth: 2
# Install basic tools
- uses: actions/setup-node@v4
name: Setup node.js
with:
registry-url: https://registry.npmjs.org/
node-version: latest
- name: Edit version and install depencies
run: |
sudo npm i -g semver
VERSION="$(semver -c ${{ github.ref_name }})"
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
jq --arg ver $VERSION '.version = $ver' package.json > package2.json
mv -fv package2.json package.json
# Install depencides and build
npm install --no-save
# Publish npm
- run: npm publish --access public --tag ${{ github.event.release.prerelease && 'next' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}