feat: unify version management with VERSION file and bump workflow
Add a single VERSION file (0.1.0) as the source of truth for both Go backend and Android app. Makefile reads from VERSION with git describe fallback, build.gradle.kts dynamically loads ../VERSION, and .goreleaser.yaml now has explicit ldflags matching Go variables. Includes a version-bump GitHub Actions workflow for automated semver bumps and a release validation step to ensure tag/VERSION consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6fbf7ea829
commit
a660c7e68f
6 changed files with 76 additions and 2 deletions
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
|
|
@ -30,6 +30,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Validate version
|
||||||
|
env:
|
||||||
|
TAG_VERSION: ${{ inputs.tag }}
|
||||||
|
run: |
|
||||||
|
FILE_VERSION=$(cat VERSION)
|
||||||
|
TAG_VERSION="${TAG_VERSION#v}"
|
||||||
|
if [ "$FILE_VERSION" != "$TAG_VERSION" ]; then
|
||||||
|
echo "::error::Tag ($TAG_VERSION) ≠ VERSION file ($FILE_VERSION). Run version-bump first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create and push tag
|
- name: Create and push tag
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
|
|
||||||
54
.github/workflows/version-bump.yml
vendored
Normal file
54
.github/workflows/version-bump.yml
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
name: Version Bump
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
bump:
|
||||||
|
description: "Semver bump type"
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- patch
|
||||||
|
- minor
|
||||||
|
- major
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Read current version
|
||||||
|
id: current
|
||||||
|
run: echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Calculate next version
|
||||||
|
id: next
|
||||||
|
run: |
|
||||||
|
IFS='.' read -r major minor patch <<< "${{ steps.current.outputs.version }}"
|
||||||
|
case "${{ inputs.bump }}" in
|
||||||
|
major) major=$((major+1)); minor=0; patch=0 ;;
|
||||||
|
minor) minor=$((minor+1)); patch=0 ;;
|
||||||
|
patch) patch=$((patch+1)) ;;
|
||||||
|
esac
|
||||||
|
echo "version=${major}.${minor}.${patch}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Update VERSION file
|
||||||
|
run: echo "${{ steps.next.outputs.version }}" > VERSION
|
||||||
|
|
||||||
|
- name: Increment versionCode
|
||||||
|
run: |
|
||||||
|
FILE=android/app/build.gradle.kts
|
||||||
|
CODE=$(grep -oP 'versionCode\s*=\s*\K\d+' "$FILE")
|
||||||
|
sed -i "s/versionCode\s*=\s*[0-9]\+/versionCode = $((CODE+1))/" "$FILE"
|
||||||
|
echo "versionCode: $CODE -> $((CODE+1))"
|
||||||
|
|
||||||
|
- name: Commit and push
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git add VERSION android/app/build.gradle.kts
|
||||||
|
git commit -m "chore: bump version to ${{ steps.next.outputs.version }}"
|
||||||
|
git push
|
||||||
|
|
@ -18,6 +18,11 @@ builds:
|
||||||
- arm64
|
- arm64
|
||||||
- arm
|
- arm
|
||||||
main: ./cmd/clawdroid
|
main: ./cmd/clawdroid
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X main.version={{.Version}}
|
||||||
|
- -X main.gitCommit={{.Commit}}
|
||||||
|
- -X main.buildTime={{.Date}}
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- formats: [tar.gz]
|
- formats: [tar.gz]
|
||||||
|
|
|
||||||
2
Makefile
2
Makefile
|
|
@ -7,7 +7,7 @@ CMD_DIR=cmd/$(BINARY_NAME)
|
||||||
MAIN_GO=$(CMD_DIR)/main.go
|
MAIN_GO=$(CMD_DIR)/main.go
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
VERSION?=$(shell cat VERSION 2>/dev/null || git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||||
GIT_COMMIT=$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo "dev")
|
GIT_COMMIT=$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo "dev")
|
||||||
BUILD_TIME=$(shell date +%FT%T%z)
|
BUILD_TIME=$(shell date +%FT%T%z)
|
||||||
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
|
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
|
||||||
|
|
|
||||||
1
VERSION
Normal file
1
VERSION
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
0.1.0
|
||||||
|
|
@ -13,6 +13,9 @@ val keystoreProperties = Properties().apply {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val versionFile = rootProject.file("../VERSION")
|
||||||
|
val appVersionName = if (versionFile.exists()) versionFile.readText().trim() else "0.1.0"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "io.clawdroid"
|
namespace = "io.clawdroid"
|
||||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||||
|
|
@ -22,7 +25,7 @@ android {
|
||||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0.0"
|
versionName = appVersionName
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue