Skip to content

Release 2.0.0 (#4)

Release 2.0.0 (#4) #1

Workflow file for this run

name: Release Workflow
on:
push:
tags:
- "v*"
branches:
- release
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Install Dependencies
run: npm ci
- name: Verify Package Version
run: |
tag_version=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
package_version=$(node -p "require('./package.json').version")
if [ "$tag_version" != "$package_version" ]; then
echo "Error: package.json version ($package_version) does not match tag version ($tag_version)"
exit 1
fi
- name: Verify Package Lock Version
run: |
tag_version=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
lockfile_version=$(node -p "require('./package-lock.json').version")
if [ "$tag_version" != "$lockfile_version" ]; then
echo "Error: package-lock.json version ($lockfile_version) does not match tag version ($tag_version)"
exit 1
fi
- name: Build
run: npm run build
- name: Get Previous Release Tag
id: get_previous_release_tag
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: releases } = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1,
});
return releases[0].tag_name;
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref }}
body: |
Changes in this Release:
$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ steps.get_previous_release_tag.outputs.result }})..HEAD)
draft: false
prerelease: false
- name: Publish to NPM
uses: js-actions/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: "public"