@@ -3,35 +3,82 @@ name: Release Sourcebot
33on :
44 workflow_dispatch :
55 inputs :
6- version :
7- description : " Version to release (e.g., 4.10.5) "
6+ bump_type :
7+ description : " Type of version bump to apply "
88 required : true
9- type : string
9+ type : choice
10+ options :
11+ - patch
12+ - minor
13+ - major
14+
15+ concurrency :
16+ group : release-sourcebot
17+ cancel-in-progress : false
1018
1119jobs :
1220 release :
1321 runs-on : ubuntu-latest
1422 permissions :
1523 contents : write
24+ outputs :
25+ version : ${{ steps.calculate_version.outputs.version }}
1626
1727 steps :
18- - name : Validate version format
19- run : |
20- VERSION="${{ inputs.version }}"
21- if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._-]+)?(\+[a-zA-Z0-9._-]+)?$ ]]; then
22- echo "Error: Version must follow semantic versioning format (X.Y.Z)"
23- exit 1
24- fi
25-
2628 - name : Checkout repository
2729 uses : actions/checkout@v4
2830 with :
2931 ref : main
3032 fetch-depth : 0
3133
34+ - name : Calculate new version
35+ id : calculate_version
36+ run : |
37+ # Extract current version from CHANGELOG.md
38+ CURRENT_VERSION=$(grep -oP '## \[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md | head -n 1)
39+
40+ if [ -z "$CURRENT_VERSION" ]; then
41+ echo "Error: Could not extract current version from CHANGELOG.md"
42+ exit 1
43+ fi
44+
45+ echo "Current version: $CURRENT_VERSION"
46+
47+ # Parse version components
48+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
49+
50+ # Apply bump based on input
51+ BUMP_TYPE="${{ inputs.bump_type }}"
52+ case "$BUMP_TYPE" in
53+ major)
54+ MAJOR=$((MAJOR + 1))
55+ MINOR=0
56+ PATCH=0
57+ ;;
58+ minor)
59+ MINOR=$((MINOR + 1))
60+ PATCH=0
61+ ;;
62+ patch)
63+ PATCH=$((PATCH + 1))
64+ ;;
65+ *)
66+ echo "Error: Invalid bump type: $BUMP_TYPE"
67+ exit 1
68+ ;;
69+ esac
70+
71+ NEW_VERSION="$MAJOR.$MINOR.$PATCH"
72+ echo "New version: $NEW_VERSION"
73+
74+ # Export to GITHUB_ENV for use in subsequent steps within this job
75+ echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
76+
77+ # Export to GITHUB_OUTPUT for use in other jobs
78+ echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
79+
3280 - name : Check if version already exists
3381 run : |
34- VERSION="${{ inputs.version }}"
3582 if grep -q "## \[$VERSION\]" CHANGELOG.md; then
3683 echo "Error: Version $VERSION already exists in CHANGELOG.md"
3784 exit 1
4390
4491 - name : Update CHANGELOG.md and version.ts
4592 run : |
46- VERSION="${{ inputs.version }}"
4793 DATE=$(date +%Y-%m-%d)
4894
4995 # Insert the new version header after the [Unreleased] line
@@ -69,13 +115,11 @@ jobs:
69115
70116 - name : Commit changes
71117 run : |
72- VERSION="${{ inputs.version }}"
73118 git add CHANGELOG.md packages/shared/src/version.ts
74119 git commit -m "Release v$VERSION"
75120
76121 - name : Create annotated tag
77122 run : |
78- VERSION="${{ inputs.version }}"
79123 git tag -a "v$VERSION" -m "sourcebot v$VERSION"
80124
81125 - name : Push changes
87131 env :
88132 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89133 run : |
90- VERSION="${{ inputs.version }}"
91134 gh release create "v$VERSION" \
92135 --verify-tag \
93136 --generate-notes \
97140 needs : release
98141 uses : ./.github/workflows/ghcr-publish.yml
99142 with :
100- version : v${{ inputs .version }}
143+ version : v${{ needs.release.outputs .version }}
101144 permissions :
102145 contents : read
103146 packages : write
0 commit comments