Manual Pre-Release Publish #120
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 Pre-Release Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch. Defaults to "main".' | |
required: true | |
default: 'main' | |
prereleaseVersion: | |
description: 'The new prerelease version to create.' | |
required: true | |
default: 'prerelease' | |
type: choice | |
options: | |
- prepatch | |
- preminor | |
- premajor | |
- prerelease | |
dryRun: | |
description: 'Do not touch or write anything. Show the commands.' | |
required: true | |
default: false | |
type: boolean | |
env: | |
DRY_RUN_ARG: ${{ inputs.dryRun && '--dry-run' || '' }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
ref: ${{ inputs.branch }} | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
- name: Package Manager 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 "[email protected]" | |
git config --global user.name "WebdriverIO Release Bot" | |
- name: Install Dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build | |
run: pnpm build | |
- name: Create Release and Tags | |
shell: bash | |
run: pnpm turbo-version -b ${{inputs.preReleaseVersion}} | |
- name: Publish to NPM | |
shell: bash | |
run: pnpx tsx scripts/publish.ts --tag next ${{inputs.dryRun && '--dry-run' || ''}} | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Log git changes | |
if: ${{inputs.dryRun}} | |
run: | | |
git diff ..origin/main | |
echo "DRY RUN: No changes were made." | |
- name: Push Tags and Commits | |
id: push-tags | |
shell: bash | |
if: ${{!inputs.dryRun}} | |
run: | | |
echo "Git log:" | |
git log --oneline -n 5 | |
# get release tag | |
RELEASE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | |
echo "Release tag: $RELEASE_TAG" | |
echo "Pushing tags and commits..." | |
# push tags and commits without running the pre-push hook | |
git push --tags --no-verify && git push --no-verify | |
# pass the release tag to the next step | |
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
generate_release_notes: true | |
prerelease: true | |
repository: webdriverio-community/wdio-electron-service | |
tag_name: ${{ steps.push-tags.outputs.RELEASE_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} |