Skip to content

Commit 1b0ef3c

Browse files
Merge branch 'main' into main
2 parents 664dbf4 + e43f187 commit 1b0ef3c

File tree

1 file changed

+63
-84
lines changed

1 file changed

+63
-84
lines changed

.github/workflows/release-builder.yml

Lines changed: 63 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@ on:
1111
- cron: '30 6 * * 5'
1212
workflow_dispatch:
1313
inputs:
14-
bump_type:
15-
description: 'Version bump type to apply to version.txt (major, minor, or patch)'
14+
version:
15+
description: 'Release version (e.g., X for v0.X.0, X.Y for v0.X.Y, or X.Y.Z for v0.Y.Z). Leave empty to use version.txt'
1616
required: false
17-
type: choice
18-
options:
19-
- minor
20-
- patch
21-
- major
22-
default: minor
17+
type: string
2318
prerelease:
2419
description: 'Set as a pre-release'
2520
required: false
@@ -35,10 +30,10 @@ on:
3530
permissions:
3631
contents: write
3732
packages: write
38-
issues: write
3933

4034
env:
4135
GOFLAGS: "-mod=readonly"
36+
RELEASE_MAJOR_VERSION: 0
4237

4338
jobs:
4439
dependency-guard:
@@ -61,60 +56,56 @@ jobs:
6156
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
6257
with:
6358
fetch-depth: 0
64-
token: ${{ secrets.THUNDER_AUTOMATION_BOT }}
6559

