Skip to content

Commit e13fad0

Browse files
authored
Merge pull request performancecopilot#131 from performancecopilot/parfait-release-update
Modifications to Parfait build/release process (for OSX)
2 parents 4856dcb + 5b94753 commit e13fad0

File tree

6 files changed

+62
-64
lines changed

6 files changed

+62
-64
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ release.properties
1010
*.class
1111
*.iml
1212
*.swp
13+
.releasing.env

Dockerfile

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
FROM ubuntu:latest
1+
FROM quay.io/performancecopilot/pcp
2+
3+
RUN yum update -y
4+
RUN yum install -y pcp-gui git java-11-openjdk maven maven-openjdk11
5+
6+
WORKDIR /parfait
7+
8+
ENV GIT_AUTHOR_NAME=""
9+
ENV GIT_AUTHOR_EMAIL=""
210

3-
RUN apt-get update && apt-get install -y git pcp pcp-gui gpg
4-
RUN apt-get install -y openjdk-11-jdk maven

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Parfait is a performance monitoring library for Java which extracts metrics and
1010

1111
# Requirements
1212

13-
Parfait requires Java 11 (as of Parfait 1.2.x).
13+
Parfait requires Java 11-17 (as of Parfait 1.2.x). While Parfait (the published library) should _run_ on newer JVMs, the current test code only successfully runs on Java versions 11-17.
1414

1515
# About parfait
1616

RELEASING.md

+21-60
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ To release parfait out to the wider community, you will need the following:
55

