Skip to content

Commit aff2c8b

Browse files
committed
Setup GitHub workflows
1 parent a2b20c8 commit aff2c8b

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

.github/workflows/gradle.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Grace CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
jobs:
11+
build:
12+
permissions:
13+
contents: read # to fetch code (actions/checkout)
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
java: ['17']
18+
env:
19+
WORKSPACE: ${{ github.workspace }}
20+
steps:
21+
- name: Checkout repository
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
uses: actions/checkout@v4
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Setup JDK
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: 'adopt'
31+
java-version: ${{ matrix.java }}
32+
- name: Setup Gradle
33+
uses: gradle/actions/setup-gradle@v4
34+
- name: Run Build
35+
id: build
36+
run: ./gradlew build -x test
37+
publish:
38+
if: github.event_name == 'push'
39+
needs: ["build"]
40+
permissions:
41+
contents: read # to fetch code (actions/checkout)
42+
checks: write
43+
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
java: ['17']
47+
steps:
48+
- name: Checkout repository
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
uses: actions/checkout@v4
52+
with:
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
- name: Setup JDK
55+
uses: actions/setup-java@v4
56+
with:
57+
distribution: 'adopt'
58+
java-version: ${{ matrix.java }}
59+
- name: Setup Gradle
60+
uses: gradle/actions/setup-gradle@v4
61+
- name: Generate secring file
62+
env:
63+
SECRING_FILE: ${{ secrets.SECRING_FILE }}
64+
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
65+
- name: Publish to Maven Central Portal
66+
id: publish
67+
env:
68+
MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }}
69+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
70+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
71+
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
72+
SECRING_FILE: ${{ secrets.SECRING_FILE }}
73+
run: ./gradlew -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Grace Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create_draft_release:
13+
runs-on: ubuntu-latest
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
steps:
17+
- name: Create draft release
18+
run: |
19+
gh release create \
20+
--repo ${{ github.repository }} \
21+
--title ${{ github.ref_name }} \
22+
--notes '' \
23+
--draft \
24+
${{ github.ref_name }}
25+
release_and_publish:
26+
needs: create_draft_release
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
java: ['17']
31+
env:
32+
GIT_USER_NAME: rainboyan
33+
GIT_USER_EMAIL: rain@rainboyan.com
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
- uses: gradle/actions/wrapper-validation@v3
40+
- name: Setup JDK
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: 'adopt'
44+
java-version: ${{ matrix.java }}
45+
- name: Setup Gradle
46+
uses: gradle/actions/setup-gradle@v4
47+
- name: Set the current release version
48+
id: release_version
49+
run: echo "release_version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
50+
- name: Generate secring file
51+
id: secring
52+
env:
53+
SECRING_FILE: ${{ secrets.SECRING_FILE }}
54+
run: echo $SECRING_FILE | base64 -d > ${{ github.workspace }}/secring.gpg
55+
- name: Publish to Maven Central Portal
56+
id: publish
57+
if: steps.secring.outcome == 'success'
58+
env:
59+
MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }}
60+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
61+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
62+
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }}
63+
SECRING_FILE: ${{ secrets.SECRING_FILE }}
64+
run: ./gradlew -Psigning.secretKeyRingFile=${{ github.workspace }}/secring.gpg publishToSonatype closeAndReleaseSonatypeStagingRepository

0 commit comments

Comments
 (0)