Manual Release Publish #78
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: Manual NPM Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseType: | |
description: 'Release Type. Increment the "major", "minor", "patch", or "pre-release" version.' | |
required: true | |
type: choice | |
default: 'patch' | |
options: | |
- patch | |
- minor | |
- major | |
- pre-release | |
distTag: | |
description: 'NPM tag (e.g. use "next" to release a test (pre-release) version)' | |
required: true | |
default: 'latest' | |
dryRun: | |
description: Do not touch or write anything. Show the commands. | |
required: true | |
default: false | |
type: boolean | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: 'main' | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8.10.0 | |
run_install: false | |
- name: NPM Setup | |
run: | | |
pnpm set registry "https://registry.npmjs.org/" | |
pnpm set //registry.npmjs.org/:_authToken $NPM_TOKEN | |
pnpm whoami | |
- name: Git Setup | |
run: | | |
git config --global user.email "bot@webdriver.io" | |
git config --global user.name "WebdriverIO Release Bot" | |
- name: Install Dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build | |
run: pnpm build | |
- name: Pre-release | |
if: ${{ inputs.distTag != 'latest' }} | |
run: | | |
INCREMENT_ARG=${{inputs.releaseType}} | |
if [ "$INCREMENT_ARG" == "pre-release" ]; then | |
unset INCREMENT_ARG | |
fi | |
pnpm run release:ci $INCREMENT_ARG --preRelease=${{inputs.distTag}} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Release | |
if: ${{ inputs.distTag == 'latest' }} | |
run: | | |
if [ "${{inputs.releaseType}}" == "pre-release" ]; then | |
echo "::error ::Invalid Workflow Input: Cannot increment the "pre-release" version for a release. When the NPM Tag is set to \"latest\" the pre-release suffix (-next.0) is not added." | |
exit 1 | |
fi | |
pnpm run release:ci ${{inputs.releaseType}} --npm.tag=${{inputs.distTag}} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |