Skip to content

Commit

Permalink
Update CI build and GitHub Actions (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksclarke authored Oct 10, 2024
1 parent 333d44a commit a7fc72b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 50 deletions.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "ksclarke"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "ksclarke"
- package-ecosystem: "docker"
directory: "/src/main/docker"
schedule:
interval: "weekly"
assignees:
- "ksclarke"
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ jobs:
build:
name: Maven PR Builder (JDK ${{ matrix.java }})
runs-on: ubuntu-latest

strategy:
matrix:
java: [ 21 ]
java: [ "21" ]
maven: [ "3.8.2" ]

steps:

Expand All @@ -28,6 +30,13 @@ jobs:
distribution: 'adopt'
java-version: ${{ matrix.java }}

# If running locally in act, install Maven
- name: Set up Maven if needed
if: ${{ env.ACT }}
uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5
with:
maven-version: ${{ matrix.maven }}

- name: Cache SonarCloud packages
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
Expand Down
35 changes: 18 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Maven Release

# Deploy the webrepl when a new tag is published
# Deploy the webrepl when a new tag is pushed
on:
push:
tags: [ 'webrepl-*' ]
Expand All @@ -9,13 +9,12 @@ jobs:
release:
name: Maven PR Builder (JDK ${{ matrix.java }})
runs-on: ubuntu-latest
env:
AUTORELEASE_ARTIFACT: false
NEXUS_USERNAME: "${{ secrets.SONATYPE_USERNAME }}"
NEXUS_PASSWORD: "${{ secrets.SONATYPE_PASSWORD }}"

strategy:
matrix:
java: [ 21 ]
maven: [ 3.8.2 ]
jdk: [ adopt ]

steps:

Expand All @@ -26,18 +25,9 @@ jobs:
uses: actions/setup-java@860f60056505705214d223b91ed7a30f173f6142 # v3.3.0
with:
cache: maven
distribution: 'adopt'
distribution: ${{ matrix.jdk }}
java-version: ${{ matrix.java }}

- name: Import GPG key
run: |
echo "${{ secrets.BUILD_KEY }}" | gpg --batch --import
gpg --list-keys
- name: Set GPG passphrase for Maven
run: |
echo "MAVEN_GPG_PASSPHRASE=${{ secrets.BUILD_PASSPHRASE }}" >> $GITHUB_ENV
- name: Login to Docker repository
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0
with:
Expand All @@ -51,10 +41,21 @@ jobs:
TAG_NAME="${GITHUB_REF#refs/tags/}" &&
echo "RELEASE_VERSION=${TAG_NAME#webrepl-}" >> $GITHUB_ENV
# If running locally in act, install Maven
- name: Set up Maven if needed
if: ${{ env.ACT }}
uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5
with:
maven-version: ${{ matrix.maven }}

- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.BUILD_PASSPHRASE }}
MAVEN_GPG_KEY: ${{ secrets.BUILD_KEY }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
mvn deploy -B -ntp -Drevision="${{ env.RELEASE_VERSION }}" -Prelease \
-Dautorelease.artifact="${{ env.AUTORELEASE_ARTIFACT }}"
mvn deploy -B -ntp -Prelease -Drevision="${{ env.RELEASE_VERSION }}" \
-DskipNexusStagingDeployMojo="true" -Dautorelease.artifact="false" \
-Ddocker.registry.account="${{ secrets.DOCKER_ACCOUNT }}"
42 changes: 10 additions & 32 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,15 @@
<!-- Test dependency versions -->
<junit.version>5.11.0</junit.version>

<!-- The Docker registry user and password used for publishing images -->
<docker.registry.username />
<docker.registry.password />

<!-- The Docker registry account, if supplied, must end with a slash (e.g. "account/") -->
<docker.registry.account />

<!-- Skip the requirement that none of the dependencies are snapshot versions -->
<enforcer.skip>true</enforcer.skip>

<!-- The default logging level for the server. -->
<logLevel>ERROR</logLevel>

<!-- The DockerHub account must be specified as a property for use in the POM -->
<!-- If supplied, the registry account must end with a slash (e.g. "account/") -->
<docker.registry.account/>
</properties>

<dependencies>
Expand Down Expand Up @@ -159,10 +156,7 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>
https://javadoc.io/doc/info.freelibrary/freelib-utils/${freelib.utils.version}/apidocs</link>
</links>
<skip>true</skip>
</configuration>
</plugin>

Expand Down Expand Up @@ -231,7 +225,6 @@
</configuration>
</plugin>


<!-- Disable standard deploy; we publish a Docker image, not Jar file -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -253,8 +246,7 @@
<imagesMap>
<image>
<!-- Registry account, if supplied, must end in a slash (e.g. "account/") -->
<!-- The %l at the end translates to "latest" if version ends in "-SNAPSHOT" -->
<name>${docker.registry.account}${project.artifactId}:%l</name>
<name>${docker.registry.account}${project.artifactId}:${revision}</name>
<build>
<dockerFile>${project.basedir}/src/main/docker/Dockerfile</dockerFile>
<buildx>
Expand Down Expand Up @@ -338,13 +330,12 @@
<images>
<image>
<!-- Registry account, if supplied, must end in a slash (e.g. "account/") -->
<!-- The %l at the end translates to "latest" if version ends in "-SNAPSHOT" -->
<name>${docker.registry.account}${project.artifactId}:%l</name>
<name>${docker.registry.account}${project.artifactId}:${revision}</name>
</image>
</images>
<authConfig>
<username>${docker.registry.username}</username>
<password>${docker.registry.password}</password>
<username>${env.DOCKER_USERNAME}</username>
<password>${env.DOCKER_PASSWORD}</password>
</authConfig>
</configuration>
</execution>
Expand All @@ -353,23 +344,10 @@
</plugins>
</build>

<repositories>
<repository>
<id>ossrh-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<parent>
<artifactId>freelib-parent</artifactId>
<groupId>info.freelibrary</groupId>
<version>11.0.0</version>
<version>12.0.0</version>
</parent>

</project>

0 comments on commit a7fc72b

Please sign in to comment.