mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
feat(流水线): github的流水线配置
This commit is contained in:
82
.github/workflows/release.yml
vendored
82
.github/workflows/release.yml
vendored
@@ -1,27 +1,33 @@
|
|||||||
name: Release to Maven Central
|
name: 发布到 Maven Central
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [released]
|
types: [created]
|
||||||
|
# 可选:也可以手动触发
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Git Repo
|
- name: 检出代码
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up Maven Central Repo
|
- name: 设置 JDK 1.8
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: 1.8
|
java-version: '8'
|
||||||
server-id: central
|
distribution: 'temurin'
|
||||||
server-username: ${{ secrets.OSSRH_USER }}
|
cache: 'maven'
|
||||||
server-password: ${{ secrets.OSSRH_PASSWORD }}
|
|
||||||
gpg-passphrase: ${{ secrets.GPG_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Configure GPG for CI
|
- name: 配置 GPG 密钥
|
||||||
run: |
|
run: |
|
||||||
|
# 导入 GPG 密钥
|
||||||
|
echo "${{ secrets.GPG_SECRET }}" | base64 --decode > private.key
|
||||||
|
gpg --batch --import private.key
|
||||||
|
rm private.key
|
||||||
|
|
||||||
|
# 配置 GPG 为非交互模式
|
||||||
mkdir -p ~/.gnupg/
|
mkdir -p ~/.gnupg/
|
||||||
echo "use-agent" > ~/.gnupg/gpg.conf
|
echo "use-agent" > ~/.gnupg/gpg.conf
|
||||||
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
|
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
|
||||||
@@ -30,11 +36,47 @@ jobs:
|
|||||||
chmod 600 ~/.gnupg/*
|
chmod 600 ~/.gnupg/*
|
||||||
gpg-connect-agent reloadagent /bye
|
gpg-connect-agent reloadagent /bye
|
||||||
|
|
||||||
- name: Publish to Maven Central Repo
|
- name: 创建 Maven 设置文件
|
||||||
uses: samuelmeuli/action-maven-publish@v1
|
run: |
|
||||||
with:
|
cat > settings.xml << EOF
|
||||||
gpg_private_key: ${{ secrets.GPG_SECRET }}
|
<settings>
|
||||||
gpg_passphrase: ${{ secrets.GPG_PASSWORD }}
|
<servers>
|
||||||
nexus_username: ${{ secrets.OSSRH_USER }}
|
<server>
|
||||||
nexus_password: ${{ secrets.OSSRH_PASSWORD }}
|
<id>ossrh</id>
|
||||||
maven_args: "-Dmaven.deploy.skip=false -DaltDeploymentRepository=central::default::https://central.sonatype.com/service/local/staging/deploy/maven2/"
|
<username>${{ secrets.OSSRH_USER }}</username>
|
||||||
|
<password>${{ secrets.OSSRH_PASSWORD }}</password>
|
||||||
|
</server>
|
||||||
|
<!-- 备用服务器 ID,以防某些插件使用不同的 ID -->
|
||||||
|
<server>
|
||||||
|
<id>central</id>
|
||||||
|
<username>${{ secrets.OSSRH_USER }}</username>
|
||||||
|
<password>${{ secrets.OSSRH_PASSWORD }}</password>
|
||||||
|
</server>
|
||||||
|
<server>
|
||||||
|
<id>sonatype-nexus-staging</id>
|
||||||
|
<username>${{ secrets.OSSRH_USER }}</username>
|
||||||
|
<password>${{ secrets.OSSRH_PASSWORD }}</password>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<gpg.executable>gpg</gpg.executable>
|
||||||
|
<gpg.passphrase>${{ secrets.GPG_PASSWORD }}</gpg.passphrase>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
</settings>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: 构建并发布到 Maven Central
|
||||||
|
run: |
|
||||||
|
mvn clean deploy \
|
||||||
|
--batch-mode \
|
||||||
|
--settings settings.xml \
|
||||||
|
-Dgpg.passphrase="${{ secrets.GPG_PASSWORD }}" \
|
||||||
|
-DskipTests=true
|
||||||
|
|||||||
Reference in New Issue
Block a user