-
Notifications
You must be signed in to change notification settings - Fork 11
72 lines (64 loc) · 2.8 KB
/
publish-release-maven-central.yml
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
# This workflow uploads the releases to the Maven Central Repository
name: Publish Release to Maven Central
on:
release:
types:
- released
- prereleased
env:
SEMANTIC_VERSION: ${{ github.event.release.tag_name }}
SONATYPE_PROFILE_ID: 33839da457341f
jobs:
upload-maven-central:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up JDK 17
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
distribution: 'temurin'
java-version: 17
cache: 'gradle'
- name: Build and Sign packages
run: ./gradlew --parallel signMavenPublication
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PRIVATE_KEY_SECRET }}
- name: Create Staging Repository
id: create-staging-repo
run: |
ID=`echo "<promoteRequest><data><description>Created from GitHub Action for version $SEMANTIC_VERSION</description></data></promoteRequest>" \
| curl -X POST \
-d @- \
-u $SDA_SONATYPE_USER:$SDA_SONATYPE_PASSWORD \
-H "Content-Type:application/xml" \
https://oss.sonatype.org/service/local/staging/profiles/$SONATYPE_PROFILE_ID/start \
| sed -n 's:.*<stagedRepositoryId>\(.*\)</stagedRepositoryId>.*:\1:p'`
echo "STAGING_PROFILE_ID=$ID" >> $GITHUB_OUTPUT
env:
SDA_SONATYPE_USER: ${{ secrets.SDA_SONATYPE_USER }}
SDA_SONATYPE_PASSWORD: ${{ secrets.SDA_SONATYPE_PASSWORD }}
- name: Upload to Maven Central
run: ./gradlew publishMavenPublicationToMavenCentralRepository closeAndReleaseRepository
env:
SDA_SONATYPE_USER: ${{ secrets.SDA_SONATYPE_USER }}
SDA_SONATYPE_PASSWORD: ${{ secrets.SDA_SONATYPE_PASSWORD }}
SONATYPE_STAGING_REPOSITORY_ID: ${{ steps.create-staging-repo.outputs.STAGING_PROFILE_ID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PRIVATE_KEY_SECRET }}
- uses: 8398a7/action-slack@v3
with:
status: custom
fields: workflow,job,commit,repo,ref,author,took
custom_payload: |
{
username: 'Maven Central Upload',
icon_emoji: ':coffin-dance:',
attachments: [{
color: 'danger',
text: `Maven Central Upload of sda-dropwizard-commons:${{ github.event.release.tag_name }} failed!\n\nWorkflow ${process.env.AS_WORKFLOW}`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: failure()