Skip to content

Release CI

Release CI #368

Workflow file for this run

name: Release CI
on:
push:
branches:
- main
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checking out for ${{ github.ref }}
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.X
- name: Update package version
run: npx version-from-git --no-git-tag-version
if: ${{ startsWith(github.ref, 'refs/heads/') }}
- name: Read package.json
id: read-package-json
run: |
echo "::set-output name=name::$(cat package.json | jq -r '.name')"
echo "::set-output name=version::$(cat package.json | jq -r '.version')"
- name: Install packages
run: npm install
- name: Build NPM packages
run: |
npm run build:tsc
- name: Npm packaging
run: npm pack
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.4.0
with:
name: npm-tarball
path: '*.tgz'
publish:
needs: build
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/download-artifact@v4.1.8
with:
name: npm-tarball
- name: Read package.json
id: read-package-json
run: |
echo "::set-output name=name::$(tar xOf *.tgz package/package.json | jq -r '.name')"
echo "::set-output name=version::$(tar xOf *.tgz package/package.json | jq -r '.version')"
echo "::set-output name=tarball::$(ls *.tgz)"
echo "::set-output name=date::$(date +%Y-%m-%d)"
- name: Run npm publish ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }}
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm publish *.tgz --tag main --access public
npm dist-tag add ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }} latest