-
-
Notifications
You must be signed in to change notification settings - Fork 14
70 lines (61 loc) · 2.09 KB
/
build.yml
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
70
name: build
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
on:
workflow_dispatch:
inputs:
release:
type: boolean
default: false
description: Whether to make a release
pull_request:
push:
paths-ignore:
- "README.md"
- ".gitignore"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: VERSION file changed
id: version-file-changed
uses: tj-actions/changed-files@v42
with:
files: VERSION
- name: Should make release?
if: |
github.ref == 'refs/heads/main' &&
((github.event.inputs.release && github.event_name == 'workflow_dispatch') ||
(github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.version-file-changed.outputs.any_changed == 'true'))
run: echo make_release=true >> "$GITHUB_ENV"
- name: Get version
if: env.make_release
run: echo VERSION="$(head VERSION)" >> "$GITHUB_ENV"
- name: Gradle Build and Test
run: |
./gradlew build test --info --stacktrace
- name: Release (GitHub)
if: env.make_release
id: github_release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
- name: Prepare PGP Keyring file
if: env.make_release
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
run: |
echo "${GPG_KEY_CONTENTS}" | base64 -d > signing-key.gpg
shell: bash
- name: Publish to Maven Central
if: env.make_release
run: |
./gradlew publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --info --stacktrace
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}