Moved signing to profile to avoid issues when building locally. Added use of secrets in workflow to deploy to central

Signed-off-by: Knut-Erik Johnsen <abstract@knut-erik.org>
This commit is contained in:
Knut-Erik Johnsen 2024-06-17 11:33:41 +02:00
parent 3e4b3e1de6
commit c23a8515c4
2 changed files with 41 additions and 15 deletions

View File

@ -17,5 +17,14 @@ jobs:
java-version: '17'
distribution: 'oracle'
cache: maven
server-id: central
server-username: MAVEN_CENTRAL_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
- name: Build with Maven
run: mvn -B deploy --file pom.xml
run: mvn -B deploy --file pom.xml -Pdeploy
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

45
pom.xml
View File

@ -188,20 +188,7 @@
</execution>
</executions>
</plugin>
<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>
@ -226,4 +213,34 @@
<developerConnection>scm:git:ssh://github.com:crossplane/function-sdk-java.git</developerConnection>
<url>https://github.com/crossplane/function-sdk-java/tree/main</url>
</scm>
<profiles>
<profile>
<id>deploy</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>