6660
- name: 📝 Determine Release Version
6761
id: get_version
6862
run: |
69-
# Read current version from version.txt
70-
if [ ! -f version.txt ] || [ -z "$(cat version.txt | tr -d '[:space:]')" ]; then
71-
echo "❌ Error: version.txt not found or empty"
72-
exit 1
73-
fi
74-
CURRENT_VERSION=$(tr -d '[:space:]' < version.txt)
75-
# Strip leading 'v' for semver parsing
76-
SEMVER="${CURRENT_VERSION#v}"
77-
78-
if [[ $SEMVER =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
79-
CUR_MAJOR="${BASH_REMATCH[1]}"
80-
CUR_MINOR="${BASH_REMATCH[2]}"
81-
CUR_PATCH="${BASH_REMATCH[3]}"
82-
else
83-
echo "❌ Error: Could not parse version '$CURRENT_VERSION' from version.txt"
84-
exit 1
85-
fi
86-
8763
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
64+
# Manual trigger - always use input values for flags
8865
PRERELEASE="${{ github.event.inputs.prerelease }}"
8966
RUN_PERF_TEST="${{ github.event.inputs.run_performance_test }}"
90-
BUMP_TYPE="${{ github.event.inputs.bump_type }}"
67+
INPUT_VERSION="${{ github.event.inputs.version }}"
68+
MAJOR="${{ env.RELEASE_MAJOR_VERSION }}"
69+
70+
if [ -n "$INPUT_VERSION" ]; then
71+
# Handle manually provided version
72+
if [[ $INPUT_VERSION =~ ^v?[0-9]+\.([0-9]+)\.([0-9]+) ]]; then
73+
# Full format (vX.Y.Z) -> Parse and use MAJOR
74+
MINOR="${BASH_REMATCH[1]}"
75+
PATCH="${BASH_REMATCH[2]}"
76+
VERSION="v${MAJOR}.${MINOR}.${PATCH}"
77+
elif [[ $INPUT_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
78+
# minor.patch format (X.Y) -> v0.X.Y
79+
VERSION="v${MAJOR}.${INPUT_VERSION}"
80+
elif [[ $INPUT_VERSION =~ ^[0-9]+$ ]]; then
81+
# minor format (X) -> v0.X.0
82+
VERSION="v${MAJOR}.${INPUT_VERSION}.0"
83+
else
84+
echo "❌ Error: Invalid version format '$INPUT_VERSION'. Use 'X', 'X.Y', or 'vX.Y.Z'"
85+
exit 1
86+
fi
87+
else
88+
# Manual run without version - read from version.txt
89+
if [ ! -f version.txt ] || [ -z "$(cat version.txt | tr -d '[:space:]')" ]; then
90+
echo "❌ Error: version.txt not found or empty"
91+
exit 1
92+
fi
93+
VERSION=$(tr -d '[:space:]' < version.txt)
94+
fi
9195
else
92-
# Scheduled run — default to minor bump
93-
PRERELEASE="false"
96+
# Scheduled run or manual run without version - read from version.txt
97+
if [ ! -f version.txt ] || [ -z "$(cat version.txt | tr -d '[:space:]')" ]; then
98+
echo "❌ Error: version.txt not found or empty"
99+
exit 1
100+
fi
101+
VERSION=$(tr -d '[:space:]' < version.txt)
102+
PRERELEASE="true"
94103
RUN_PERF_TEST="true"
95-
BUMP_TYPE="minor"
96104
fi
97-
98-
case "$BUMP_TYPE" in
99-
major)
100-
VERSION="v$((CUR_MAJOR + 1)).0.0"
101-
;;
102-
minor)
103-
VERSION="v${CUR_MAJOR}.$((CUR_MINOR + 1)).0"
104-
;;
105-
patch)
106-
VERSION="v${CUR_MAJOR}.${CUR_MINOR}.$((CUR_PATCH + 1))"
107-
;;
108-
*)
109-
echo "❌ Error: Invalid bump_type '$BUMP_TYPE'. Must be major, minor, or patch."
110-
exit 1
111-
;;
112-
esac
113-
114-
echo "✅ Bumping $CURRENT_VERSION → $VERSION (bump: $BUMP_TYPE, Prerelease: $PRERELEASE, Perf Test: $RUN_PERF_TEST)"
115105
echo "version=$VERSION" >> $GITHUB_OUTPUT
116106
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
117107
echo "run_performance_test=$RUN_PERF_TEST" >> $GITHUB_OUTPUT
108+
echo "✅ Using version: $VERSION (Prerelease: $PRERELEASE, Perf Test: $RUN_PERF_TEST)"
118109
119110
- name: ✅ Validate Release Version
120111
run: |
@@ -139,37 +130,7 @@ jobs:
139130
- name: 🏷️ Update Product Version
140131
run: |
141132
VERSION="${{ steps.get_version.outputs.version }}"
142-
echo "$VERSION" > version.txt
143-
echo "✅ Updated version.txt to $VERSION"
144-
145-
- name: 📝 Update README Version References
146-
run: |
147-
VERSION="${{ steps.get_version.outputs.version }}"
148-
149-
echo "📝 Updating README.md docker-compose curl URL to $VERSION"
150-
151-
# Update the docker-compose.yml curl URL in README.md
152-
sed -i -E "s|(https://raw\.githubusercontent\.com/asgardeo/thunder/)v[0-9]+\.[0-9]+\.[0-9]+(/.+docker-compose\.yml)|\1${VERSION}\2|g" README.md
153-
154-
echo "✅ Updated README.md curl URL to $VERSION"
155-
grep 'docker-compose.yml' README.md
156-
157-
- name: 📤 Commit and Push Version Bump
158-
run: |
159-
VERSION="${{ steps.get_version.outputs.version }}"
160-
161-
git config --local user.name "thunder-automation-bot"
162-
git config --local user.email "thunder-bot@wso2.com"
163-
164-
git add version.txt README.md
165-
166-
if git diff --cached --quiet; then
167-
echo "✅ No changes to commit (files already at $VERSION)"
168-
else
169-
git commit -m "[Release] Bump version to ${VERSION}"
170-
git push origin HEAD:main
171-
echo "✅ Pushed version bump commit to main"
172-
fi
133+
echo "$VERSION" > version.txt
173134
174135
- name: ⚙️ Set up Go Environment
175136
uses: ./.github/actions/setup-go
@@ -483,20 +444,21 @@ jobs:
483444
# Parse version components (handle both X.Y and X.Y.Z formats)
484445
if [[ $RELEASE_VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then
485446
# X.Y.Z format
486-
MAJOR="${BASH_REMATCH[1]}"
487447
MINOR="${BASH_REMATCH[2]}"
488448
PATCH="${BASH_REMATCH[3]}"
489449
elif [[ $RELEASE_VERSION =~ ^([0-9]+)\.([0-9]+) ]]; then
490450
# X.Y format
491-
MAJOR="${BASH_REMATCH[1]}"
492451
MINOR="${BASH_REMATCH[2]}"
493452
PATCH="0"
494453
else
495454
echo "❌ Error: Unable to parse version format: $RELEASE_VERSION"
496455
exit 1
497456
fi
498457
499-
# Bump minor version for next development cycle
458+
# Use fixed major version
459+
MAJOR="${{ env.RELEASE_MAJOR_VERSION }}"
460+
461+
# Bump minor version
500462
NEXT_MINOR=$((MINOR + 1))
501463
NEXT_VERSION="${MAJOR}.${NEXT_MINOR}.0"
502464
@@ -549,6 +511,23 @@ jobs:
549511
cd "$GITHUB_WORKSPACE"
550512
echo "✅ Updated sample apps version to $NEXT_VERSION"
551513
514+
# - name: 📈 Commit and Push Version Update
515+
# run: |
516+
# git config --local user.email "action@github.com"
517+
# git config --local user.name "GitHub Action"
518+
519+
# NEXT_VERSION="${{ steps.next_version.outputs.next_version }}"
520+
521+
# # Add and commit the version changes
522+
# git add version.txt samples/apps/react-vanilla-sample/package.json samples/apps/react-vanilla-sample/server/package.json
523+
524+
# if ! git diff --cached --quiet; then
525+
# git commit -m "[Release] Update version to ${NEXT_VERSION} for the next development iteration"
526+
# git push origin HEAD:main
527+
# echo "✅ Pushed version update to main branch"
528+
# else
529+
# echo "✅ No changes to commit"
530+
# fi
552531

553532
package-samples-linux:
554533
name: 📦 Package Linux & Windows Samples

0 commit comments

Comments
 (0)