Skip to content

Commit ccb9794

Browse files
committed
Configure project to deploy to Maven Central and GPG sign
1 parent b424452 commit ccb9794

File tree

23 files changed

+318
-124
lines changed

23 files changed

+318
-124
lines changed

.github/jvm.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-XX:-TieredCompilation -XX:TieredStopAtLevel=1

.github/workflows/deploy.yml

Lines changed: 103 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,38 @@ name: Deploy a branch
33
on:
44
workflow_dispatch:
55
inputs:
6-
7-
deploy-artifacts-to-gh-packages:
8-
description: "Deploy artifacts to GH Packages"
6+
dry-run:
7+
description: "Dry run the deployment"
98
default: true
109
type: boolean
1110

12-
deploy-javadoc-to-gh-pages:
13-
description: "Deploy JavaDocs to GH Pages"
14-
default: true
11+
skip-scm:
12+
description: "Skip tagging and release version update commits"
13+
default: false
1514
type: boolean
1615

17-
jobs:
18-
build:
19-
name: Build
20-
uses: ./.github/workflows/build.yml
16+
skip-dependency-scan:
17+
description: "Skip dependency scan"
18+
default: false
19+
type: boolean
2120

22-
github:
23-
name: "Deploy to GitHub"
24-
needs: [build]
21+
skip-tests:
22+
description: "Skip tests"
23+
default: false
24+
type: boolean
25+
26+
version:
27+
description: "Version (leave blank to release non-SNAPSHOT patch)"
28+
default: ""
29+
type: string
30+
31+
jobs:
32+
maven-central:
33+
name: "Maven Central"
2534
runs-on: ubuntu-22.04
2635

2736
permissions:
28-
contents: read
29-
packages: write
30-
pages: write
37+
contents: write
3138
id-token: write
3239

3340
steps:
@@ -36,38 +43,99 @@ jobs:
3643
with:
3744
fetch-depth: 2
3845

39-
- name: Initialize JDK
46+
- name: Initialize Java environment
4047
uses: actions/setup-java@v3
4148
with:
4249
distribution: zulu
4350
# Must use >= JDK 17 for Javadocs to generate correctly.
4451
java-version: 17
52+
server-id: ossrh
53+
server-username: OSSRH_USERNAME
54+
server-password: OSSRH_TOKEN
55+
gpg-passphrase: GPG_PASSPHRASE
56+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
57+
58+
- name: Configure Git
59+
shell: bash
60+
run: |-
61+
source ./scripts/common.sh
62+
63+
info "Applying Git user configuration"
64+
run <<SCRIPT
65+
git config user.name '${{ github.actor }}'
66+
git config user.email '${{ github.actor }}@users.noreply.github.com'
67+
SCRIPT
4568
46-
- name: Build artifacts and deploy to GitHub packages
47-
run: >-
48-
./mvnw
49-
-B
50-
-e
51-
-T4
52-
-Dmaven.deploy.skip=${{ ! inputs.deploy-artifacts-to-gh-packages }}
53-
-Dmaven.source.includePom=true
54-
-Dmaven.test.skip=true
55-
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120
56-
-Dstyle.color=always
57-
--also-make
58-
--no-transfer-progress
59-
--projects java-compiler-testing
60-
clean install javadoc:jar source:jar deploy
69+
- name: Perform release to Maven Central
70+
shell: bash
71+
run: |-
72+
source ./scripts/common.sh
73+
74+
info "Determining release version to use (this may take a moment)..."
75+
if [ '${{ inputs.version }}' == "" ]; then
76+
release_version="$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//g')"
77+
else
78+
release_version='${{ inputs.version }}'
79+
fi
80+
81+
success "Will use version ${release_version} for this release"
82+
83+
info "Preparing and performing the release"
84+
ensure-set OSSRH_USERNAME OSSRH_TOKEN GPG_PASSPHRASE
85+
86+
build_args=()
87+
if [[ '${{ inputs.skip-dependency-check }}' = 'false' ]]; then
88+
build_args+=("-P" "dependency-check")
89+
fi
90+
if [[ '${{ inputs.skip-tests }}' = 'true' ]]; then
91+
build_args+=("-Dmaven.test.skip" "-DskipTests")
92+
fi
93+
94+
build_goals=()
95+
if [[ '${{ inputs.skip-scm }}' = 'true' ]]; then
96+
build_goals+=("release:update-versions")
97+
else
98+
build_goals+=("release:prepare")
99+
fi
100+
build_goals+=("release:perform")
101+
102+
run <<-SCRIPT
103+
./mvnw -B -e \
104+
-P release \
105+
--no-transfer-progress \
106+
-Darguments='${build_args[@]}' \
107+
-DdryRun='${{ inputs.dry-run }}' \
108+
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 \
109+
-Dpassword='${{ secrets.GITHUB_TOKEN }}' \
110+
-DreleaseVersion='${release_version}' \
111+
-DsignTag=false \
112+
-Dstyle.color=always \
113+
-Dtag='v${release_version}' \
114+
${build_goals[@]}
115+
SCRIPT
116+
117+
success "Release has been performed successfully"
61118
env:
62-
GITHUB_TOKEN: ${{ github.token }}
119+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
120+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
121+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
63122

64123
- name: Upload JavaDocs as a build artifact
65-
if: ${{ inputs.deploy-javadoc-to-gh-pages }}
66124
uses: actions/upload-pages-artifact@v1
67125
with:
68126
path: java-compiler-testing/target/apidocs
69127

128+
javadocs:
129+
name: "JavaDocs (GitHub Pages)"
130+
runs-on: ubuntu-22.04
131+
needs:
132+
- maven-central
133+
permissions:
134+
pages: write
135+
id-token: write
136+
137+
steps:
70138
- name: Deploy JavaDocs build artifact to GitHub Pages
71-
if: ${{ inputs.deploy-javadoc-to-gh-pages }}
139+
if: ${{ ! inputs.dry-run }}
72140
id: deployment
73141
uses: actions/deploy-pages@v1

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ target/
1616
.classpath
1717

1818
# Maven
19-
pom.xml.versionsBackup
19+
pom.xml.next
20+
pom.xml.releaseBackup
21+
pom.xml.tag
22+
pom.xml.versionsBackup
23+
release.properties

acceptance-tests/acceptance-tests-avaje-inject/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

acceptance-tests/acceptance-tests-avaje-jsonb/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

acceptance-tests/acceptance-tests-checkerframework/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

acceptance-tests/acceptance-tests-dagger/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

acceptance-tests/acceptance-tests-error-prone/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

acceptance-tests/acceptance-tests-google-auto-factory/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

acceptance-tests/acceptance-tests-google-auto-service/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<project xmlns="http://maven.apache.org/POM/4.0.0"
20-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2220
<modelVersion>4.0.0</modelVersion>
2321

2422
<parent>

0 commit comments

Comments
 (0)