Skip to content

Commit

Permalink
Configure release profiles; Add GitHub workflows to build, test, and …
Browse files Browse the repository at this point in the history
…release package. (#3)
  • Loading branch information
kirkrodrigues authored Dec 5, 2023
1 parent 38821ec commit 2635d94
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-and-release-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "build-and-release-package"

on: "workflow_dispatch"

concurrency: "${{github.workflow}}-${{github.ref}}"

jobs:
build-package:
runs-on: "ubuntu-latest"
permissions:
packages: "write"
steps:
- uses: "actions/checkout@v3"
with:
submodules: "recursive"

- uses: "actions/setup-java@v4"
with:
java-version: "11"
distribution: "adopt"
server-id: "ossrh"
server-username: "MAVEN_USERNAME"
server-password: "MAVEN_PASSWORD"
gpg-private-key: "${{secrets.GPG_PRIVATE_KEY}}"
gpg-passphrase: "MAVEN_GPG_PASSPHRASE"

- name: "Build package, run tests, and deploy to GitHub"
run: "mvn --batch-mode deploy -Pmaven_release"
env:
MAVEN_USERNAME: "${{secrets.OSSRH_USERNAME}}"
MAVEN_PASSWORD: "${{secrets.OSSRH_TOKEN}}"
MAVEN_GPG_PASSPHRASE: "${{secrets.GPG_PASSPHRASE}}"
38 changes: 38 additions & 0 deletions .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "build-package"

on:
push:
paths:
- ".github/workflows/build-package.yml"
- "pom.xml"
- "src/**"
workflow_dispatch:

concurrency:
group: "${{github.workflow}}-${{github.ref}}"
cancel-in-progress: true

jobs:
build-package:
runs-on: "ubuntu-latest"
permissions:
packages: "write"
steps:
- uses: "actions/checkout@v3"
with:
submodules: "recursive"

- uses: "actions/setup-java@v4"
with:
java-version: "11"
distribution: "adopt"
server-id: "github"

- name: "Build package and run tests"
run: "mvn --batch-mode test"

- if: "${{github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}}"
name: "Deploy to GitHub"
env:
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
run: "mvn --batch-mode deploy -DskipTests -Pgithub_release"
67 changes: 67 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down Expand Up @@ -182,4 +187,66 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>github_release</id>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/y-scope/logback-appenders</url>
</repository>
</distributionManagement>
</profile>

<profile>
<id>maven_release</id>

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

<build>
<plugins>
<!-- phase:verify -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Prevent gpg from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>

<!-- phase:deploy -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 2635d94

Please sign in to comment.