Publish Package to github packages #5
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: Publish Package to github packages | |
on: | |
workflow_dispatch: | |
inputs: | |
semver: | |
type: choice | |
required: true | |
default: patch | |
options: [patch, minor, major] | |
description: The semver of the release. | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
pull-requests: write | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
# Setup .npmrc file to publish to GitHub Packages | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://npm.pkg.github.com' | |
# Defaults to the user or organization that owns the workflow file | |
scope: '@qualipool' | |
###### | |
## Calculate next version based on user semver input | |
## Update version and create tag and push to main | |
###### | |
- name: Calculate next version based on semver input | |
id: next_version | |
uses: zwaldowski/semver-release-action@a6a8309186ccf60c52ea2463a723c78d3b924577 # v4 | |
with: | |
dry_run: true | |
per_branch: true | |
bump: ${{ github.event.inputs.semver }} | |
github_token: ${{ github.token }} | |
- name: Bump version in package.json | |
uses: reedyuk/npm-version@15e0d016f632fe38bbb704910b8359f23262deb7 # 1.2.2 | |
with: | |
version: ${{ steps.next_version.outputs.version }} | |
- name: Commit files, create tag and push to remote | |
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 | |
with: | |
message: ${{ steps.next_version.outputs.version }} | |
default_author: user_info | |
push: 'true' | |
tag: v${{ steps.next_version.outputs.version }} | |
github_token: ${{ github.token }} | |
###### | |
## Build package and publish it to GitHub packages | |
###### | |
- run: npm ci | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |