Skip to content

Commit 334b2f8

Browse files
committedMar 12, 2025·
Test publish step
1 parent 90f3b56 commit 334b2f8

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed
 

‎.github/workflows/build.yml

+70-4
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,88 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
12+
environment: snapshot
1313
steps:
1414
- uses: actions/checkout@v3
15-
1615
- name: Set up JDK 8
1716
uses: actions/setup-java@v3
1817
with:
1918
java-version: '8'
2019
distribution: 'temurin'
2120
cache: 'gradle'
22-
2321
- name: Setup Gradle
2422
uses: gradle/gradle-build-action@v2
2523
with:
2624
cache-read-only: false
2725
gradle-home-cache-cleanup: true
28-
2926
- name: Build
3027
run: ./gradlew build
28+
- name: Upload build artifacts
29+
uses: actions/upload-artifact@v3
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@v3
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@v3
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+
echo "${{ secrets.SIGNING_KEY }}" | base64 -d > signing.gpg
67+
./gradlew uploadArchives -Psigning.secretKeyRingFile=$(pwd)/signing.gpg -Psigning.keyId=$SIGNING_KEY_ID -Psigning.password=$SIGNING_PASSWORD
68+
- name: Bump version
69+
id: bump_version
70+
run: |
71+
# Get current version without SNAPSHOT
72+
CURRENT_VERSION=$(grep "version" build.gradle | sed 's/version "\(.*\)"/\1/')
73+
74+
# Split into parts
75+
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
76+
77+
# Increment patch version
78+
NEXT_PATCH=$((VERSION_PARTS[2] + 1))
79+
80+
# Create new version
81+
NEXT_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$NEXT_PATCH-SNAPSHOT"
82+
83+
# Update build.gradle
84+
sed -i "s/version \".*\"/version \"$NEXT_VERSION\"/" build.gradle
85+
86+
# Make the new version available to other steps
87+
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
88+
- name: Commit version bump
89+
env:
90+
NEXT_VERSION: ${{ steps.bump_version.outputs.next_version }}
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 push

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.idea/
33
out/
44
build/
5-
.DS_Store
5+
.DS_Store
6+
secring.gpg

0 commit comments

Comments
 (0)