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

Add Nexus Shell Script and user to settings.xml #3

Merged
merged 2 commits into from
Sep 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions maven/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>nexus-release</id>
<name>Release Nexus Repository</name>
<url>https://nexus.infra.lucenia.dev/repository/maven-releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-snapshot</id>
<name>Snapshot Nexus Repository</name>
<url>https://nexus.infra.lucenia.dev/repository/maven-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
Expand All @@ -34,5 +56,11 @@
<username>${env.USERNAME}</username>
<password>${env.ACCESS_TOKEN}</password>
</server>
<server>
<id>lucenia-nexus</id>
<username>${env.NEXUS_USERNAME}</username>
<password>${env.NEXUS_PASSWORD}</password>
<passphrase>${env.NEXUS_PASSPHRASE}</passphrase>
</server>
</servers>
</settings>
76 changes: 76 additions & 0 deletions scripts/gradle/publish-to-do-nexus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash -eu

# Copyright Lucenia Inc.
#
# SPDX-License-Identifier: Apache-2.0.
#
# The Lucenia Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# This script was written by @karlvr and available at the following
# location: https://gist.github.com/karlvr/5a4321f9ddf193ceb122849f8fb806d1
#
# Modifications licensed under Apache-2.0.

basedir="${1:-}" # The directory to start looking for poms from
repository="${2:-}" # The repository name on Nexus
serverid="${3:-}" # Matches to <server> in ~/.m2/settings.xml

if [ -z "$basedir" -o -z "$repository" -o -z "$serverid" ]; then
echo "usage: $0 <basedir> <repository> <serverid>" >&2
exit 1
fi

trap ctrl_c INT

ctrl_c() {
echo "Interrupted" >&2
exit 1
}

# Find poms in artifact and version order
for pom in $(find "$basedir" \( -name '.nexus' \) -prune -false -o -name '*.pom' | sort --version-sort) ; do
dir=$(dirname $pom)
dir=$(cd "$dir" && pwd)
if [ -f "$dir/.migrated-github-packages" ]; then
continue
fi

version=$(basename $dir)
artifact=$(basename $(dirname $dir))
jar="$dir/$artifact-$version.jar"
sources="$dir/$artifact-$version-sources.jar"
javadoc="$dir/$artifact-$version-javadoc.jar"
pomfile="$dir/$artifact-$version.pom"
modfile="$dir/$artifact-$version.module"
group=$(cat $modfile | jq -r '.component.group')
username=$NEXUS_USERNAME
password=$NEXUS_PASSWORD
passphrase=$PASSPHRASE

command="mvn -e -q org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file \
-DrepositoryId=$serverid \
-Durl=https://nexus.infra.lucenia.dev/repository/$repository \
-Dgpg.passphrase=$passphrase"

if [ -f "$jar" ]; then
command="$command -Dfile=\"$jar\""
elif [ -f "$pomfile" ]; then
command="$command -Dfile=\"$pomfile\""
fi
if [ -f "$sources" ]; then
command="$command -Dsources=\"$sources\""
fi
if [ -f "$javadoc" ]; then
command="$command -Djavadoc=\"$javadoc\""
fi
if [ -f "$pomfile" ]; then
command="$command -DpomFile=\"$pomfile\""
fi

echo "$pomfile"
echo "$command"
eval $command
touch "$dir/.migrated-github-packages"
done