66
* checked out the Parfait git repo locally
77
* Maven
8-
* gpg
8+
* gpg & a published GPG public key
99
* An account on [OSS Sonatype Repo](https://oss.sonatype.org/)
1010

1111
If you're releasing from a Mac/OSX, then you'll also need:
12-
* Docker
12+
* Docker/colima/Podman
13+
1314

1415
OSS Sonatype
1516
------------
@@ -25,7 +26,7 @@ gpg
2526

2627
Part of the Maven release process uses `gpg` to digitally sign the releases using a signature. Please refer to the OSSRH Overview guide above in the OSS Sonatype section as most of the links stem from there.
2728

28-
As outlined in the docs, to streamline the release process I recommend encoding your `gpg` password into ``~/.m2/settings.xml`:
29+
As outlined in the docs, to streamline the release process I recommend encoding your `gpg` details (but not your password) into ``~/.m2/settings.xml`:
2930

3031
...
3132
<profiles>
@@ -35,7 +36,6 @@ As outlined in the docs, to streamline the release process I recommend encoding
3536
<properties>
3637
<gpg.executable>gpg</gpg.executable>
3738
<gpg.keyname>[email protected]</gpg.keyname>
38-
<gpg.passphrase>..................</gpg.passphrase>
3939
</properties>
4040
</profile>
4141
...
@@ -46,6 +46,12 @@ As outlined in the docs, to streamline the release process I recommend encoding
4646
...
4747
</activeProfiles>
4848

49+
You can configure your GPG passphrase via an environment variable before running the release process:
50+
51+
```markdown
52+
53+
export MAVEN_GPG_PASSPHRASE=....
54+
```
4955

5056
Otherwise you will be asked for the passphrase for every single Parfait module (which is quite a few)....
5157

@@ -89,74 +95,29 @@ Once the `Release` action is performed you & others in the OSS Sonatype group fo
8995

9096
Releasing from OSX
9197
==================
92-
There are some complications releasing from a computer with OSX. As of December 2023, PCP doesn't have a supported OSX distribution,
98+
99+
There are some complications releasing from a computer with OSX. As of November 2024, PCP doesn't have a supported OSX distribution,
93100
and Parfait test harness require interaction with PCP locally to validate. As the Maven release process involves running the
94101
tests locally to validate, this is problematic.
95102

96-
To support the release process on OSX, there is a `Dockerfile` used _purely_ as a mechanism for releasing. It is
103+
To support the release process on OSX, there is a release script that leverages a `Dockerfile` used _purely_ as a mechanism for releasing. It is
97104
a quick'n'dirty mechanism, ugly and less than ideal, but works.
98105

99106
Here's the steps:
100107
```
101108
# Prerequisites:
102109
# * ensure your current working directory is in the root of the Parfait repository
103-
# * EXPORT your gpg PRIVATE key in armor format to directory ~/gpgkeyexport (used later)
104-
# - gpg --armor --export 21FFA5EB0E068E51 > ~/gpgkeyexport/[email protected].prvt.asc
110+
# * EXPORT your gpg PRIVATE key in armor format to directory ~/gpgkeyexport (used during the build)
111+
# - gpg --armor --export-secret-key 21FFA5EB0E068E51 > ~/gpgkeyexport/gpgkey.prvt.asc
105112
106113
# Make sure your ssh key needed for Github is added to a running `ssh-agent` on your local host.
107114
$ ssh-add
108115
109-
# Build the Docker image used for running the release
110-
$ docker build .
111-
112-
# Find the imageID you just built, it should be the one at the top
113-
$ docker images | head -2
114-
REPOSITORY TAG IMAGE ID CREATED SIZE
115-
<none> <none> b2de17c68635 17 hours ago 851MB
116-
117-
# Grab that ImageID to set an environment variable
118-
$ IMAGEID=b2de17c68635
119-
120-
# Run the Docker image
121-
# - maps the ssh-agent on your host into the container
122-
# - maps the Parfait codebase to /code in the container
123-
# - maps your exported GPG key to a path needed later
124-
# The Docker image is a simple Ubuntu image with Java, PCP, git, and gpg installed
125-
$ docker run -e SSH_AUTH_SOCK="/run/host-services/ssh-auth.sock" -v.:/code -v ~/.m2:/root/.m2 -v ~/gpgkeyexport:/root/gpgkeyexport --mount type=bind,src=/run/host-services/ssh-auth.sock,target=/run/host-services/ssh-auth.sock -it $IMAGEID /bin/sh
126-
127-
# Now we're in the running container, we need to import the GPG key
128-
# Import your private GPG key into the containers enviroment
129-
# I couldn't find a working way to reference my gpg setup from the container, so this is was a hacky way to solve it
130-
$ gpg --import /root/gpgkeyexport/[email protected]
131-
132-
# start PCP, this is needed by the tests
133-
$ service pmcd start
134-
135-
# setup git in the container to support the release process
136-
$ git config --global user.email “[email protected]
137-
$ git config --global user.name “Paul “Smith
138-
$ git config --global gpg.program gpg
139-
140-
# change path to where the Parfait code is mapped into the container
141-
$ cd /code
142-
143-
# This is needed otherwise you’ll get
144-
# gpg: signing failed: Inappropriate ioctl for device
145-
# the GPG signing process needs to prompt you for your passphrase
146-
# even though the Maven GPG plugin allows you to declare the password
147-
# this seems to still be needed...
148-
$ export GPG_TTY=$(tty)
149-
150-
# The Maven JavaDoc plugin needs to set the JAVA_HOME..
151-
$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64
152-
153-
# Now we can finally start the release process itself!
154-
$ mvn release:prepare release:perform
155-
156-
# You'll be prompted on screen for your GPG passphrase (if you have one)
157-
# Maven will build, test, verify, package and sign and push to OSS Sonatype
158-
# Follow the Standard OSS Sonatype release process from here
159-
# you can now exit the container
160-
$ exit
116+
# Create a `.releasing.env` file (not part of SCM) that contains the following environment variables needed
117+
#GIT_USERNAME=<your Github username>
118+
#GIT_EMAIL=<your Github email address>
119+
#GPG_PASSPHRASE=<passphrase for your PRIVATE GPG key exported earlier>
161120
121+
# Run the Release script
122+
./releasing.sh
162123
```
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
echo "Starting PMCD"
6+
/usr/libexec/pcp/lib/pmcd start
7+
8+
echo "Importing GPGKEY"
9+
# this trick allows the GPG secret key to be imported via the command line
10+
# thank goodness for Google
11+
echo $MAVEN_GPG_PASSPHRASE | gpg --batch --yes --passphrase-fd 0 --import /root/gpgkeyexport/gpgkey.prvt.asc
12+
13+
echo "Building Parfait"
14+
mvn clean verify gpg:sign

releasing.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
[ ! -f .releasing.env ] && echo ".releasing.env file not found" && exit 1
6+
source .releasing.env
7+
8+
[ ! $GIT_USERNAME ] && echo "GIT_USERNAME is not set" && exit 1
9+
[ ! $GIT_EMAIL ] && echo "GIT_EMAIL is not set" && exit 1
10+
[ ! $GPG_PASSPHRASE ] && echo "GPG_PASSPHRASE is not set" && exit 1
11+
12+
docker build . -t parfait-build
13+
docker run --rm --env GIT_USERNAME="${GIT_USERNAME}" --env GIT_EMAIL="${GIT_EMAIL}" --env MAVEN_GPG_PASSPHRASE="${GPG_PASSPHRASE}" -v `pwd`:/parfait -v ~/.m2:/root/.m2 -v ~/gpgkeyexport:/root/gpgkeyexport parfait-builder sh -c 'releasing-scripts/docker-release-build.sh'
14+
15+
16+

0 commit comments

Comments
 (0)