Skip to content

fix: publish to maven central repo (#27) #11

fix: publish to maven central repo (#27)

fix: publish to maven central repo (#27) #11

Workflow file for this run

name: Java CI with Maven

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 47, Col: 5): Unexpected value 'publish'
# Run workflow on commits to the `master` branch
on:
push:
branches:
- master
jobs:
build-and-release:
permissions: write-all
runs-on: ubuntu-latest
environment: production
steps:
# 下载代码
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
# 安装 JDK
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Maven Settings XML
uses: whelk-io/maven-settings-xml-action@v20
with:
repositories: ''
servers: ''
- name: Build with Maven
run: mvn -B -DskipTests package --file pom.xml
- run: mkdir staging && cp target/*.jar staging
- name: Set Release version env variable
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Build and Test
run: |
echo "done!"
- name: Publish Tag and Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ env.RELEASE_VERSION }}"
prerelease: false
title: "Release v${{ env.RELEASE_VERSION }}"
files: |
staging/*.jar
publish:
needs: build-and-release
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
server-id: central
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Deploy to Sonatype Central
run: mvn clean deploy -DskipTests -B
env:
CENTRAL_USERNAME: ${{ secrets.OSSRH_USERNAME }}
CENTRAL_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}