Skip to content

Commit 340e57b

Browse files
fix: update versioning logic in GitHub Actions and set new version 1.0.30 in pubspec.yaml
Build & Release workflow updates: - Removed manual major/minor version environment variables. - Version is now extracted directly from `pubspec.yaml`. - If build number (version code) is not specified in `pubspec.yaml`, it defaults to 1. - Added a step to find the previous release tag for changelog generation. - Added a step to create a Git tag if it doesn't already exist. - Updated release name and body format. pubspec.yaml: - Updated version to 1.0.30+10030. - Removed comments about automated versioning, as version is now managed in `pubspec.yaml`.
1 parent 943277e commit 340e57b

File tree

2 files changed

+38
-43
lines changed

2 files changed

+38
-43
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ on:
88

99
name: "Build & Release"
1010

11-
# 🎯 VERSION CONTROL - Change these to bump major/minor versions
12-
env:
13-
APP_MAJOR_VERSION: 1
14-
APP_MINOR_VERSION: 0
15-
# PATCH version is automatically calculated from git history
16-
# Version will be: MAJOR.MINOR.PATCH (e.g., 1.0.30, 1.0.31, etc.)
17-
# To release 1.1.x: Change APP_MINOR_VERSION to 1
18-
# To release 2.0.x: Change APP_MAJOR_VERSION to 2, APP_MINOR_VERSION to 0
19-
2011
jobs:
2112
# Test job for PRs
2213
test:
@@ -54,44 +45,40 @@ jobs:
5445
fetch-tags: true
5546
token: ${{ secrets.TOKEN }}
5647

57-
- name: Calculate Version
48+
- name: Extract Version from pubspec.yaml
5849
id: version
5950
run: |
60-
MAJOR=${{ env.APP_MAJOR_VERSION }}
61-
MINOR=${{ env.APP_MINOR_VERSION }}
62-
63-
# Get all existing tags for this major.minor combination
64-
EXISTING_TAGS=$(git tag -l "v$MAJOR.$MINOR.*" | sort -V)
51+
# Extract version from pubspec.yaml
52+
VERSION_WITH_BUILD=$(grep '^version: ' pubspec.yaml | sed 's/version: *//')
53+
VERSION=$(echo "$VERSION_WITH_BUILD" | cut -d'+' -f1)
54+
VERSION_CODE=$(echo "$VERSION_WITH_BUILD" | cut -d'+' -f2)
6555
66-
if [ -z "$EXISTING_TAGS" ]; then
67-
# No existing tags for this major.minor, start with patch 0
68-
PATCH=0
69-
else
70-
# Get the highest patch version
71-
LATEST_TAG=$(echo "$EXISTING_TAGS" | tail -n 1)
72-
LATEST_PATCH=$(echo "$LATEST_TAG" | sed "s/v$MAJOR\.$MINOR\.//")
73-
PATCH=$((LATEST_PATCH + 1))
56+
# If version code is not specified, use default
57+
if [ "$VERSION" = "$VERSION_CODE" ]; then
58+
VERSION_CODE=1
7459
fi
7560
76-
VERSION="$MAJOR.$MINOR.$PATCH"
77-
VERSION_CODE=$((MAJOR * 10000 + MINOR * 100 + PATCH))
7861
TAG="v$VERSION"
7962
80-
echo "🚀 Calculated Version: $VERSION"
63+
echo "🚀 Extracted Version: $VERSION"
8164
echo "🔢 Version Code: $VERSION_CODE"
8265
echo "🏷️ Git Tag: $TAG"
8366
8467
# Export to environment
8568
echo "VERSION=$VERSION" >> $GITHUB_ENV
8669
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
8770
echo "TAG=$TAG" >> $GITHUB_ENV
88-
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
89-
echo "MINOR=$MINOR" >> $GITHUB_ENV
90-
echo "PATCH=$PATCH" >> $GITHUB_ENV
71+
72+
- name: Find Previous Release for Changelog
73+
run: |
74+
# Get the most recent version tag for changelog comparison
75+
PREV_TAG=$(git tag -l 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -1)
9176
92-
# Update pubspec.yaml with calculated version
93-
sed -i "s/version: .*/version: $VERSION+$VERSION_CODE/" pubspec.yaml
94-
echo "✅ Updated pubspec.yaml to: $VERSION+$VERSION_CODE"
77+
if [ -n "$PREV_TAG" ]; then
78+
echo "PREV_TAG=$PREV_TAG" >> $GITHUB_ENV
79+
else
80+
echo "PREV_TAG=" >> $GITHUB_ENV
81+
fi
9582
9683
- uses: actions/setup-java@v4
9784
with:
@@ -152,6 +139,19 @@ jobs:
152139
cp -r Runner.app Payload/
153140
zip -r SysAdmin-v${{ env.VERSION }}.ipa Payload
154141
142+
# Create Tag if it doesn't exist
143+
- name: Create Tag
144+
run: |
145+
if ! git rev-parse ${{ env.TAG }} >/dev/null 2>&1; then
146+
git config --local user.email "action@github.com"
147+
git config --local user.name "GitHub Action"
148+
git tag ${{ env.TAG }}
149+
git push origin ${{ env.TAG }}
150+
echo "Created new tag: ${{ env.TAG }}"
151+
else
152+
echo "Tag ${{ env.TAG }} already exists, skipping tag creation"
153+
fi
154+
155155
# Create Release
156156
- name: Create GitHub Release
157157
uses: ncipollo/release-action@v1
@@ -163,10 +163,11 @@ jobs:
163163
build/ios/iphoneos/SysAdmin-v${{ env.VERSION }}.ipa
164164
token: ${{ secrets.TOKEN }}
165165
tag: ${{ env.TAG }}
166-
name: SysAdmin ${{ env.TAG }}
166+
name: Release ${{ env.TAG }}
167167
body: |
168-
## 🚀 Release ${{ env.TAG }}
169-
170-
### Full Changelog: [${{ env.TAG }}...v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PREV_PATCH }}](https://github.com/prathameshkhade/SysAdmin/compare/v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PREV_PATCH }}...${{ env.TAG }})### Full Changelog: [${{ env.TAG }}...v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PREV_PATCH }}](https://github.com/prathameshkhade/SysAdmin/compare/v${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PREV_PATCH }}...${{ env.TAG }})
168+
# Release ${{ env.TAG }}
169+
## What's New
170+
## Bug Fixes
171+
#### Full Changelog: [${{ env.PREV_TAG }}...${{ env.TAG }}](https://github.com/${{ github.repository }}/compare/${{ env.PREV_TAG }}...${{ env.TAG }})
171172
draft: false
172173
prerelease: false

pubspec.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ description: "Building GUI for the Linux System Administrator"
44
# pub.dev using `flutter pub publish`. This is preferred for private packages.
55
publish_to: "none" # Remove this line if you wish to publish to pub.dev
66

7-
# 🤖 VERSION IS FULLY AUTOMATED - DO NOT EDIT
8-
# Version is automatically calculated by GitHub Actions workflow
9-
# To change major/minor versions, edit the workflow file env variables:
10-
# - APP_MAJOR_VERSION: for 1.x.x → 2.x.x
11-
# - APP_MINOR_VERSION: for 1.0.x → 1.1.x
12-
# Patch versions increment automatically on each release
13-
version: 0.0.0+1
7+
version: 1.0.30+10030
148

159
environment:
1610
sdk: ^3.5.3

0 commit comments

Comments
 (0)