Skip to content

Publish Release

Publish Release #2

Workflow file for this run

name: Publish Release
on:
release:
types: [published]
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Restore node_modules cache
uses: actions/cache/restore@v3
id: cache
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Cache node modules
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
build:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Unpack node_modules
uses: actions/cache/restore@v3
id: cache
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
- name: Build
run: npm run build
publish:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Unpack node_modules
uses: actions/cache/restore@v3
id: cache
with:
path: node_modules
key: timestamp${{ hashFiles('package-lock.json') }}
- name: Update version
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
VERSION=${GITHUB_REF#refs/tags/v}
npm version $VERSION --no-git-tag-version --allow-same-version
git add package.json
git commit -m "chore(release): ${VERSION} [skip ci]"
git push
- name: Build and publish
run: |
npm run build
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}