Skip to content

Commit 087d40c

Browse files
authored
build: improve version + publish flow (#4078)
1 parent 8b6b183 commit 087d40c

File tree

4 files changed

+66
-26
lines changed

4 files changed

+66
-26
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ jobs:
123123
- name: Create GitHub release
124124
env:
125125
GH_TOKEN: ${{ fromJSON(steps.secret-service.outputs.secrets).GITHUB_TOKEN }}
126-
run: gh release create "v${{ steps.version.outputs.version }}" --target next --generate-notes --prerelease
126+
run: gh release create "v${{ steps.version.outputs.version }}" --target ${{ github.sha }} --generate-notes --prerelease

CONTRIBUTING.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -134,39 +134,47 @@ Here are some things to keep in mind as you file pull requests to fix bugs, add
134134

135135
## Release process
136136

137-
This guide is for maintainers who have:
137+
This guide is for maintainers who have access to the [Forgers](https://github.com/orgs/electron/teams/forgers)
138+
GitHub team.
138139

139-
- Push access to the `electron/forge` repository.
140-
- Collaborator access to the `@electron-forge` packages on npm.
140+
> [!IMPORTANT]
141+
> These instructions are strictly for Electron Forge 8 pre-release versions.
142+
> Do not use against `main`!
141143
142-
### 1. Prepare your local code checkout
144+
### 1. Run the version bump script
143145

144-
- Switch to the tip of the `main` branch with `git switch main && git pull`.
145-
- Run tests locally with `yarn test`.
146-
- Check that the latest CI run passed on `main` on [GitHub](https://github.com/electron/forge/actions?query=workflow:CI).
147-
- Remove all untracked files and directories from your checkout with `git clean -fdx`.
148-
- Install dependencies with `yarn install`.
146+
Run the `yarn lerna:version` script from the root of this monorepo. This script will:
149147

150-
### 2. Publish all npm packages
148+
1. Reset your current git state to `HEAD`.
149+
1. Run Lerna's [`version`](https://github.com/lerna/lerna/tree/main/libs/commands/version#readme)
150+
command, which increments all packages to the next alpha pre-release version.
151+
(You'll need to accept the version bump before proceeding.)
152+
1. Check out a new branch called `alpha-release/YYMMDD-hh-mm`.
153+
1. Commit your changes with the appropriate commit title and message.
151154

152-
- Log into npm with `npm login`.
153-
- Run the `yarn lerna:publish` command.
154-
- Enter your npm account's time-based one-time password (TOTP).
155+
### 2. Merge the change into `next`
155156

156-
The `lerna:publish` script will automatically increment the next package version based on the
157-
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. From there, it does two things:
157+
Push your changes up and create a new PR. **When your PR is merged, ensure that you keep the original
158+
commit message and extended description from the original script.**
158159

159-
1. It creates a tagged commit that bumps the version number in `package.json` at the root and package levels
160-
and pushes the commit and tag to GitHub.
161-
1. It publishes every `@electron-forge/` package to npm.
160+
> [!NOTE]
161+
> Branch protection is configured so that only Forgers are allowed to push up commits that can
162+
> trigger a release.
163+
164+
Once your PR is merged, the [`release.yml`](.github/workflows/release.yml) workflow should run.
165+
166+
### 3. Approve the release job
162167

163-
### 3. Publish release to GitHub
168+
Look for a pending [Publish](https://github.com/electron/forge/actions?query=event%3Apush+branch%3Anext)
169+
job in the Actions tab on the Forge repository. You need to get another Forger member to approve
170+
the job before the publish happens.
164171

165-
- Go to the repo's [New Release](https://github.com/electron/forge/releases/new) page.
166-
- Select tag you just published.
167-
- Target the `main` branch.
168-
- [Automatically generated release notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes)
169-
against the previous Forge release.
172+
Once the job is completed, all `@electron-forge/` packages and `create-electron-app` should have
173+
new published versions under the `alpha` dist-tag.
174+
175+
> [!NOTE]
176+
> If the Publish job fails for whatever reason, feel free to start over at step 1. Version numbers
177+
> aren't sacred, so we can just re-increment the release number and try again.
170178
171179
### Adding a new `@electron-forge` package
172180

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build": "tsc -b packages && ts-node tools/test-dist",
1212
"build:watch": "tsc -b packages --watch",
1313
"docs": "yarn build && typedoc",
14-
"lerna:version": "lerna version prerelease --force-publish --preid=alpha --no-changelog --exact --no-git-tag-version --no-push",
14+
"lerna:version": "./tools/version.sh",
1515
"lint:js": "prettier --check . --experimental-cli && eslint . --cache",
1616
"lint:markdown": "electron-markdownlint \"**/*.md\"",
1717
"lint:markdown-js": "electron-lint-markdown-standard --root . --ignore-path .markdownlintignore --semi \"**/*.md\"",

tools/version.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ -n "$(git status --porcelain)" ]; then
6+
echo "Error: Working directory is not clean. Please commit or stash your changes before running lerna:version."
7+
exit 1
8+
fi
9+
10+
echo "Running lerna version..."
11+
lerna version prerelease \
12+
--force-publish \
13+
--preid=alpha \
14+
--no-changelog \
15+
--exact \
16+
--no-git-tag-version \
17+
--no-push
18+
19+
# Releaser may decline to apply version changes. Exit early in that case.
20+
if [ -z "$(git status --porcelain)" ]; then
21+
echo "No version changes were made. Exiting."
22+
exit 0
23+
fi
24+
25+
BRANCH_NAME="alpha-release/$(date +'%y%m%d-%I-%M')"
26+
echo "Creating branch: $BRANCH_NAME"
27+
git checkout -b "$BRANCH_NAME"
28+
29+
echo "Committing changes..."
30+
git commit -a -m 'chore: version bump' -m '<trigger_release>'
31+
32+
echo "Version bump complete! Branch $BRANCH_NAME created and changes committed."

0 commit comments

Comments
 (0)