新增 action 发布 maven 脚本
This commit is contained in:
parent
696f523e01
commit
163d576b73
35
.github/workflows/publish.yml
vendored
Normal file
35
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: Publish package to the Maven Central Repository
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build without tests
|
||||
run: ./gradlew build -x test
|
||||
|
||||
- name: Decode
|
||||
run: |
|
||||
echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64
|
||||
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
|
||||
|
||||
- name: Publish
|
||||
run: ./gradlew publish -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg)
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
|
@ -187,15 +187,13 @@ subprojects {
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
def userName = System.getProperty("un")
|
||||
def passWord = System.getProperty("ps")
|
||||
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
|
||||
credentials {
|
||||
username userName
|
||||
password passWord
|
||||
username System.getenv("MAVEN_USERNAME")
|
||||
password System.getenv("MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user