-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (71 loc) · 2.84 KB
/
callable.gradle-release.yml
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
name: Gradle Release
on:
workflow_call:
inputs:
type:
description: 'Release type'
required: true
type: string
jobs:
release:
name: gradle release
runs-on: ubuntu-latest
steps:
- name: Validate 'Release Type' param
env:
TYPE: ${{ inputs.type }}
run: |
valid_types=(major minor patch)
if [[ ! ${valid_types[*]} =~ "$TYPE" ]]; then
echo "Unknown release type: $TYPE"
exit 1
fi
- name: Checkout project sources ('main' branch)
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.CI_GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
- uses: gradle/actions/wrapper-validation@v3
- name: Setup Gradle
uses: gradle/actions/[email protected]
with:
cache-read-only: true
- name: Get current version
run: |
source gradle.properties
echo "current_version=${version}" >> $GITHUB_ENV
- name: Determine version type
env:
TYPE: ${{ inputs.type }}
VERSION: ${{ env.current_version }}
run: |
export major=$(echo "${VERSION}" | cut -d. -f1)
export minor=$(echo "${VERSION}" | cut -d. -f2)
export patch=$(echo "${VERSION}" | cut -d. -f3 | cut -d- -f1)
echo "resolved: ${major}.${minor}.${patch}"
if [[ "$TYPE" == "major" ]]; then
echo "new_version=$((major+1)).0.0" >> $GITHUB_ENV
echo "new_snapshot_version=$((major+1)).0.1-SNAPSHOT" >> $GITHUB_ENV
elif [ "$TYPE" == "minor" ]; then
echo "new_version=${major}.$((minor+1)).0" >> $GITHUB_ENV
echo "new_snapshot_version=${major}.$((minor+1)).1-SNAPSHOT" >> $GITHUB_ENV
else
echo "new_version=${major}.${minor}.${patch}" >> $GITHUB_ENV
echo "new_snapshot_version=${major}.${minor}.$((patch+1))-SNAPSHOT" >> $GITHUB_ENV
fi
- name: Set git config 'user.name' and 'user.email'
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
- name: Run 'gradle release'
run: |
echo "Type: ${{ inputs.type }}"
echo "Current version: ${{ env.current_version }}"
echo "New version: ${{ env.new_version }}"
echo "New snapshot version: ${{ env.new_snapshot_version }}"
echo "./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.new_version }} -Prelease.newVersion=${{ env.new_snapshot_version }}"
gradle release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.new_version }} -Prelease.newVersion=${{ env.new_snapshot_version }}