Repository navigation
99 lines (95 loc) · 3.61 KB
/
Copy pathrelease.yml
File metadata and controls
99 lines (95 loc) · 3.61 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
on:
push:
branches: [ master ]
# Manual run: publishes the current build.gradle version to Maven Central
# without creating a tag / GitHub release (e.g. to retry a failed publish).
workflow_dispatch:
jobs:
check-release-tag:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare tag
id: prepare_tag
continue-on-error: true
run: |
export TAG=v$(awk '/^version = / { gsub("\"", ""); print $3 }' build.gradle)
echo "TAG=$TAG" >> $GITHUB_ENV
export CHECK_TAG=$(git tag | grep $TAG)
if [[ $CHECK_TAG ]]; then
echo "Skipping because release tag already exists"
exit 1
fi
- name: Output
id: release_output
if: ${{ steps.prepare_tag.outcome == 'success' }}
run: |
echo "tag=${{ env.TAG }}" >> $GITHUB_OUTPUT
outputs:
tag: ${{ steps.release_output.outputs.tag }}
create-github-release:
runs-on: ubuntu-latest
needs: check-release-tag
if: ${{ needs.check-release-tag.outputs.tag }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Prepare tag
run: |
export TAG=v$(awk '/^version = / { gsub("\"", ""); print $3 }' build.gradle)
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Prepare description
run: |
csplit -s CHANGELOG.md "/##/" {1}
cat xx01 > CHANGELOG.tmp
- name: Create Release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
tag_name: ${{ env.TAG }}
name: ${{ env.TAG }}
body_path: CHANGELOG.tmp
draft: false
prerelease: false
publish:
runs-on: ubuntu-latest
needs: create-github-release
if: ${{ always() && (needs.create-github-release.result == 'success' || github.event_name == 'workflow_dispatch') }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "temurin"
- name: Create gradle.properties
shell: bash
run: |
mkdir -p _gradle_user_home
echo "GRADLE_USER_HOME=_gradle_user_home" >> $GITHUB_ENV
cat <<FILE > _gradle_user_home/gradle.properties
maven.username=${{ secrets.MAVEN_USERNAME }}
maven.password=${{ secrets.MAVEN_PASSWORD }}
signing.keyId=${{ secrets.SIGNING_KEY_ID }}
signing.password=${{ secrets.SIGNING_PASSWORD }}
signing.secretKeyRingFile=_gradle_user_home/pusher-maven-gpg-signing-key.gpg
FILE
echo "${{ secrets.PUSHER_MAVEN_GPG_SIGNING_KEY }}" | base64 --decode > _gradle_user_home/pusher-maven-gpg-signing-key.gpg
- name: Upload to Sonatype staging
run: ./gradlew publish
# Hands the uploaded staging repository to the Central Portal, which
# validates it and releases it to Maven Central. Must run from the same
# job (same IP address) as the upload above.
- name: Release to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: |
TOKEN=$(printf '%s:%s' "$MAVEN_USERNAME" "$MAVEN_PASSWORD" | base64 -w0)
curl --fail-with-body -sS -X POST \
-H "Authorization: Bearer $TOKEN" \
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.pusher?publishing_type=automatic"