-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (67 loc) · 2.14 KB
/
release.yml
File metadata and controls
69 lines (67 loc) · 2.14 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
name: Java CI with Maven
# 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 }}