Skip to content

Commit 01c31ab

Browse files
Merge pull request #625 from madeofpendletonwool/finalize-08
pre release commit flow
2 parents c686aeb + 46f0d1a commit 01c31ab

File tree

2 files changed

+59
-36
lines changed

2 files changed

+59
-36
lines changed

.github/workflows/build-android-flutter.yml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ on:
1313
version:
1414
description: "Manual override version tag (optional)"
1515
required: false
16-
commit_version:
17-
description: "Commit version update to git"
18-
type: boolean
19-
default: false
20-
required: false
2116

2217
jobs:
2318
build:
@@ -63,40 +58,15 @@ jobs:
6358
echo "storeFile=../upload-keystore.jks" >> key.properties
6459
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > upload-keystore.jks
6560
66-
- name: Update app version
61+
- name: Verify version files
6762
run: |
6863
cd mobile
69-
# Update pubspec.yaml version to use Flutter format (version+build)
70-
if [[ "$IMAGE_TAG" != "latest" ]]; then
71-
# Remove 'v' prefix if present and create build number from git count with offset
72-
VERSION_NAME=${IMAGE_TAG#v}
73-
BUILD_NUMBER=$(($(git rev-list --count HEAD) + 20250000))
74-
sed -i "s/^version: .*/version: ${VERSION_NAME}+${BUILD_NUMBER}/" pubspec.yaml
75-
76-
# Also update environment.dart constants
77-
sed -i "s/static const _projectVersion = '[^']*';/static const _projectVersion = '${VERSION_NAME}';/" lib/core/environment.dart
78-
sed -i "s/static const _build = '[^']*';/static const _build = '${BUILD_NUMBER}';/" lib/core/environment.dart
79-
80-
echo "Updated version to ${VERSION_NAME}+${BUILD_NUMBER}"
81-
fi
64+
echo "Current version in pubspec.yaml:"
65+
grep "^version:" pubspec.yaml
66+
echo "Current version in environment.dart:"
67+
grep "_projectVersion\|_build" lib/core/environment.dart
68+
echo "Build will use versions exactly as they are in the repository"
8269
83-
- name: Commit version update
84-
if: github.event_name == 'release' || github.event.inputs.commit_version == 'true'
85-
run: |
86-
cd mobile
87-
git config --local user.email "action@github.com"
88-
git config --local user.name "GitHub Action"
89-
git add pubspec.yaml lib/core/environment.dart
90-
if ! git diff --staged --quiet; then
91-
# Use the correct tag name based on trigger type
92-
if [[ "${{ github.event_name }}" == "release" ]]; then
93-
TAG_NAME="${{ github.event.release.tag_name }}"
94-
else
95-
TAG_NAME="${{ github.event.inputs.version || env.IMAGE_TAG }}"
96-
fi
97-
git commit -m "chore: update version to ${TAG_NAME} [skip ci]"
98-
git push
99-
fi
10070
10171
- name: Build APK
10272
run: |
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Pre-Release Version Update
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to set (e.g., 0.8.0)"
8+
required: true
9+
type: string
10+
11+
jobs:
12+
update-version:
13+
name: Update Version Files
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Update app version
24+
run: |
25+
cd mobile
26+
VERSION_NAME=${{ github.event.inputs.version }}
27+
# Calculate what the git count WILL BE after we commit (current + 1)
28+
BUILD_NUMBER=$(($(git rev-list --count HEAD) + 1 + 20250000))
29+
30+
# Update pubspec.yaml version
31+
sed -i "s/^version: .*/version: ${VERSION_NAME}+${BUILD_NUMBER}/" pubspec.yaml
32+
33+
# Update environment.dart constants
34+
sed -i "s/static const _projectVersion = '[^']*';/static const _projectVersion = '${VERSION_NAME}';/" lib/core/environment.dart
35+
sed -i "s/static const _build = '[^']*';/static const _build = '${BUILD_NUMBER}';/" lib/core/environment.dart
36+
37+
echo "Updated version to ${VERSION_NAME}+${BUILD_NUMBER}"
38+
39+
- name: Commit and push version update
40+
run: |
41+
git config --local user.email "action@github.com"
42+
git config --local user.name "GitHub Action"
43+
git add mobile/pubspec.yaml mobile/lib/core/environment.dart
44+
git commit -m "chore: update version to ${{ github.event.inputs.version }} [skip ci]"
45+
git push
46+
47+
- name: Summary
48+
run: |
49+
echo "✅ Version updated to ${{ github.event.inputs.version }}"
50+
echo "📋 Next steps:"
51+
echo "1. Create a GitHub release pointing to the latest commit"
52+
echo "2. The release workflow will build from that exact commit"
53+
echo "3. Version files will match the commit for reproducible builds"

0 commit comments

Comments
 (0)