Skip to content

Commit 06af6de

Browse files
authored
Refactors and road grades. Locates scopes etc. properly in another place. (#1)
Signed-off-by: Laird Nelson <[email protected]>
1 parent ae71774 commit 06af6de

32 files changed

+2453
-1524
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ljnelson
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: 'Workflow: Maven Release: Prepare and Perform'
2+
run-name: 'Workflow Run: Maven Release: Prepare and Perform'
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dryRun:
7+
default: true
8+
description: 'Dry run?'
9+
type: 'boolean'
10+
mvnDebug:
11+
default: false
12+
description: 'Debug?'
13+
type: 'boolean'
14+
mvnTransferLogging:
15+
default: false
16+
description: 'Log Maven artifact transfers?'
17+
type: 'boolean'
18+
jobs:
19+
job-mvn-release-prepare-perform:
20+
name: 'Job: Maven Release: Prepare and Perform'
21+
permissions:
22+
contents: 'read'
23+
runs-on: 'ubuntu-latest'
24+
steps:
25+
- id: 'checkout'
26+
name: 'Step: Check Out Project'
27+
uses: 'actions/checkout@v4'
28+
with:
29+
fetch-depth: 1
30+
persist-credentials: false
31+
- id: 'setup-java'
32+
name: 'Step: Set Up Java and Maven'
33+
uses: 'actions/setup-java@v4'
34+
with:
35+
cache: 'maven'
36+
distribution: 'temurin'
37+
gpg-passphrase: 'GPG_PASSPHRASE'
38+
gpg-private-key: '${{ secrets.GPG_PRIVATE_KEY }}'
39+
java-version: '23'
40+
mvn-toolchain-id: 'Temurin 23'
41+
mvn-toolchain-vendor: 'openjdk' # see ../../pom.xml
42+
server-id: 'sonatype-oss-repository-hosting' # see https://github.com/microbean/microbean-parent/blob/master/pom.xml#L38
43+
server-password: 'SONATYPE_OSSRH_PASSWORD'
44+
server-username: 'SONATYPE_OSSRH_USERNAME'
45+
- id: 'setup-askpass'
46+
name: 'Step: Set Up GIT_ASKPASS'
47+
run: |
48+
install -m 700 /dev/null "${RUNNER_TEMP}/.askpass" # atomically create empty file with appropriate permissions
49+
cat >> "${RUNNER_TEMP}/.askpass" <<<'#!/bin/bash
50+
case "${1}" in
51+
Username*) exec echo x-access-token ;;
52+
Password*) exec echo "${PUSH_TOKEN}" ;;
53+
esac'
54+
- id: 'setup-gpg'
55+
name: 'Step: Set Up GPG'
56+
run: |
57+
echo 'pinentry-mode loopback' >> ~/.gnupg/gpg.conf
58+
- id: 'mvn-release-prepare'
59+
name: 'Step: Maven Release: Prepare, Perform and Publish Site'
60+
env:
61+
DRY_RUN: '${{ inputs.dryRun }}'
62+
GIT_ASKPASS: '${{ runner.temp }}/.askpass'
63+
GPG_PASSPHRASE: '${{ secrets.GPG_PASSPHRASE }}'
64+
MVN_DEBUG: ${{ inputs.mvnDebug && '--debug' || '' }}
65+
MVN_TRANSFER_LOGGING: ${{ inputs.mvnTransferLogging && '' || '--no-transfer-progress' }}
66+
PUSH_TOKEN : '${{ secrets.PUSH_TOKEN }}' # critical; see ${GIT_ASKPASS} file
67+
SCM_GIT_HTTPS_URL: 'scm:git:${{ github.server_url }}/${{ github.repository }}.git'
68+
SONATYPE_OSSRH_PASSWORD: '${{ secrets.SONATYPE_OSSRH_PASSWORD }}'
69+
SONATYPE_OSSRH_STAGING_PROFILE_ID: '${{ vars.SONATYPE_OSSRH_STAGING_PROFILE_ID }}'
70+
SONATYPE_OSSRH_USERNAME: '${{ secrets.SONATYPE_OSSRH_USERNAME }}'
71+
shell: 'bash -e {0}'
72+
run: >
73+
git config --global user.email '[email protected]'
74+
75+
git config --global user.name 'microbean'
76+
77+
echo "::group::Running mvn prepare"
78+
79+
./mvnw --batch-mode ${MVN_DEBUG} --errors ${MVN_TRANSFER_LOGGING} release:prepare
80+
-DdryRun="${DRY_RUN}"
81+
-Darguments="${MVN_TRANSFER_LOGGING}"
82+
-Dscm.url="${SCM_GIT_HTTPS_URL}"
83+
84+
scm_tag="$(grep '^scm.tag=' release.properties | cut -f 2 -d =)"
85+
86+
echo "Prepared ${scm_tag}" >> "${GITHUB_STEP_SUMMARY}"
87+
88+
echo "scm_tag=${scm_tag}" >> "${GITHUB_OUTPUT}"
89+
90+
echo "::endgroup::"
91+
92+
echo "::group::Running mvn perform"
93+
94+
set +e
95+
96+
{
97+
./mvnw --batch-mode ${MVN_DEBUG} --errors ${MVN_TRANSFER_LOGGING} release:perform
98+
-Darguments="${MVN_TRANSFER_LOGGING} -Dscmpublish.dryRun=${DRY_RUN} -Dscmpublish.pubScmUrl=${SCM_GIT_HTTPS_URL} -DskipTests -DstagingProfileId=${SONATYPE_OSSRH_STAGING_PROFILE_ID}"
99+
-DdryRun="${DRY_RUN}"
100+
-Dgoals="process-classes,post-site,scm-publish:publish-scm,deploy"
101+
-Dscm.url="${SCM_GIT_HTTPS_URL}"
102+
|
103+
tee /dev/fd/3
104+
|
105+
grep --invert-match --silent 'Java class com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO' || cat > /dev/null
106+
;
107+
}
108+
3>&1
109+
110+
exit_codes=(${PIPESTATUS[@]})
111+
112+
echo "::endgroup::"
113+
114+
set -e
115+
116+
if [ "${exit_codes[2]}" -ne 0 ] ; then
117+
# grep "failed" (found com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO) and mvn failed
118+
echo "Released ${scm_tag} successfully, but verify that the staging repository was successfully released" >> "${GITHUB_STEP_SUMMARY}";
119+
# Treat this as a successful run
120+
exit 0;
121+
elif [ "${exit_codes[0]}" -eq 0 ] ; then
122+
# mvn succeeded and grep "succeeded" (did not find com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO)
123+
echo "Released ${scm_tag} successfully" >> "${GITHUB_STEP_SUMMARY}";
124+
fi
125+
126+
exit "${exit_codes[0]}"

.github/workflows/mvn-verify.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Workflow: Maven Verify'
2+
run-name: 'Workflow Run: Maven Verify'
3+
on:
4+
- 'pull_request'
5+
- 'push'
6+
jobs:
7+
job-mvn-verify:
8+
name: 'Job: Maven Verify'
9+
permissions:
10+
contents: 'read'
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- id: 'checkout'
14+
name: 'Step: Checkout'
15+
uses: 'actions/checkout@v4'
16+
with:
17+
fetch-depth: 1
18+
persist-credentials: false
19+
- id: 'setup-java'
20+
name: 'Step: Set Up Java and Maven'
21+
uses: 'actions/setup-java@v4'
22+
with:
23+
cache: 'maven'
24+
distribution: 'temurin'
25+
java-version: '23'
26+
mvn-toolchain-id: 'Temurin 23'
27+
mvn-toolchain-vendor: 'openjdk' # see ../../pom.xml
28+
- id: 'mvn-verify'
29+
name: 'Step: Maven Verify'
30+
run: './mvnw --batch-mode --color never --errors --no-transfer-progress -Dorg.slf4j.simpleLogger.defaultLogLevel=info verify'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

0 commit comments

Comments
 (0)