Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #11726: Automate creation of settings.xml file for release #11743

Merged
merged 1 commit into from Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .ci/jsoref-spellchecker/whitelist.words
Expand Up @@ -230,6 +230,7 @@ Cloneable
cloudbees
clss
cmdline
cmp
cmt
CNAME
Cnt
Expand Down Expand Up @@ -751,6 +752,7 @@ kbd
kclee
KDoc
keygen
keyname
keyrings
Kochurkin
konstantinos
Expand Down Expand Up @@ -1035,6 +1037,7 @@ parenpad
parrt
parsetreetablepresentation
Passembly
passphrase
pathcomplexity
patreon
patternvariablename
Expand Down
38 changes: 38 additions & 0 deletions .ci/prepare-settings.sh
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

mkdir -p .ci-temp
cp .ci/release-settings.xml .ci-temp/

checkForVariable() {
VAR_NAME=$1
if [ -v "${!VAR_NAME}" ]; then
echo "Error: Define $1 environment variable"
exit 1
fi
}

checkForVariable "SONATYPE_USER"
checkForVariable "SONATYPE_PWD"
checkForVariable "GPG_PASSPHRASE"
checkForVariable "GPG_KEY"

replace() {
sed -i "s/$1/$2/g" .ci-temp/release-settings.xml
}

replace SONATYPE_USER
romani marked this conversation as resolved.
Show resolved Hide resolved
replace SONATYPE_PWD
replace GPG_PASSPHRASE
replace GPG_KEY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these names be more Checkstyle specific? IE: CS_GPG_KEY or CHECKSTYLE_GPG_KEY

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure for now to put CS as prefix for all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these just environment variables the user has set on their machine going by checkForVariable? Are these environment variables needed some place else besides for this script?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a variables, not used in other scripts.

We never named variables with CS prefix, I not sure that we should start now.



TEMP_SETTING="./.ci-temp/release-settings.xml"
SETTING="~/.m2/settings.xml"

if cmp -s "$TEMP_SETTING" "$SETTING"; then
TODAY=$(date + "%y%m%d")
mv $SETTING $SETTING.backup."${TODAY}"
fi

cp $TEMP_SETTING $SETTING
24 changes: 24 additions & 0 deletions .ci/release-settings.xml
@@ -0,0 +1,24 @@
<settings>
<servers>
<server>
<id>sonatype-nexus-staging</id>
<username>SONATYPE_USER</username>
<password>SONATYPE_PWD</password>
</server>
</servers>

<profiles>
<profile>
<!-- "mvn release:prepare .... -Pgpg"
and it is possible to skip " -Dgpg.passphrase=...." at "-Darguments"
Use "gpg \-\-list-keys", "pub 1024D/C6XXXX57A 2010-01-13"
to get "gpg.keyname" in example it is value "C6XXXX57A"
-->
<id>gpg</id>
<properties>
<gpg.passphrase>GPG_PASSPHRASE</gpg.passphrase>
<gpg.keyname>GPG_KEY</gpg.keyname>
</properties>
</profile>
</profiles>
</settings>