[UPDATE] 更新持续集成,支持发布到 Maven Central 和 GitHub Packages #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish packages | |
on: | |
push: | |
branches: | |
- master | |
- '*.x' | |
jobs: | |
publish-to-github-packages: | |
name: Publish to GitHub Packages | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: zulu | |
server-id: github | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
gpg-passphrase: GPG_PASSPHRASE | |
- name: Echo settings.xml | |
run: cat /home/runner/.m2/settings.xml | |
- name: Publish packages | |
run: mvn -P github --batch-mode clean deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.GHPKG_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.GHPKG_TOKEN }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
publish-to-maven-central: | |
name: Publish to Maven Central | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: zulu | |
server-id: sonatype | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
gpg-passphrase: GPG_PASSPHRASE | |
- name: Echo settings.xml | |
run: cat /home/runner/.m2/settings.xml | |
- name: Publish packages | |
run: mvn -P sonatype --batch-mode clean deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |