Dispatch publish release #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: Dispatch publish release | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
type: choice | |
description: 'Package to release' | |
required: true | |
options: | |
- core | |
- embed | |
level: | |
type: choice | |
description: Select the release update level | |
options: | |
- major | |
- minor | |
- patch | |
- prerelease | |
- premajor | |
- preminor | |
- prepatch | |
preid: | |
type: choice | |
required: false | |
description: Select pre-id (alpha | beta) | |
default: 'none' | |
options: | |
- alpha | |
- beta | |
registry: | |
type: choice | |
required: false | |
description: Select registry | |
default: 'github-packages' | |
options: | |
- github-packages | |
- npm | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: π§ Git | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "Github InternetIdentityLabs" | |
- name: π§ Node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org/ | |
- name: π§ Yarn | |
run: | | |
yarn config set version-git-message "chore(${{ github.event.inputs.package }}): release v%s" | |
yarn config set version-tag-prefix "@nfid/${{ github.event.inputs.package }}-v" | |
- name: π€ Install | |
run: yarn | |
- name: π€ Increment package version | |
working-directory: packages/${{ github.event.inputs.package }} | |
run: | | |
if [[ ${{ github.event.inputs.level }} == "pre"* ]]; then | |
yarn version --${{ github.event.inputs.level }} --preid ${{ github.event.inputs.preid }} | |
else | |
yarn version --${{ github.event.inputs.level }} | |
fi | |
- name: π€ Build | |
run: npx nx build ${{ github.event.inputs.package }} | |
- name: π¦ Publish package to NPM registry | |
if: ${{ github.event.inputs.registry == 'npm' }} | |
working-directory: dist/packages/${{ github.event.inputs.package }} | |
run: yarn publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.IL_GH_NPM_TOKEN }} | |
- name: π¦ Publish package to github-packages registry | |
if: ${{ github.event.inputs.registry == 'github-packages' }} | |
working-directory: dist/packages/${{ github.event.inputs.package }} | |
run: | | |
npm pkg set 'name'='@internet-identity-labs/${{ github.event.inputs.package }}' | |
echo "registry=https://npm.pkg.github.com" >> .npmrc | |
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc | |
yarn publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: π Push tags | |
run: | | |
git push | |
git push --tags |