Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: configure jreleaser #50

Merged
merged 1 commit into from
Mar 19, 2024
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
72 changes: 70 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defaults:
shell: bash

jobs:
release:
maven-release:
runs-on: ubuntu-latest
name: Release power-server
if: ${{github.event.pull_request.merged == true}}
Expand Down Expand Up @@ -58,4 +58,72 @@ jobs:
- name: Push changes to ${{github.base_ref}} branch
run: |
git push
git push origin ${{steps.metadata.outputs.current-version}}
git push origin ${{steps.metadata.outputs.current-version}}

# Build native executable per runner
package:
needs: [ maven-release ]
name: 'Build with Graal on ${{ matrix.os }}'
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macOS-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: 'Check out repository'
uses: actions/checkout@v4

- name: 'Build Native Image'
if: ${{ runner.os == 'Linux' }}
run: ./mvnw -ntp -B --file pom.xml -Pnative package -DskipTests

- name: 'Create distribution'
run: ./mvnw -ntp -B --file pom.xml -Pdist package -DskipTests

- name: 'Upload build artifact'
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ runner.os }}-${{ runner.arch }}
path: |
target/*.zip
target/*.tar.gz

# Collect all executables and release
release:
needs: [ maven-release, package ]
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
uses: actions/checkout@v4
with:
fetch-depth: 0

# checkout will clobber downloaded artifacts
# we have to download them again
- name: 'Download all build artifacts'
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: artifacts-*
merge-multiple: true

- name: 'Set up Java'
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven

- name: 'Release with JReleaser'
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./mvnw -ntp -B --file pom.xml -Prelease -DartifactsDir=artifacts jreleaser:full-release

- name: 'JReleaser output'
if: always()
uses: actions/upload-artifact@v4
with:
name: jreleaser-logs
path: |
target/jreleaser/trace.log
target/jreleaser/output.properties
75 changes: 75 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
<developer>
<name>Christophe Laprun</name>
<email>metacosm@gmail.com</email>
<roles>
<role>author</role>
</roles>
</developer>
</developers>
<inceptionYear>2023</inceptionYear>

<scm>
<connection>scm:git:git://github.com/metacosm/power-server.git</connection>
Expand Down Expand Up @@ -54,6 +58,9 @@
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<buildnumber-maven-plugin.version>3.2.0</buildnumber-maven-plugin.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
<maven-assembly-plugin.version>3.7.0</maven-assembly-plugin.version>
<jreleaser.version>1.11.0</jreleaser.version>
</properties>

<modules>
Expand Down Expand Up @@ -242,6 +249,74 @@
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>${jreleaser.version}</version>
<configuration>
<jreleaser>
<release>
<github>
<changelog>
<formatted>ALWAYS</formatted>
<preset>conventional-commits</preset>
</changelog>
</github>
</release>
<distributions>
<power-server>
<name>power-server</name>
<type>BINARY</type>
<brew>
<active>RELEASE</active>
<multiPlatform>true</multiPlatform>
</brew>
<sdkman>
<active>RELEASE</active>
</sdkman>
<artifacts>
<artifact>
<path>
{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-linux-x86_64.tar.gz
</path>
<transform>
artifacts/{{distributionName}}-{{projectEffectiveVersion}}-linux-x86_64.tar.gz
</transform>
<platform>linux-x86_64</platform>
</artifact>
<!--<artifact>
<path>
{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-windows-x86_64.zip
</path>
<transform>
artifacts/{{distributionName}}-{{projectEffectiveVersion}}-windows-x86_64.zip
</transform>
<platform>windows-x86_64</platform>
</artifact>-->
<artifact>
<path>
{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-osx-x86_64.zip
</path>
<transform>
artifacts/{{distributionName}}-{{projectEffectiveVersion}}-osx-x86_64.zip
</transform>
<platform>osx-x86_64</platform>
</artifact>
<artifact>
<path>
{{artifactsDir}}/{{distributionName}}-{{projectVersion}}-osx-aarch_64.zip
</path>
<transform>
artifacts/{{distributionName}}-{{projectEffectiveVersion}}-osx-aarch_64.zip
</transform>
<platform>osx-aarch_64</platform>
</artifact>
</artifacts>
</power-server>
</distributions>
</jreleaser>
</configuration>
</plugin>
<!-- Set properties containing the scm revision -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
136 changes: 93 additions & 43 deletions server/pom.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-parent</artifactId>
<version>0.0.3-SNAPSHOT</version>
</parent>
<artifactId>power-server</artifactId>
<name>power-server : server</name>
<description>A RESTful endpoint to retrieve power consumption information on a per-process basis</description>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-metadata</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>build-tools</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-parent</artifactId>
<version>0.0.3-SNAPSHOT</version>
</parent>
<artifactId>power-server</artifactId>
<name>power-server : server</name>
<description>A RESTful endpoint to retrieve power consumption information on a per-process basis</description>
<properties>
<distribution.directory>${project.build.directory}/distributions</distribution.directory>
<executable-suffix />
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>power-server-metadata</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>${os-maven-plugin.version}</version>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>net.laprun.sustainability</groupId>
<artifactId>build-tools</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>dist</id>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>make-distribution</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<attach>false</attach>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${project.artifactId}-${project.version}-${os.detected.classifier}</finalName>
<outputDirectory>${distribution.directory}</outputDirectory>
<workDirectory>${project.build.directory}/assembly/work</workDirectory>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>dist-windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<executable-suffix>.exe</executable-suffix>
</properties>
</profile>
</profiles>
</project>
19 changes: 19 additions & 0 deletions server/src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>dist</id>
<formats>
<format>tar.gz</format>
<format>zip</format>
<format>dir</format>
</formats>
<files>
<file>
<source>${project.build.directory}/${project.artifactId}-${project.version}-runner${executable-suffix}
</source>
<outputDirectory>./bin</outputDirectory>
<destName>${project.artifactId}${executable-suffix}</destName>
</file>
</files>
</assembly>