Skip to content

Commit 0f5d4a1

Browse files
committed
Split Flutter version bump workflow into app (CalVer) and lib (SemVer)
1 parent b9e86ab commit 0f5d4a1

4 files changed

Lines changed: 156 additions & 7 deletions

File tree

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: bump version / flutter app
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
date_override:
7+
description: >
8+
Optional date to use instead of "now" (recommended format: YYYY-MM-DD).
9+
required: false
10+
type: string
11+
default: ""
12+
format:
13+
description: >
14+
Optional CalVer format string passed directly to bump-calver (blank = default).
15+
required: false
16+
type: string
17+
default: ""
18+
secrets:
19+
APP_ID:
20+
description: GitHub App installation ID
21+
required: true
22+
APP_PRIVATE_KEY:
23+
description: GitHub App private key
24+
required: true
25+
26+
jobs:
27+
prepare_next_release:
28+
name: prepare next release
29+
runs-on: ubuntu-latest
30+
steps:
31+
- id: generate_token
32+
name: Generate a GitHub App token
33+
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a
34+
with:
35+
app_id: ${{ secrets.APP_ID }}
36+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
37+
38+
- name: Checkout source code
39+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
40+
with:
41+
token: ${{ steps.generate_token.outputs.token }}
42+
ref: main
43+
fetch-depth: 0
44+
45+
- name: Add Toolbox Envy to PATH
46+
uses: EarthmanMuons/toolbox-envy/.github/actions/add-to-path@main
47+
with:
48+
include_bins: |
49+
common
50+
flutter
51+
52+
- name: Configure Git identity
53+
run: |
54+
git config user.name "senile-errata[bot]"
55+
git config user.email "senile-errata@users.noreply.github.com"
56+
57+
- name: Set up Flutter
58+
uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
59+
with:
60+
channel: stable
61+
flutter-version-file: pubspec.yaml
62+
cache: true
63+
64+
- name: Install dependencies
65+
run: flutter pub get --enforce-lockfile
66+
67+
- name: Update dependencies
68+
run: flutter pub upgrade --unlock-transitive
69+
70+
- name: Bump CalVer version for project
71+
run: |
72+
bump-calver --format "${{ inputs.format }}" "${{ inputs.date_override }}" | set-project-version
73+
74+
- name: Bump CHANGELOG version to match
75+
run: get-project-version | bump-changelog-version
76+
77+
- id: version
78+
name: Get the new release version
79+
run: |
80+
echo "release_version=$(get-project-version)" >>"$GITHUB_OUTPUT"
81+
82+
- name: Verify changes exist
83+
run: |
84+
git update-index -q --really-refresh
85+
if git diff-index --quiet HEAD --; then
86+
echo "No changes detected; refusing to open PR."
87+
exit 1
88+
fi
89+
90+
- id: cpr
91+
name: Create pull request
92+
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725
93+
with:
94+
token: ${{ steps.generate_token.outputs.token }}
95+
branch: release/bump-version
96+
branch-suffix: timestamp
97+
commit-message: Release v${{ steps.version.outputs.release_version }}
98+
title: Prepare v${{ steps.version.outputs.release_version }} release.
99+
body: |-
100+
This PR was automatically created by the [bump-version](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow, which ran the following commands:
101+
102+
103+
```
104+
$ flutter pub upgrade --unlock-transitive
105+
$ bump-calver --format "${{ inputs.format }}" "${{ inputs.date_override }}" | set-project-version
106+
$ get-project-version | bump-changelog-version
107+
```
108+
109+
**Please review the submitted changes.**
110+
111+
Once this PR is merged into the _main_ branch, an automated process will tag the commit and create a draft GitHub Release with signed assets attached for final review before publishing.
112+
113+
- name: Annotate workflow run with PR URL
114+
run: |
115+
set -euo pipefail
116+
{
117+
echo "### Opened pull request for release v${{ steps.version.outputs.release_version }}"
118+
echo
119+
echo "- ${{ steps.cpr.outputs.pull-request-url }}"
120+
} >>"$GITHUB_STEP_SUMMARY"

.github/workflows/bump-version-flutter.yml renamed to .github/workflows/bump-version-flutter-lib.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: bump version / flutter
1+
name: bump version / flutter lib
22

33
on:
44
workflow_call:
@@ -91,10 +91,10 @@ jobs:
9191
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725
9292
with:
9393
token: ${{ steps.generate_token.outputs.token }}
94-
branch: chore/bump-version-${{ inputs.level }}
94+
branch: release/bump-version
9595
branch-suffix: timestamp
96-
commit-message: Prepare v${{ steps.version.outputs.release_version }} ${{ inputs.level }} release.
97-
title: Release v${{ steps.version.outputs.release_version }}
96+
commit-message: Release v${{ steps.version.outputs.release_version }}
97+
title: Prepare v${{ steps.version.outputs.release_version }} ${{ inputs.level }} release.
9898
body: |-
9999
This PR was automatically created by the [bump-version](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow, which ran the following commands:
100100

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Workflows specific to Flutter projects:
6464

6565
- `check-flutter.yml` – Format, analyze, and test using pinned Flutter
6666
- `preload-caches-flutter.yml` – Cache pinned Flutter dependencies
67-
- `bump-version-flutter.yml` – Bump version and changelog, open PR
67+
- `bump-version-flutter-app.yml` – Bump CalVer version and changelog, open PR
68+
- `bump-version-flutter-lib.yml` – Bump SemVer version and changelog, open PR
6869
- `draft-release-flutter.yml` – Draft release, build, sign, and upload assets
6970

7071
Details: [docs/flutter.md](docs/flutter.md)

docs/flutter.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,37 @@ cache to speed up CI runs.
4949

5050
---
5151

52-
## bump-version-flutter.yml
52+
## bump-version-flutter-app.yml
5353

54-
Bumps the project semantic version and CHANGELOG and opens a release PR.
54+
Intended for Flutter applications released as final artifacts (APK/IPA/etc).
55+
56+
Bumps the project version and CHANGELOG (using CalVer), then opens a release
57+
preparation pull request.
58+
59+
**Inputs**
60+
61+
| Name | Required |
62+
| ------------- | -------- |
63+
| date_override | false |
64+
| format | false |
65+
66+
**Secrets**
67+
68+
- `APP_ID`
69+
- `APP_PRIVATE_KEY`
70+
71+
**Authentication**
72+
73+
This workflow requires a GitHub App token (see namespace note above).
74+
75+
---
76+
77+
## bump-version-flutter-lib.yml
78+
79+
Intended for Flutter packages/plugins consumed as dependencies.
80+
81+
Bumps the project version and CHANGELOG (using SemVer), then opens a release
82+
preparation pull request.
5583

5684
**Inputs**
5785

0 commit comments

Comments
 (0)