Publish to npmjs #33
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 to npmjs | |
on: | |
# Who has permission to workflow_dispatch | |
# https://github.com/orgs/community/discussions/26622 | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release' | |
required: true | |
type: string | |
distTag: | |
description: 'Used as lerna publish --dist-tag' | |
default: 'latest' | |
required: true | |
type: string | |
jobs: | |
publish: | |
permissions: | |
contents: write | |
id-token: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: './.node-version' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Cache Deps | |
uses: actions/cache@v4 | |
with: | |
path: | | |
node_modules | |
packages/*/node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles( 'yarn.lock' ) }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Fetch Deps | |
run: yarn install --frozen-lockfile | |
- name: Set git username and email | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "actions-user" | |
- name: Set package version | |
run: | | |
yarn lerna version ${{ github.event.inputs.version }} --exact --no-push --yes | |
yarn lerna publish from-git -y --dist-tag ${{ github.event.inputs.distTag }} | |
env: | |
NPM_CONFIG_PROVENANCE: true | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Git push version up commits | |
run: | | |
git push origin --tags ${{ github.ref_name }} | |
- name: Upload Builds | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
path: | | |
packages/*/lib/ | |
packages/*/types/ |