Skip to content

ci: update version with tag name #20

ci: update version with tag name

ci: update version with tag name #20

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release'
required: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Extract version from tag or dispatch
id: get_version
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "Version from tag ${GITHUB_REF##*/}"
echo "::set-output name=version::${GITHUB_REF##*/v}"
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "Version from dispatch input ${{ github.event.inputs.version }}"
echo "::set-output name=version::${{ github.event.inputs.version }}"
fi
- name: Update version in package.json
run: npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version
- name: Build
run: npm run build
- name: Authenticate with npm registry
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
- name: Config npm
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --no-git-checks