|
1 | 1 | name: Build and Release |
2 | 2 |
|
3 | | -on: |
4 | | - push: |
5 | | - branches: |
6 | | - - master |
7 | | - tags: |
8 | | - - 'v*' |
| 3 | +on: |
9 | 4 | workflow_dispatch: |
10 | 5 | inputs: |
11 | 6 | version: |
12 | 7 | description: 'Version to release (e.g., 8.0.1)' |
13 | | - required: true |
| 8 | + required: false |
14 | 9 | type: string |
15 | 10 | auto_release: |
16 | 11 | description: 'Automatically create GitHub release' |
17 | | - required: true |
| 12 | + required: false |
18 | 13 | type: boolean |
19 | 14 | default: false |
20 | 15 |
|
@@ -55,21 +50,28 @@ jobs: |
55 | 50 | - name: Determine version |
56 | 51 | id: version |
57 | 52 | run: | |
58 | | - # Use version from latest git tag, fallback to build.gradle.kts if no tags exist |
59 | | - git fetch --tags |
60 | | - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
61 | | - |
62 | | - if [ -n "$LATEST_TAG" ]; then |
63 | | - # Remove 'v' or 'V' prefix if present |
64 | | - VERSION=${LATEST_TAG#v} |
65 | | - VERSION=${VERSION#V} |
66 | | - echo "Using version from git tag: $VERSION" |
| 53 | + INPUT_VERSION="${{ github.event.inputs.version }}" |
| 54 | +
|
| 55 | + if [ -n "$INPUT_VERSION" ]; then |
| 56 | + VERSION="$INPUT_VERSION" |
| 57 | + echo "Using version from manual input: $VERSION" |
67 | 58 | else |
68 | | - # Fallback to build.gradle.kts |
69 | | - VERSION=$(grep '^version = ' build.gradle.kts | head -1 | sed 's/.*"\(.*\)".*/\1/') |
70 | | - echo "No git tags found, using version from build.gradle.kts: $VERSION" |
| 59 | + # Use version from latest git tag, fallback to build.gradle.kts if no tags exist |
| 60 | + git fetch --tags |
| 61 | + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") |
| 62 | +
|
| 63 | + if [ -n "$LATEST_TAG" ]; then |
| 64 | + # Remove 'v' or 'V' prefix if present |
| 65 | + VERSION=${LATEST_TAG#v} |
| 66 | + VERSION=${VERSION#V} |
| 67 | + echo "Using version from git tag: $VERSION" |
| 68 | + else |
| 69 | + # Fallback to build.gradle.kts |
| 70 | + VERSION=$(grep '^version = ' build.gradle.kts | head -1 | sed 's/.*"\(.*\)".*/\1/') |
| 71 | + echo "No git tags found, using version from build.gradle.kts: $VERSION" |
| 72 | + fi |
71 | 73 | fi |
72 | | - |
| 74 | +
|
73 | 75 | echo "version=$VERSION" >> $GITHUB_OUTPUT |
74 | 76 | echo "Building version: $VERSION" |
75 | 77 |
|
|
0 commit comments