Skip to content

Commit

Permalink
ci: add deployment to Maven Central
Browse files Browse the repository at this point in the history
Refs: #26
  • Loading branch information
ariwk committed Jun 28, 2024
1 parent 64b2807 commit 747ce68
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 78 deletions.
37 changes: 1 addition & 36 deletions .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,6 @@ jobs:
"id": "s3",
"username": "${{ secrets.S3_SBB_POLARION_MAVEN_REPO_RW_ACCESS_KEY }}",
"password": "${{ secrets.S3_SBB_POLARION_MAVEN_REPO_RW_SECRET_ACCESS_KEY }}"
},
{
"id": "github",
"username": "${env.GITHUB_ACTOR}",
"password": "${env.GITHUB_TOKEN}"
},
{
"id": "ossrh",
"username": "${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_USERNAME }}",
"password": "${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_TOKEN }}"
}
]
profiles: >
[
{
"id": "githubDeploy",
"properties":
{
"altDeploymentRepository": "github::default::https://maven.pkg.github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.generic"
}
},
{
"id": "mavenCentralDeploy",
"properties":
{
"altDeploymentRepository": "ossrh::default::https://oss.sonatype.org/content/repositories/snapshots/"
}
}
]
- name: Print settings.xml
Expand All @@ -78,17 +51,9 @@ jobs:
- name: Extract artefact version
id: artefact_version
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- name: Publish to S3 bucket
if: ${{ !endsWith(steps.artefact_version.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
run: mvn --batch-mode deploy -Ps3Deploy
- name: Publish to GitHub Packages
if: ${{ !endsWith(steps.artefact_version.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
run: mvn --batch-mode deploy -PgithubDeploy
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Publish to Maven Central
# if: ${{ !endsWith(steps.artefact_version.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
run: mvn --batch-mode deploy -PmavenCentralDeploy
run: mvn --batch-mode deploy
env:
SIGN_KEY_PASS: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PASSPHRASE }}
OSSRH_USERNAME: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_USERNAME }}
Expand Down
5 changes: 0 additions & 5 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
69 changes: 32 additions & 37 deletions pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<maven-dependency-plugin.version>3.7.1</maven-dependency-plugin.version>
<exec-maven-plugin.version>3.3.0</exec-maven-plugin.version>
<maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
<version.nexus-staging-maven-plugin>1.6.13</version.nexus-staging-maven-plugin>

<!-- Test dependencies -->
<junit.version>5.10.2</junit.version>
Expand Down Expand Up @@ -62,6 +61,28 @@
</properties>

<profiles>
<profile>
<id>sign-artifacts</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>install-to-local-polarion</id>
<build>
Expand Down Expand Up @@ -433,42 +454,6 @@
<build>
<pluginManagement>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- This is required to make sure the plugin does not stop asking for -->
<!-- user input on the passphrase -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${version.nexus-staging-maven-plugin}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down Expand Up @@ -582,4 +567,14 @@
</pluginManagement>
</build>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>

0 comments on commit 747ce68

Please sign in to comment.