Release npm package to github and npm registry
This action was created to tackle Yarn2 mono-repos where individual workspace releases are required. It releases npm packages to github and npm registry based on provided semantic version, tag, and change log.
Use semrel-analyze to obtain these input values based on Conventional Commits.
name: ci-cd
on: [push]
jobs:
cd:
runs-on: ubuntu-latest
strategy:
max-parallel: 1 # to avoid git conflicts
matrix:
workspace:
- lib1
- lib2
- service
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: install node 16
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: analyze ${{ matrix.workspace }}
id: analyze
uses: rotorsoft/semrel-analyze@v1
with:
package: "@rotorsoft/${{ matrix.workspace }}"
directory: "workspace/${{ matrix.workspace }}"
- name: release ${{ matrix.workspace }}
uses: rotorsoft/semrel-release@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
npm-registry: "registry.npmjs.org"
npm-token: "${{ secrets.NPM_TOKEN }}"
npm-access: "public"
user: "rotorsoft"
email: "rotorsoft@outlook.com"
package: "@rotorsoft/${{ matrix.workspace }}"
directory: "workspace/${{ matrix.workspace }}"
tag: "${{ steps.analyze.outputs.next-tag }}"
version: "${{ steps.analyze.outputs.next-version }}"
change-log: "${{ steps.analyze.outputs.change-log }}"- v2: adding GITHUB_REF when pulling and pushing changes
- v3.0.0: adding pnpm support
git tag -a v1.1.0 -m "Release v1.1.0"
git push origin v1.1.0