diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98fdb71d5c..602f9f3152 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -123,4 +123,4 @@ jobs: - name: Create GitHub release env: GH_TOKEN: ${{ fromJSON(steps.secret-service.outputs.secrets).GITHUB_TOKEN }} - run: gh release create "v${{ steps.version.outputs.version }}" --target next --generate-notes --prerelease + run: gh release create "v${{ steps.version.outputs.version }}" --target ${{ github.sha }} --generate-notes --prerelease diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f5777a516..cfdeb278c9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -134,39 +134,47 @@ Here are some things to keep in mind as you file pull requests to fix bugs, add ## Release process -This guide is for maintainers who have: +This guide is for maintainers who have access to the [Forgers](https://github.com/orgs/electron/teams/forgers) +GitHub team. -- Push access to the `electron/forge` repository. -- Collaborator access to the `@electron-forge` packages on npm. +> [!IMPORTANT] +> These instructions are strictly for Electron Forge 8 pre-release versions. +> Do not use against `main`! -### 1. Prepare your local code checkout +### 1. Run the version bump script -- Switch to the tip of the `main` branch with `git switch main && git pull`. -- Run tests locally with `yarn test`. -- Check that the latest CI run passed on `main` on [GitHub](https://github.com/electron/forge/actions?query=workflow:CI). -- Remove all untracked files and directories from your checkout with `git clean -fdx`. -- Install dependencies with `yarn install`. +Run the `yarn lerna:version` script from the root of this monorepo. This script will: -### 2. Publish all npm packages +1. Reset your current git state to `HEAD`. +1. Run Lerna's [`version`](https://github.com/lerna/lerna/tree/main/libs/commands/version#readme) + command, which increments all packages to the next alpha pre-release version. + (You'll need to accept the version bump before proceeding.) +1. Check out a new branch called `alpha-release/YYMMDD-hh-mm`. +1. Commit your changes with the appropriate commit title and message. -- Log into npm with `npm login`. -- Run the `yarn lerna:publish` command. -- Enter your npm account's time-based one-time password (TOTP). +### 2. Merge the change into `next` -The `lerna:publish` script will automatically increment the next package version based on the -[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. From there, it does two things: +Push your changes up and create a new PR. **When your PR is merged, ensure that you keep the original +commit message and extended description from the original script.** -1. It creates a tagged commit that bumps the version number in `package.json` at the root and package levels - and pushes the commit and tag to GitHub. -1. It publishes every `@electron-forge/` package to npm. +> [!NOTE] +> Branch protection is configured so that only Forgers are allowed to push up commits that can +> trigger a release. + +Once your PR is merged, the [`release.yml`](.github/workflows/release.yml) workflow should run. + +### 3. Approve the release job -### 3. Publish release to GitHub +Look for a pending [Publish](https://github.com/electron/forge/actions?query=event%3Apush+branch%3Anext) +job in the Actions tab on the Forge repository. You need to get another Forger member to approve +the job before the publish happens. -- Go to the repo's [New Release](https://github.com/electron/forge/releases/new) page. -- Select tag you just published. -- Target the `main` branch. -- [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) - against the previous Forge release. +Once the job is completed, all `@electron-forge/` packages and `create-electron-app` should have +new published versions under the `alpha` dist-tag. + +> [!NOTE] +> If the Publish job fails for whatever reason, feel free to start over at step 1. Version numbers +> aren't sacred, so we can just re-increment the release number and try again. ### Adding a new `@electron-forge` package diff --git a/package.json b/package.json index a6ae85495f..458190569f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build": "tsc -b packages && ts-node tools/test-dist", "build:watch": "tsc -b packages --watch", "docs": "yarn build && typedoc", - "lerna:version": "lerna version prerelease --force-publish --preid=alpha --no-changelog --exact --no-git-tag-version --no-push", + "lerna:version": "./tools/version.sh", "lint:js": "prettier --check . --experimental-cli && eslint . --cache", "lint:markdown": "electron-markdownlint \"**/*.md\"", "lint:markdown-js": "electron-lint-markdown-standard --root . --ignore-path .markdownlintignore --semi \"**/*.md\"", diff --git a/tools/version.sh b/tools/version.sh new file mode 100755 index 0000000000..12c0b9ce38 --- /dev/null +++ b/tools/version.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +if [ -n "$(git status --porcelain)" ]; then + echo "Error: Working directory is not clean. Please commit or stash your changes before running lerna:version." + exit 1 +fi + +echo "Running lerna version..." +lerna version prerelease \ + --force-publish \ + --preid=alpha \ + --no-changelog \ + --exact \ + --no-git-tag-version \ + --no-push + +# Releaser may decline to apply version changes. Exit early in that case. +if [ -z "$(git status --porcelain)" ]; then + echo "No version changes were made. Exiting." + exit 0 +fi + +BRANCH_NAME="alpha-release/$(date +'%y%m%d-%I-%M')" +echo "Creating branch: $BRANCH_NAME" +git checkout -b "$BRANCH_NAME" + +echo "Committing changes..." +git commit -a -m 'chore: version bump' -m '' + +echo "Version bump complete! Branch $BRANCH_NAME created and changes committed."