Publish to npm #8
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: | |
version: | |
description: 'npm version to publish' | |
type: choice | |
required: true | |
options: | |
# these are defined in ${{vars.versions}}, but ghw doesn't yet support the use of expressions in inputs. | |
- 'patch (x.y.z+1, bug fixes)' | |
- 'minor (x.y+1.0, new functionality)' | |
- 'major (x+1.0.0, api breaking changes)' | |
dry_run: | |
description: 'Perform all steps except npm publish' | |
type: boolean | |
default: true | |
required: true | |
jobs: | |
build: | |
if: false | |
uses: ./.github/workflows/build.yml | |
test-vars_versions: | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Testing vars.versions | |
run: | | |
echo "::notice::github.sha = ${{github.sha}}" | |
echo "::notice::vars.versions = ${{vars.versions}}" | |
echo "::notice::toJSON(vars.versions).values = ${{toJSON(vars.versions).values}}" | |
echo "vars.versions:\n\t\"${{vars.versions}}\"" | |
echo "toJSON(vars.versions): ${{toJSON(vars.versions)}}" | |
echo "${{toJSON(vars.versions).values}}" | |
echo "${{toJSON(vars.versions).labels}}" | |
echo "${{toJSON(vars.versions).labels[0]}}" | |
publish-npm: | |
if: false | |
# needs: build | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org/ | |
- run: npm ci | |
- run: npm run dist | |
- name: Publish to npm | |
if: inputs.dry_run == false | |
run: | | |
echo "npm version ${{env.PKG_VERSION}}" | |
echo "npm publish" | |
env: | |
PKG_VERSION: ${{toJSON(vars.versions).values[inputs.version]}} | |
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |