Skip to content

release

release #15

Workflow file for this run

name: Publish Package to npmjs
on:
workflow_run:
workflows: ["Test Pipeline"]
types:
- completed
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install
run: npm install
- name: Run build
run: npm run build
release:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Build package
run: npm run build
- name: Publish package
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Get version from package.json
id: get_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create GitHub tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ env.VERSION }}" -m "Release version ${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub release
uses: actions/create-release@v1
with:
tag_name: "v${{ env.VERSION }}"
release_name: "Release v${{ env.VERSION }}"
body: "Automatic release of version v${{ env.VERSION }}."
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}