-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (58 loc) · 2.4 KB
/
Copy pathpublish.yml
File metadata and controls
71 lines (58 loc) · 2.4 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
name: Java release with Gradle
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Decode GPG key
run: echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" | base64 --decode > ./secring.gpg
- name: Create gradle.properties
run: |
echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties
echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties
echo "signing.secretKeyRingFile=./../secring.gpg" >> gradle.properties
echo "ossrhUsername=${{ secrets.OSSRH_USERNAME }}" >> gradle.properties
echo "ossrhPassword=${{ secrets.OSSRH_PASSWORD }}" >> gradle.properties
- name: Build with Gradle
run: ./gradlew build
- name: Prepare Central bundle
run: ./gradlew prepareCentralBundle
- name: Upload bundle to Central Portal
env:
CENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: |
chmod +x .github/scripts/upload_central.sh
.github/scripts/upload_central.sh build/central-bundle.zip
- name: Tag and update version
run: |
# Extract current version from gradle.properties
VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2)
echo "Current version: $VERSION"
# Create and push the tag for the current version
git tag "v$VERSION"
git push origin "v$VERSION"
# Increment version for the next cycle (bump patch)
NEW_VERSION=$(echo $VERSION | awk -F. '{ $NF = $NF + 1; print $0 }' OFS='.')
echo "New version: $NEW_VERSION"
# Update gradle.properties with the new version
sed -i "s/^version=.*/version=$NEW_VERSION/" gradle.properties
# Commit the change
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add gradle.properties
git commit -m "Increment version to $NEW_VERSION [skip ci]"
# Push the commit
git push origin HEAD:${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}