Skip to content

Commit

Permalink
Publish Maven plugin (Take 6) (#2102)
Browse files Browse the repository at this point in the history
* Publish Maven plugin (Take 6)

* Publish Maven things to Sonatype
  • Loading branch information
ennru authored Apr 19, 2024
1 parent 18c60ce commit 6db1346
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
36 changes: 21 additions & 15 deletions .github/publish-maven.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
#!/usr/bin/env bash

echo "Extracting the SDK version from sbt build"

# debugging help
echo "----"
sbt --client --no-colors "print coreSdk/version"
echo "----"
SDK_VERSION=$(sbt --client --no-colors "print coreSdk/version" | tail -n 3 | head -n 1 | tr -d '\n')
IS_SNAPSHOT=$(sbt --client --no-colors "print coreSdk/isSnapshot" | tail -n 3 | head -n 1 | tr -d '\n')
if [ "false" == "${IS_SNAPSHOT}" ]
then
REPO="akka-repo::default::https://maven.cloudsmith.io/lightbend/akka/"
else
REPO="akka-repo::default::https://maven.cloudsmith.io/lightbend/akka-snapshots/"
fi
echo "Publishing '${SDK_VERSION}' to '${REPO}'"
echo "Publishing '${SDK_VERSION}'"

cd maven-java
echo ${PGP_SECRET} | base64 -d | gpg --import --batch

# update poms with the version extracted from sbt dynver (-B == no colors)
mvn -B versions:set -DnewVersion=${SDK_VERSION}

# create Maven settings.xml with credentials for repository publishing
mkdir -p ~/.m2
cat <<EOF >~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>akka-repo</id>
<username>${PUBLISH_USER}</username>
<password>${PUBLISH_PASSWORD}</password>
<server>
<id>ossrh</id>
<username>${SONATYPE_USERNAME}</username>
<password>${SONATYPE_PASSWORD}</password>
</server>
</servers>
<profiles>
Expand All @@ -34,5 +36,9 @@ cat <<EOF >~/.m2/settings.xml
</profiles>
</settings>
EOF
mvn -B versions:set -DnewVersion=${SDK_VERSION}
mvn -P release -B deploy -DaltDeploymentRepository="${REPO}"

# import the artefact signing key
echo ${PGP_SECRET} | base64 -d | gpg --import --batch

# Maven deply with profile `release` (-B == no colors)
mvn -P release -B deploy
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PUBLISH_USER: ${{ secrets.PUBLISH_USER }}
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_PASSWORD }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

publish-documentation:
name: Documentation
Expand Down
34 changes: 17 additions & 17 deletions maven-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@
<maven.version>3.9.0</maven.version>
</properties>

<!-- <distributionManagement>-->
<!-- <snapshotRepository>-->
<!-- <id>ossrh</id>-->
<!-- <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>-->
<!-- </snapshotRepository>-->
<!-- </distributionManagement>-->
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<build>
<pluginManagement>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.sonatype.plugins</groupId>-->
<!-- <artifactId>nexus-staging-maven-plugin</artifactId>-->
<!-- <version>1.6.13</version>-->
<!-- <extensions>true</extensions>-->
<!-- <configuration>-->
<!-- <serverId>ossrh</serverId>-->
<!-- <nexusUrl>https://s01.oss.sonatype.org</nexusUrl>-->
<!-- <autoReleaseAfterClose>true</autoReleaseAfterClose>-->
<!-- </configuration>-->
<!-- </plugin>-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down

0 comments on commit 6db1346

Please sign in to comment.