Skip to content

Commit

Permalink
Fix github actions and pom
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaar, Bjørn-Andre committed Nov 10, 2023
1 parent 0b5d00e commit cd307c4
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 43 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
branches:
- master

env:
REGISTRY: europe-north1-docker.pkg.dev/artifact-registry-5n/dapla-pseudo-maven
IMAGE: dapla-dlp-pseudo-func
TAG: ${{ github.ref_name }}-${{ github.sha }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,6 +39,6 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: mvn --batch-mode -P ssb-bip package
- name: Build with Maven and deploy to Artifact Registry
run: mvn --batch-mode -P ssb-bip deploy

2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
# Draft the next Release notes as Pull Requests are merged into master
# Draft the next Release notes as Pull Requests are merged into main
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 40 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ on:
branches:
- release

env:
REGISTRY: europe-north1-docker.pkg.dev/artifact-registry-5n/dapla-pseudo-maven
IMAGE: dapla-dlp-pseudo-func

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
id-token: write
packages: write

steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.DAPLA_BOT_APP_ID }}
private-key: ${{ secrets.DAPLA_BOT_PRIVATE_KEY }}

- uses: actions/checkout@v3
with:
token: ${{ steps.app-token.outputs.token }}
ref: refs/heads/master

- name: Set up JDK 21
Expand All @@ -45,39 +49,52 @@ jobs:

- name: Configure Git user
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
git config user.name "dapla-bot[bot]"
git config user.email "143391972+dapla-bot[bot]@users.noreply.github.com"
- name: Perform release and publish jar
- name: Setup Maven authentication to GitHub packages
uses: s4u/[email protected]
id: maven_settings
with:
servers: '[{"id": "github","configuration": {"httpHeaders": {"property": {"name": "Authorization","value": "Bearer ${{ secrets.GITHUB_TOKEN }}"}}}}]'

- name: Maven release and deploy to GitHub packages
id: release_jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
mvn --batch-mode -P ssb-bip -DskipTests release:prepare
# Get the release version from the pom.xml before the next snapshot increment
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed "s/-SNAPSHOT//")
echo "version=${VERSION}" >> $GITHUB_OUTPUT
# Perform the release/deploy and increment the version to the next snapshot
mvn --batch-mode release:prepare -Darguments="-Dmaven.deploy.skip=true -DskipTests"
mvn --batch-mode release:perform
TAG=$(git describe --abbrev=0 --tags)
echo "tag=${TAG}" >> $GITHUB_OUTPUT
mvn --batch-mode -P ssb-bip -DskipTests release:perform
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
echo "artifact_id=${ARTIFACT_ID}" >> $GITHUB_OUTPUT
ARTIFACT_PATH=$(realpath ./target/$ARTIFACT_ID*.jar)
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- env:
EVENT_CONTEXT: ${{ toJSON(github.event) }}
run: |
echo $EVENT_CONTEXT
- name: Create GitHub release draft
uses: release-drafter/release-drafter@v5
id: create_github_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
with:
tag: ${{ steps.release_jar.outputs.tag }}

- name: Upload assets to GitHub release draft
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
# Get all files matching the artifact id and version (source, javadoc, etc.)
ARTIFACT_GLOB=(./target/$ARTIFACT_ID-${{ steps.release_jar.outputs.version }}*.jar)
for file in "${ARTIFACT_GLOB[@]}"; do
echo "Uploading $file"
gh release upload ${{ steps.create_github_release.outputs.tag_name }} $file
done
- name: Publish GitHub release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
with:
release_id: ${{ steps.create_github_release.outputs.id }}
release_id: ${{ steps.create_github_release.outputs.id }}
32 changes: 20 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
<name>dapla-dlp-pseudo-func</name>

<properties>
<java.version>11</java.version>
<java.version>21</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<artifact-registry.url>artifactregistry://europe-north1-maven.pkg.dev/artifact-registry-5n/dapla-pseudo-maven</artifact-registry.url>
<artifact-registry.url>artifactregistry://europe-north1-maven.pkg.dev/artifact-registry-5n/dapla-pseudo-maven/</artifact-registry.url>
<github.repository>statisticsnorway/dapla-dlp-pseudo-func</github.repository>

<!-- Dependency versions -->
<assertj.version>3.24.2</assertj.version>
Expand All @@ -31,12 +32,12 @@
<!-- Plugin/extension versions -->
<artifactregistry-maven-wagon.version>2.1.4</artifactregistry-maven-wagon.version>
<checkstyle.version>10.8.1</checkstyle.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>3.3.0</maven-javadoc-plugin.version>
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-checkstyle-plugin.version>3.3.1</maven-checkstyle-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>3.6.2</maven-javadoc-plugin.version>
<maven-shade-plugin.version>3.5.1</maven-shade-plugin.version>
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<sonar-maven-plugin.version>3.9.1.2184</sonar-maven-plugin.version>
</properties>
Expand Down Expand Up @@ -220,7 +221,7 @@
<repositories>
<repository>
<id>artifact-registry</id>
<url>${artifact-registry.url}/maven-releases</url>
<url>${artifact-registry.url}</url>
<releases>
<enabled>true</enabled>
</releases>
Expand All @@ -230,7 +231,7 @@
</repository>
<repository>
<id>artifact-registry-snapshot</id>
<url>${artifact-registry.url}/maven-snapshots</url>
<url>${artifact-registry.url}</url>
<releases>
<enabled>false</enabled>
</releases>
Expand Down Expand Up @@ -296,14 +297,21 @@
<distributionManagement>
<repository>
<id>artifact-registry</id>
<url>${artifact-registry.url}/maven-releases</url>
<url>${artifact-registry.url}</url>
</repository>
<snapshotRepository>
<id>artifact-registry-snapshots</id>
<url>${artifact-registry.url}/maven-snapshots</url>
<url>${artifact-registry.url}</url>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/${github.repository}</url>
</repository>
</distributionManagement>

</project>

0 comments on commit cd307c4

Please sign in to comment.