Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 35 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,51 @@ jobs:
env:
MAVEN_ARGS: --show-version --no-transfer-progress
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up java
uses: actions/setup-java@v4
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn verify


publishing_parameters:
name: Publishing parameters
publish:
needs: build
name: Publish ${{ github.ref_name }}
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.version.outputs.is_release }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Determine version
id: version
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: temurin
java-version: '21'
cache: "maven"
gpg-private-key: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PRIVATE }}
server-id: central
server-username: MAVEN_CENTRAL_TOKEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN_PASSWORD
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Activate Artifact Signing and Version Suffix
run: |
if [[ $GITHUB_REF == *"tags"* ]]; then
is_release=true
version=${GITHUB_REF#refs/tags/}
profiles="build-sources-and-javadoc,deploy-to-maven-central"
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
profiles="$profiles,sign-artifacts"
version_suffix=""
else
is_release=false
version=${GITHUB_REF#refs/heads/}-SNAPSHOT
version_suffix="-SNAPSHOT"
fi
echo "is_release=${is_release//\//-}" >> $GITHUB_OUTPUT
echo "version=${version//\//-}" >> $GITHUB_OUTPUT


publish:
needs: [build, publishing_parameters]
name: Publish ${{ needs.publishing_parameters.outputs.version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: digipost/action-maven-publish@v1
with:
sonatype_secrets: ${{ secrets.sonatype_secrets }}
release_version: ${{ needs.publishing_parameters.outputs.version }}
perform_release: ${{ needs.publishing_parameters.outputs.is_release }}
echo "MAVEN_PROFILES=$profiles" >> $GITHUB_ENV
version="${GITHUB_REF_NAME}${version_suffix}"
echo "VERSION=$version" >> $GITHUB_ENV
- name: Set Maven version
run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${VERSION}
- name: Build and deploy to Maven Central
run: |
mvn --batch-mode --no-transfer-progress --activate-profiles ${MAVEN_PROFILES} deploy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sånn det er satt opp nå, så vil det jo i praksis bli kjørt to (nesten) identiske Maven-bygg i sekvens, hvis man teller den første parallell-matrisen som ett bygg. Først kjøres et fullstendig Maven-bygg eksl. deploy til remote repository, deretter et fullstendig Maven-bygg til inkl. deploy til remote repository.

Kunne vi gjort dette litt mer effektivt? Har to forslag:

  1. Prøve å ekskludere noen overflødige phases/goals i publish-jobben, tester peker seg jo ut her, både kompilering av testkode og kjøring av tester.
  2. (Egentlig min preferanse) Kombinere build og publish til en jobb. Problemet her er jo at vi gjerne vil kjøre 3 bygg-varianter med ulike Java-versjoner, så om vi tilpasser om vi kjører mvn deployén spesifikk Java-versjon, og ellers mvn verify. Jeg tror kanskje dette også vil gi minst duplisert GitHub actions jobb-oppsett.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref PR: #42 😇

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enig. Den første jobben er egentlig bortkasta CPU og energi. Den andre vil jo feile på samme måte som den første i verify-steget, uansett. Vi kan hellere reintrodusere en eller annen form for delvis bygging uten publisering, om det skulle være bruk for det seinere. Ser nærmere på PR-en din om litt.

env:
MAVEN_CENTRAL_TOKEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_TOKEN_USERNAME }}
MAVEN_CENTRAL_TOKEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_CENTRAL_SIGNING_KEY_PASSPHRASE }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ target
*.iml
.idea
.sonatype
.vscode/settings.json
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>no.digipost</groupId>
<artifactId>digipost-open-super-pom</artifactId>
<version>13</version>
<version>14</version>
</parent>

<artifactId>digg</artifactId>
Expand Down Expand Up @@ -167,7 +167,7 @@
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.1</version>
<configuration>
<rules>
<requireMavenVersion>
Expand All @@ -190,7 +190,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
<configuration>
<compilerArgs>
<arg>-Xlint</arg>
Expand All @@ -199,31 +199,31 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
<version>3.5.3</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.3</version>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.10.0</version>
<version>3.11.2</version>
<configuration>
<tags>
<tag>
Expand All @@ -241,15 +241,15 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.17.1</version>
<version>2.18.0</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.23.0</version>
<version>0.23.1</version>
<configuration>
<parameter>
<includes>
Expand Down