Publish to NPM #72
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: Publish to NPM | |
on: | |
workflow_dispatch: | |
inputs: | |
increment: | |
description: 'Increment "major", "minor", "patch", or "pre*" version; or specify version [default: "patch"]' | |
required: true | |
default: 'patch' | |
type: string | |
dry-run: | |
description: 'Do not touch or write anything, but show the commands' | |
default: true | |
type: boolean | |
jobs: | |
release-it: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Setup | |
uses: ./.github/actions/setup | |
- name: Setup NPM auth token | |
run: | | |
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }} | |
- name: Dry Run Release | |
if: ${{ inputs.dry-run }} | |
run: | | |
yarn release ${{ inputs.increment }} -d --ci | |
- name: NPM Publish | |
if: ${{ !inputs.dry-run }} | |
run: | | |
git config --global user.email "${{ secrets.GIT_EMAIL }}" | |
git config --global user.name "${{ secrets.GIT_USERNAME }}" | |
yarn release ${{ inputs.increment }} --ci --no-git.tag --no-github.release --npm.allowSameVersion | |
- name: Get Package Info | |
if: ${{ !inputs.dry-run }} | |
id: package-info | |
run: | | |
name=$(node -p "require('./package.json').name") | |
version=$(node -p "require('./package.json').version") | |
echo "name=${name}" >> "$GITHUB_OUTPUT" | |
echo "version=${version}" >> "$GITHUB_OUTPUT" | |
- name: Update Example | |
if: ${{ !inputs.dry-run }} | |
run: | | |
yarn example add ${{steps.package-info.outputs.name}}@${{steps.package-info.outputs.version}} | |
- name: Commit Example | |
if: ${{ !inputs.dry-run }} | |
run: | | |
git add example | |
git commit -m "chore(example): update example to install ${{steps.package-info.outputs.name}}@${{steps.package-info.outputs.version}}" | |
- name: Release | |
if: ${{ !inputs.dry-run }} | |
run: | | |
yarn release ${{ inputs.increment }} --ci --no-npm --no-git.commit |