-
Notifications
You must be signed in to change notification settings - Fork 9
132 lines (116 loc) · 4.27 KB
/
publish.yml
File metadata and controls
132 lines (116 loc) · 4.27 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: publish
on:
push:
branches:
- main
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g. 2.0.8) - leave empty to use branch/tag name'
required: false
type: string
default: ''
publish_maven:
description: 'Publish to Maven'
required: false
type: boolean
default: true
publish_javadoc:
description: 'Publish JavaDoc to gh-pages branch'
required: false
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# JavaDoc has not been published for a very long time.
publish-javadoc:
name: Publish Javadoc
runs-on: ubuntu-latest
timeout-minutes: 30
# Only publish when semantic-release creates a release commit (starts with "chore(release):")
if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_javadoc)
permissions:
contents: write
pages: write
steps:
# Checkout the main and gh-pages branches. Main is used to generate the Javadoc, gh-pages stores the output Javadoc.
- name: Checkout main branch
uses: actions/checkout@v5
with:
path: main
persist-credentials: true
fetch-depth: 0
- name: Checkout gh-pages branch
uses: actions/checkout@v5
with:
fetch-depth: 0
path: gh-pages
persist-credentials: true
ref: gh-pages
- name: Set up Java 11
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Publish Javadocs
env:
GITHUB_REPO_SLUG: ${{ github.repository }}
GITHUB_TAG: ${{ steps.version.outputs.version }}
run: |
main/build/publishJavadoc-gha.sh
publish-maven-central:
# Requires GPG_KEYNAME, GPG_PRIVATE_KEY, GPG_PASSPHRASE, CP_USERNAME, and CP_PASSWORD
name: Publish to Maven Central
runs-on: ubuntu-latest
timeout-minutes: 30
# Only publish when semantic-release creates a release commit (starts with "chore(release):")
if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_maven)
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Java 11
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
server-id: central
server-username: CP_USERNAME
server-password: CP_PASSWORD
# Import GPG key into build agent's local keystore
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Set Maven version
run: mvn versions:set -DnewVersion=${{ steps.version.outputs.version }} -DgenerateBackupPoms=false
- name: Deploy to Maven Central
env:
# Required variables and secrets for publishing to Maven Central
# GNU Privacy Guard variables
GPG_KEYNAME: ${{ vars.GPG_KEYNAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
# Central portal username and password
CP_USERNAME: ${{ vars.CP_USERNAME }}
CP_PASSWORD: ${{ secrets.CP_PASSWORD }}
run: |
mvn -B -ntp deploy --settings build/.github.settings.xml -DskipTests -P central