-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (62 loc) · 2.48 KB
/
Copy pathpublish.yml
File metadata and controls
72 lines (62 loc) · 2.48 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
name: Publish
# Mirrors the testingbot-java release flow: publish on a version tag, sign with GPG,
# push to Maven Central (Central Portal), and attach artifacts to a GitHub Release.
# This repo additionally publishes to the Gradle Plugin Portal (the primary way users
# apply a Gradle plugin).
#
# Triggers on version tags with or without a leading "v" (e.g. 0.1.0 or v0.1.0), and
# can also be started manually from the Actions tab (workflow_dispatch), which publishes
# whatever VERSION_NAME is set in gradle.properties.
on:
push:
tags: [ 'v*', '[0-9]*' ]
workflow_dispatch: {}
permissions:
contents: read
jobs:
publish:
name: Publish to Gradle Plugin Portal and Maven Central
runs-on: ubuntu-latest
environment: release
permissions:
contents: write # create the GitHub Release
steps:
- uses: actions/checkout@v7
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v6
- name: Verify the tag matches VERSION_NAME
if: github.ref_type == 'tag'
run: |
VERSION=$(grep '^VERSION_NAME=' gradle.properties | cut -d= -f2)
TAG=${GITHUB_REF_NAME#v}
echo "gradle.properties VERSION_NAME=$VERSION, tag=$TAG"
if [ "$VERSION" != "$TAG" ]; then
echo "::error::Release tag ($TAG) does not match VERSION_NAME ($VERSION)."
exit 1
fi
- name: Build and test
run: ./gradlew build --stacktrace
- name: Publish to Gradle Plugin Portal
run: ./gradlew publishPlugins --stacktrace
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
- name: Publish to Maven Central
run: ./gradlew publishToMavenCentral --stacktrace
env:
# Reuses the same org secrets as testingbot-java.
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
- name: Create GitHub Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v3
with:
files: build/libs/*.jar
generate_release_notes: true