Skip to content

Commit 8e86e67

Browse files
committed
Update publish script
1 parent 360ca7c commit 8e86e67

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
id: versions
1919
shell: bash
2020
run: |
21-
declare -r VERSION="$((git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || echo "v0.0.0") \
22-
| cut -c2-)"
21+
declare -r VERSION="$((git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || echo "v0.0.0") | cut -c2-)"
2322
declare -r MAJOR="$(echo "$VERSION" | cut -d. -f1)"
2423
declare -r MINOR="$(echo "$VERSION" | cut -d. -f2)"
2524
declare -r PATCH="$(echo "$VERSION" | cut -d. -f3)"
@@ -60,7 +59,3 @@ jobs:
6059
tag: v${{ steps.versions.outputs.next_version }}
6160
token: ${{ secrets.GITHUB_TOKEN }}
6261

63-
- name: Publish snapshot to maven central
64-
if: "github.ref == 'refs/heads/master'"
65-
shell: bash
66-
run: echo ">>> Publish Snapshot ${{ steps.versions.outputs.next_version }}-SNAPSHOT"

.github/workflows/publish.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ jobs:
2525
java-version: 11
2626
distribution: temurin
2727

28+
- name: Cache gradle
29+
uses: actions/cache@v2
30+
with:
31+
path: |
32+
~/.gradle/caches
33+
~/.gradle/wrapper
34+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
35+
restore-keys: ${{ runner.os }}-gradle
36+
2837
- name: Publish release
2938
if: startsWith(github.ref, 'refs/tags/v')
3039
env:
@@ -44,10 +53,11 @@ jobs:
4453
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
4554
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
4655
run: |
47-
declare -r VERSION="$(git describe --abbrev=0 --tags --match 'v[0-9]*' 2>/dev/null || echo "v0.0.0" | cut -c2-)"
56+
declare -r VERSION="$((git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || echo "v0.0.0") | cut -c2-)"
4857
declare -r MAJOR="$(echo "$VERSION" | cut -d. -f1)"
4958
declare -r MINOR="$(echo "$VERSION" | cut -d. -f2)"
5059
declare -r PATCH="$(echo "$VERSION" | cut -d. -f3)"
5160
declare -r NEXT_VERSION="$MAJOR.$MINOR.$(( $PATCH + 1 ))"
52-
./gradlew publishToSonatype -Pversion="${NEXT_VERSION}-${GITHUB_REF#refs/heads/}-SNAPSHOT" -Ppublish
53-
echo "Published snapshot: ${NEXT_VERSION}-${GITHUB_REF#refs/heads/}-SNAPSHOT"
61+
declare -r MIDDLE="$([ "$GITHUB_REF" == "refs/heads/master" ] && echo "" || echo "-${GITHUB_REF#refs/heads/}")"
62+
./gradlew publishToSonatype -Pversion="${NEXT_VERSION}${MIDDLE}-SNAPSHOT" -Ppublish
63+
echo "Published snapshot: ${NEXT_VERSION}${MIDDLE}-SNAPSHOT"

0 commit comments

Comments
 (0)