1
1
name : Build
2
2
3
3
on :
4
- push :
5
- branches : [ main, master ]
6
4
pull_request :
7
5
branches : [ main, master ]
8
6
24
22
cache-read-only : false
25
23
gradle-home-cache-cleanup : true
26
24
- name : Build
27
- run : ./gradlew build
28
- - name : Upload build artifacts
29
- uses : actions/upload-artifact@v4
30
- with :
31
- name : build-artifacts
32
- path : build/
33
-
34
- publish :
35
- needs : build
36
- if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
37
- runs-on : ubuntu-latest
38
- environment : production
39
- steps :
40
- - uses : actions/checkout@v4
41
- - name : Set up JDK 8
42
- uses : actions/setup-java@v3
43
- with :
44
- java-version : ' 8'
45
- distribution : ' temurin'
46
- cache : ' gradle'
47
- - name : Setup Gradle
48
- uses : gradle/gradle-build-action@v2
49
- - name : Download build artifacts
50
- uses : actions/download-artifact@v4
51
- with :
52
- name : build-artifacts
53
- path : build/
54
- - name : Set release version
55
- run : |
56
- # Remove -SNAPSHOT from version
57
- sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle
58
- - name : Publish package
59
- env :
60
- SONATYPE_USERNAME : ${{ secrets.SONATYPE_USERNAME }}
61
- SONATYPE_PASSWORD : ${{ secrets.SONATYPE_PASSWORD }}
62
- SIGNING_KEY_ID : ${{ secrets.SIGNING_KEY_ID }}
63
- SIGNING_PASSWORD : ${{ secrets.SIGNING_PASSWORD }}
64
- SIGNING_KEY : ${{ secrets.SIGNING_KEY }}
65
- run : |
66
- ./gradlew uploadArchives
67
- - name : Bump version
68
- id : bump_version
69
- run : |
70
- # Get current version without SNAPSHOT
71
- CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/')
72
-
73
- # Split into parts
74
- IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
75
-
76
- # Increment patch version
77
- NEXT_PATCH=$((VERSION_PARTS[2] + 1))
78
-
79
- # Create new version
80
- NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT"
81
-
82
- # Update build.gradle
83
- sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle
84
-
85
- # Make the new version available to other steps
86
- echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
87
- - name : Commit version bump
88
- env :
89
- NEXT_VERSION : ${{ steps.bump_version.outputs.next_version }}
90
- BRANCH_NAME : main
91
- run : |
92
- git config user.name "github-actions[bot]"
93
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
94
- git add --all
95
- git commit -m "Prepare version $NEXT_VERSION for development [skip ci]"
96
- git pull --rebase origin $BRANCH_NAME
97
- git push origin HEAD:$BRANCH_NAME
25
+ run : ./gradlew build
0 commit comments