CD - Validate and Create New Release #23
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
run-name: CD - Validate and Create New Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release: Syntax - (*.*.*)' | |
required: true | |
type: string | |
# Ensures that only one job group runs at a time to avoid resource waste | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
create-release: | |
name: Create New Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Retrieve current package version | |
id: package-version | |
run: | | |
current_version=$(jq -r '.version' package.json) | |
echo "Current version: $current_version" | |
echo "::set-output name=current_version::$current_version" | |
- name: Validate New Version | |
id: validate-version | |
run: node .github/scripts/comparePackageVersions.mjs ${{ steps.package-version.outputs.current_version }} ${{ github.event.inputs.version }} | |
- name: Create Release | |
id: create-release | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/{owner}/{repo}/releases | |
owner: ${{ github.repository_owner }} | |
repo: ${{ github.repository }} | |
tag_name: ${{ github.event.inputs.version }} | |
name: v${{ github.event.inputs.version }} | |
body: | | |
## Changes | |
- New version: ${{ github.event.inputs.version }} | |
- Previous version: ${{ steps.package-version.outputs.current_version }} | |
prerelease: false | |
generate_release_notes: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- 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 ci | |
- name: Publish Release | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |