Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4a7bad

Browse files
committedMar 15, 2025·
Split into multiple files
1 parent 311c19b commit d4a7bad

File tree

2 files changed

+65
-73
lines changed

2 files changed

+65
-73
lines changed
 

‎.github/workflows/build.yml

+1-73
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Build
22

33
on:
4-
push:
5-
branches: [ main, master ]
64
pull_request:
75
branches: [ main, master ]
86

@@ -24,74 +22,4 @@ jobs:
2422
cache-read-only: false
2523
gradle-home-cache-cleanup: true
2624
- 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

‎.github/workflows/publish.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ main, master, github_actions ]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
environment: production
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up JDK 8
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: '8'
17+
distribution: 'temurin'
18+
cache: 'gradle'
19+
- name: Setup Gradle
20+
uses: gradle/gradle-build-action@v2
21+
- name: Set release version
22+
run: |
23+
# Remove -SNAPSHOT from version
24+
sed -i 's/\(version "[0-9.]*\)-SNAPSHOT"/\1"/' build.gradle
25+
- name: Publish package
26+
env:
27+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
28+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
29+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
30+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
31+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
32+
run: |
33+
./gradlew uploadArchives
34+
- name: Bump version
35+
id: bump_version
36+
run: |
37+
# Get current version without SNAPSHOT
38+
CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/')
39+
40+
# Split into parts
41+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
42+
43+
# Increment patch version
44+
NEXT_PATCH=$((VERSION_PARTS[2] + 1))
45+
46+
# Create new version
47+
NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT"
48+
49+
# Update build.gradle
50+
sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle
51+
52+
# Make the new version available to other steps
53+
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
54+
- name: Commit version bump
55+
env:
56+
NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }}
57+
BRANCH_NAME: github_actions
58+
run: |
59+
git config user.name "github-actions[bot]"
60+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+
git add --all
62+
git commit -m "Prepare version $NEXT_VERSION for development [skip ci]"
63+
git pull --rebase origin $BRANCH_NAME
64+
git push origin HEAD:$BRANCH_NAME

0 commit comments

Comments
 (0)
Please sign in to comment.