Skip to content

A local-first personal finance app

change release process to use a branch and add automation (#7418)

Matt Fiddamandb72948d7c4a
diff --git a/.github/actions/release-notes/check/action.yml b/.github/actions/release-notes/check/action.yml
index c71ce43758..4bbac41d06 100644
--- a/.github/actions/release-notes/check/action.yml
+++ b/.github/actions/release-notes/check/action.yml
@@ -9,7 +9,7 @@ runs:
node-version: 22
- name: Install dependencies
shell: bash
- run: yarn --immutable
+ run: yarn workspaces focus @actual-app/ci-actions
- name: Check release notes
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
diff --git a/.github/actions/release-notes/generate/action.yml b/.github/actions/release-notes/generate/action.yml
index c702490f7d..c657120b7f 100644
--- a/.github/actions/release-notes/generate/action.yml
+++ b/.github/actions/release-notes/generate/action.yml
@@ -9,7 +9,7 @@ runs:
node-version: 22
- name: Install dependencies
shell: bash
- run: yarn --immutable
+ run: yarn workspaces focus @actual-app/ci-actions
- name: Generate release notes
shell: bash
env:
diff --git a/.github/workflows/generate-release-pr.yml b/.github/workflows/cut-release-branch.yml
similarity index 65%
rename from .github/workflows/generate-release-pr.yml
rename to .github/workflows/cut-release-branch.yml
index 3764616f77..f457938012 100644
--- a/.github/workflows/generate-release-pr.yml
+++ b/.github/workflows/cut-release-branch.yml
@@ -1,6 +1,9 @@
-name: Generate release PR
+name: Cut release branch
on:
+ schedule:
+ # 17:00 UTC on the 25th of each month
+ - cron: '0 17 25 * *'
workflow_dispatch:
inputs:
ref:
@@ -11,19 +14,29 @@ on:
description: 'Version number for the release (optional)'
required: false
default: ''
+ release-date:
+ description: 'Expected release date, YYYY-MM-DD (optional)'
+ required: false
+ default: ''
+
+permissions:
+ contents: write
+ pull-requests: write
jobs:
- generate-release-pr:
+ cut-release-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- ref: ${{ github.event.inputs.ref }}
+ ref: ${{ github.event.inputs.ref || 'master' }}
+
- name: Set up environment
uses: ./.github/actions/setup
with:
download-translations: 'false'
+
- name: Bump package versions
id: bump_package_versions
shell: bash
@@ -59,12 +72,29 @@ jobs:
done
echo "version=${new_versions[web]}" >> "$GITHUB_OUTPUT"
- - name: Create PR
+
+ - name: Compute release date
+ id: release_date
+ shell: bash
+ env:
+ INPUT_DATE: ${{ github.event.inputs['release-date'] }}
+ run: |
+ if [[ -n "$INPUT_DATE" ]]; then
+ echo "date=$INPUT_DATE" >> "$GITHUB_OUTPUT"
+ else
+ # default to the 1st of next month
+ echo "date=$(date -d '+1 month' '+%Y-%m-01')" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Create release branch and PR
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ secrets.ACTIONS_UPDATE_TOKEN }}
commit-message: 'πŸ”– (${{ steps.bump_package_versions.outputs.version }})'
title: 'πŸ”– (${{ steps.bump_package_versions.outputs.version }})'
- body: 'Generated by [generate-release-pr.yml](../tree/master/.github/workflows/generate-release-pr.yml)'
- branch: 'release/v${{ steps.bump_package_versions.outputs.version }}'
+ body: |
+ Generated by [cut-release-branch.yml](../tree/master/.github/workflows/cut-release-branch.yml)
+
+ <!-- release-date:${{ steps.release_date.outputs.date }} -->
+ branch: 'release/${{ steps.bump_package_versions.outputs.version }}'
base: master
diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml
index d02fd68c53..33ded8794d 100644
--- a/.github/workflows/release-notes.yml
+++ b/.github/workflows/release-notes.yml
@@ -3,6 +3,10 @@ name: Release notes
on:
pull_request:
+permissions:
+ contents: write
+ pull-requests: read
+
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
@@ -11,11 +15,31 @@ jobs:
release-notes:
runs-on: ubuntu-latest
steps:
+ - name: Check if triggered by bot
+ id: bot-check
+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
+ with:
+ script: |
+ const { data: commit } = await github.rest.git.getCommit({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ commit_sha: context.payload.pull_request.head.sha,
+ });
+ const skip = commit.author.name === 'github-actions[bot]'
+ && commit.message.startsWith('Generate release notes');
+ console.log(`Head commit by "${commit.author.name}": ${commit.message.split('\n')[0]}`);
+ console.log(`Skip: ${skip}`);
+ core.setOutput('skip', String(skip));
+
- name: Checkout
+ if: steps.bot-check.outputs.skip != 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
+ token: ${{ secrets.ACTIONS_UPDATE_TOKEN || github.token }}
+
- name: Get changed files
+ if: steps.bot-check.outputs.skip != 'true'
id: changed-files
run: |
git fetch origin ${{ github.base_ref }}
@@ -28,9 +52,17 @@ jobs:
else
echo "only_docs=false" >> $GITHUB_OUTPUT
fi
+
- name: Check release notes
- if: startsWith(github.head_ref, 'release/') == false && steps.changed-files.outputs.only_docs != 'true'
+ if: >-
+ steps.bot-check.outputs.skip != 'true'
+ && startsWith(github.head_ref, 'release/') == false
+ && steps.changed-files.outputs.only_docs != 'true'
uses: ./.github/actions/release-notes/check
+
- name: Generate release notes
- if: startsWith(github.head_ref, 'release/') == true
+ if: >-
+ steps.bot-check.outputs.skip != 'true'
+ && startsWith(github.head_ref, 'release/') == true
+ && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
uses: ./.github/actions/release-notes/generate
diff --git a/packages/ci-actions/bin/release-notes-generate.mjs b/packages/ci-actions/bin/release-notes-generate.mjs
index 9198ca582b..404cc898e1 100644
--- a/packages/ci-actions/bin/release-notes-generate.mjs
+++ b/packages/ci-actions/bin/release-notes-generate.mjs
@@ -34,6 +34,7 @@ const apiResult = await fetch('https://api.github.com/graphql', {
node {
number
headRefName
+ body
}
}
}
@@ -53,8 +54,44 @@ await collapsedLog('API Response', apiResult);
const prData = apiResult.data.repository.pullRequests.edges[0].node;
const version = prData.headRefName.split('/')[1].replace(/^v/, '');
-const today = new Date().toISOString().slice(0, 10);
+const slug = version.replace(/\./g, '-');
const author = process.env.GITHUB_ACTOR || 'TODO';
+const commitMessage = `Generate release notes for v${version}`;
+
+const releaseDateMatch = (prData.body || '').match(
+ /<!-- release-date:(\d{4}-\d{2}-\d{2}) -->/,
+);
+const releaseDate = releaseDateMatch ? releaseDateMatch[1] : 'TODO';
+
+const botName = 'github-actions[bot]';
+const botEmail = '41898282+github-actions[bot]@users.noreply.github.com';
+
+await exec(`git config user.name '${botName}'`);
+await exec(`git config user.email '${botEmail}'`);
+
+await group('Prepare branch', async () => {
+ if (process.env.GITHUB_HEAD_REF) {
+ await exec(`git fetch origin ${process.env.GITHUB_HEAD_REF}`, {
+ stdio: 'inherit',
+ });
+ await exec(`git checkout ${process.env.GITHUB_HEAD_REF}`, {
+ stdio: 'inherit',
+ });
+ }
+
+ // the previous generation commit deletes source files from
+ // upcoming-release-notes, rebase it out so we can regenerate from all of them
+ const { stdout: commitHash } = await exec(
+ `git log --grep='${commitMessage}' --format=%H -1`,
+ );
+ const hash = commitHash.trim();
+ if (hash) {
+ console.log(`Dropping previous release notes commit ${hash}`);
+ await exec(`git rebase --onto ${hash}~1 ${hash}`, {
+ stdio: 'inherit',
+ });
+ }
+});
const { notesByCategory, files } = await parseReleaseNotes(
'upcoming-release-notes',
@@ -71,14 +108,15 @@ if (files.length === 0) {
const highlights = '- TODO: Add release highlights';
await group('Generate blog post', async () => {
- const slug = version.replace(/\./g, '-');
- const filename = `${today}-release-${slug}.md`;
- const blogPath = join('packages/docs/blog', filename);
+ const blogPath = join(
+ 'packages/docs/blog',
+ `${releaseDate}-release-${slug}.md`,
+ );
const blogContent = `---
title: Release ${version}
description: New release of Actual.
-date: ${today}T10:00
+date: ${releaseDate}T10:00
slug: release-${version}
tags: [announcement, release]
hide_table_of_contents: false
@@ -89,7 +127,7 @@ ${highlights}
<!--truncate-->
-**Docker Tag: v${version}**
+**Docker Tag: ${version}**
${categorizedNotes}
`;
@@ -104,11 +142,11 @@ await group('Update releases.md', async () => {
const newSection = `## ${version}
-Release date: ${today}
+Release date: ${releaseDate}
${highlights}
-**Docker Tag: v${version}**
+**Docker Tag: ${version}**
${categorizedNotes}`;
@@ -122,14 +160,6 @@ ${categorizedNotes}`;
});
await group('Remove used release notes', async () => {
- if (process.env.GITHUB_HEAD_REF) {
- await exec(`git fetch origin ${process.env.GITHUB_HEAD_REF}`, {
- stdio: 'inherit',
- });
- await exec(`git checkout ${process.env.GITHUB_HEAD_REF}`, {
- stdio: 'inherit',
- });
- }
await Promise.all(
files.map(f => fs.unlink(join('upcoming-release-notes', f))),
);
@@ -140,19 +170,8 @@ await group('Commit and push', async () => {
'git add upcoming-release-notes packages/docs/blog packages/docs/docs/releases.md',
{ stdio: 'inherit' },
);
- const name = 'github-actions[bot]';
- const email = '41898282+github-actions[bot]@users.noreply.github.com';
- await exec(`git commit -m 'Generate release notes for v${version}'`, {
- stdio: 'inherit',
- env: {
- ...process.env,
- GIT_AUTHOR_NAME: name,
- GIT_COMMITTER_NAME: name,
- GIT_AUTHOR_EMAIL: email,
- GIT_COMMITTER_EMAIL: email,
- },
- });
- await exec('git push origin', { stdio: 'inherit' });
+ await exec(`git commit -m '${commitMessage}'`);
+ await exec('git push --force-with-lease origin', { stdio: 'inherit' });
});
async function parseReleaseNotes(dir) {
diff --git a/packages/ci-actions/src/versions/get-next-package-version.ts b/packages/ci-actions/src/versions/get-next-package-version.ts
index ae3bf0fa3e..694de2a592 100644
--- a/packages/ci-actions/src/versions/get-next-package-version.ts
+++ b/packages/ci-actions/src/versions/get-next-package-version.ts
@@ -60,7 +60,7 @@ function resolveType(
currentDate.getFullYear() === 2000 + versionYear &&
currentDate.getMonth() + 1 === versionMonth;
- if (inPatchMonth && currentDate.getDate() <= 25) {
+ if (inPatchMonth && currentDate.getDate() < 25) {
return 'hotfix';
}
diff --git a/packages/docs/docs/contributing/releasing.md b/packages/docs/docs/contributing/releasing.md
index 5c002b14b9..ca22bb5cf3 100644
--- a/packages/docs/docs/contributing/releasing.md
+++ b/packages/docs/docs/contributing/releasing.md
@@ -21,28 +21,28 @@ For example:
- `v23.3.2` - another bugfix launched later in the month of March;
- `v23.4.0` - first release launched on 9th of April, 2023;
-## Set up the PR
+## Release branch
-### Code
+A release branch and PR are automatically cut at 17:00 UTC on the 25th of each month. To cut one manually, run [this GitHub Action](https://github.com/actualbudget/actual/actions/workflows/cut-release-branch.yml).
-- [ ] Run [this GitHub Action](https://github.com/actualbudget/actual/actions/workflows/generate-release-pr.yml) to generate a release PR (for a regular monthly release, leave the arguments set to their default values).
-- [ ] Open the generated PR and ensure the release notes workflow has started to collate the release notes into a comment in the PR. You may need to push an empty commit in order to trigger CI.
-- [ ] After the release notes workflows in the PR has been run, copy the collated notes into a new blog post using a previous release as a template. The release notes will also need adding to the `docs/releases.md` file.
-- [ ] Fix spelling as needed.
+The release notes workflow automatically generates a blog post and updates `docs/releases.md` from the files in `upcoming-release-notes/`. This runs each time the release PR is updated, so there is no need to manually copy notes into the docs.
-## Await approval of the Release PR
+Fixes that need to be included in the release should be cherry-picked onto the release branch manually.
-- [ ] Remove `[WIP]` from the PR title to mark it as ready for review, and share in the release channel on Discord.
-- [ ] Wait until at least 2 other maintainers have approved the release before merging the release PR.
+## Stabilise the release
-## Trigger the release pipeline
+- [ ] Fix spelling in the generated release notes as needed.
+- [ ] Share the release PR in the release channel on Discord.
+- [ ] Wait until at least 2 other maintainers have approved the release.
-Once the release PRs have been merged, the commit in `actual` needs to be tagged. When the tag is pushed, it will trigger the Docker stable image, all NPM package and the Desktop app to be built and published.
+## Merge and tag the release
-- [ ] Run the below in the `actual` repository, or use the GitHub UI.
+- [ ] Merge the release PR to master.
+- [ ] Create the tag on the **release branch** and push it. When the tag is pushed, it triggers the Docker stable image, all NPM packages and the Desktop app to be built and published.
```bash
+ git checkout release/vX.Y.Z
git tag vX.Y.Z
- git push vX.Y.Z
+ git push {remote} vX.Y.Z
```
All NPM packages should be automatically released and pushed to the NPM registry. Check them here:
@@ -63,6 +63,4 @@ Once the GitHub release is published, the Flathub publish workflow will trigger
- [ ] Un-draft the GitHub release which will send announcement notifications to all apps.
- [ ] Approve and merge the [Flathub Release PR](https://github.com/flathub/com.actualbudget.actual/pulls) to master.
- [ ] Wrap up by sending an announcement on Discord and Twitter.
-- [ ] Wait one to two days to see if any new bugs show up that need a patch release. If none show up, end the merge freeze.
-
-:tada:
+- [ ] Wait one to two days to see if any new bugs show up that need a patch release.
diff --git a/upcoming-release-notes/7418.md b/upcoming-release-notes/7418.md
new file mode 100644
index 0000000000..d449c65a71
--- /dev/null
+++ b/upcoming-release-notes/7418.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [matt-fidd]
+---
+
+Change release automation to stop us from requiring a merge freeze every month