-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (74 loc) · 3.19 KB
/
release.yml
File metadata and controls
86 lines (74 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Multi-Release
on:
workflow_dispatch:
inputs:
release-body:
description: "Changelog for this release"
type: string
required: false
default: "Manual release from build branch."
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository (Master)
uses: actions/checkout@v4
with:
ref: master
path: master-repo
fetch-depth: 0
- name: Bump version if needed
id: version_check
shell: bash
run: |
cd master-repo
git config user.name "github-actions"
git config user.email "github-actions@github.com"
# Function to increment patch version
increment_version() {
local v=$1
local major=$(echo $v | cut -d. -f1)
local minor=$(echo $v | cut -d. -f2)
local patch=$(echo $v | cut -d. -f3)
echo "$major.$minor.$((patch + 1))"
}
# Load version from gradle.properties
VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2)
git fetch --tags
# Check if tag already exists and increment version until it's unique
while git rev-parse "v$VERSION" >/dev/null 2>&1; do
echo "Tag v$VERSION already exists. Counting up..."
VERSION=$(increment_version $VERSION)
done
# Get current version again for comparison
CURRENT_VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2)
if [ "$VERSION" != "$CURRENT_VERSION" ]; then
echo "Updating version in gradle.properties to $VERSION"
sed -i "s/mod_version=$CURRENT_VERSION/mod_version=$VERSION/" gradle.properties
git add gradle.properties
git commit -m "chore: bump version to $VERSION [skip ci]"
git push origin master
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Checkout Build branch
uses: actions/checkout@v4
with:
ref: build
path: build-artifacts
- name: Push Tag
run: |
cd master-repo
git tag v${{ steps.version_check.outputs.version }}
git push origin v${{ steps.version_check.outputs.version }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version_check.outputs.version }}
name: Release v${{ steps.version_check.outputs.version }}
body: ${{ github.event.inputs.release-body }}
generate_release_notes: true
files: build-artifacts/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}