Skip to content

Commit

Permalink
Fix pom and devops
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-muller666 committed Jul 27, 2024
1 parent 713124d commit 61119f2
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 21 deletions.
55 changes: 34 additions & 21 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- test-devops

jobs:

Expand Down Expand Up @@ -53,6 +54,7 @@ jobs:
echo "New project version: $PROJECT_VERSION"
echo "-----> Packaging"
mvn --quiet package -Drevision=$PATCH -DskipTests=true -Dmaven.javadoc.skip=true
mvn --quiet -Drevision=$PATCH gplus:execute
echo "Packaging completed"
VERSION_TAG=v$PROJECT_VERSION
git tag "$VERSION_TAG"
Expand All @@ -67,6 +69,13 @@ jobs:
path: target/*.jar
if-no-files-found: error

- name: Upload pom-release file
uses: actions/upload-artifact@v2
with:
name: release-pom
path: target/pom.xml
if-no-files-found: error

publish-docs:
needs: build-application
runs-on: ubuntu-latest
Expand Down Expand Up @@ -115,8 +124,8 @@ jobs:

- name: Debug Output
run: |
echo "Version Tag from build-application job: ${{ needs.build-application.outputs.VERSION_TAG }}"
echo "Project Version from build-application job: ${{ needs.build-application.outputs.PROJECT_VERSION }}"
echo "VERSION_TAG from build-application job: ${{ needs.build-application.outputs.VERSION_TAG }}"
echo "PROJECT_VERSION from build-application job: ${{ needs.build-application.outputs.PROJECT_VERSION }}"
- name: Create Release
id: create_release
Expand All @@ -128,10 +137,17 @@ jobs:
release_name: Release ${{ needs.build-application.outputs.PROJECT_VERSION }}
body: |
To manually install the JAR file included in this release, use the following Maven command:
```sh
mvn install:install-file -Dfile=<path-to-jar-file> -DgroupId=no.acntech.easycontainers -DartifactId=easycontainers -Dversion=${{ needs.build-application.outputs.PROJECT_VERSION }} -Dpackaging=jar
mvn install:install-file \
-Dfile=<path-to-jar-file> \
-DgroupId=no.acntech.easycontainers \
-DartifactId=easycontainers \
-Dversion=${{ needs.build-application.outputs.PROJECT_VERSION }} \
-Dpackaging=jar \
-DpomFile=<path-to-pom-file>
```
Ensure to replace the placeholder with the actual path to the downloaded JAR file.
Ensure to replace the placeholders with the actual path to the downloaded JAR file and the release pom file.
For Gradle, add this to your `build.gradle` file's dependencies block:
```groovy
Expand All @@ -146,31 +162,28 @@ jobs:
<version>${{ needs.build-application.outputs.PROJECT_VERSION }}</version>
</dependency>
```
Also make sure the following necessary dependencies are added to your project:
- kubernetes-client
- docker-java
- docker-java-transport-okhttp
- awaitility
- khttp
- commons-io
- commons-lang3
- commons-compress
- slf4j-api
- logback-classic
See the [project pom](https://github.com/acntech/easycontainers/blob/main/pom.xml) for more information and exact versions.
draft: false
prerelease: true

- name: Upload Release Asset
id: upload_release_asset
- name: Upload Jar
id: upload_release_jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./easycontainers-${{ needs.build-application.outputs.PROJECT_VERSION }}.jar
asset_name: easycontainers-${{ needs.build-application.outputs.PROJECT_VERSION }}.jar
asset_content_type: application/java-archive
asset_content_type: application/java-archive

- name: Upload Release POM
id: upload_release_pom
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pom.xml
asset_name: pom.xml
asset_content_type: application/xml
108 changes: 108 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
<versions-maven-plugin.version>2.17.1</versions-maven-plugin.version>
<maven-dependency-plugin.version>3.7.1</maven-dependency-plugin.version>
<dependency-check-maven.version>10.0.3</dependency-check-maven.version>
<exec-maven-plugin.version>3.3.0</exec-maven-plugin.version>
<gmavenplus-plugin.version>3.0.2</gmavenplus-plugin.version>

</properties>

Expand Down Expand Up @@ -481,6 +483,112 @@
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>${gmavenplus-plugin.version}</version>
<executions>
<execution>
<!--
<id>generate-release-pom</id>
<phase>generate-resources</phase>
-->
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
<script>
<![CDATA[
import org.apache.maven.model.io.xpp3.MavenXpp3Reader
import org.apache.maven.model.io.xpp3.MavenXpp3Writer
import org.apache.maven.model.Model
import org.apache.maven.model.Dependency
def pomFile = new File("pom.xml")
def reader = new FileReader(pomFile)
def mavenReader = new MavenXpp3Reader()
def model = mavenReader.read(reader)
reader.close()
def revision = System.properties['revision']
if (!revision) {
throw new IllegalStateException("Please specify the revision using '-Drevision'")
}
println "Creating release pom.xml with revision: $revision"
// Interpolate model version
String newVersion = "${model.version.replace('${revision}', revision)}"
println "version interpolated: $newVersion"
// Create a new minimal model
def newModel = new Model()
newModel.modelVersion = '4.0.0'
newModel.groupId = model.groupId
newModel.artifactId = model.artifactId
newModel.version = newVersion
// Add only compile, runtime, or no-scope dependencies
List<Dependency> dependencies = model.dependencies.findAll { dep ->
dep.scope in ['compile', 'runtime', null]
}.collect { dep ->
// Interpolate version for each dependency
String version
if (dep.version.contains('${') && dep.version.contains('}')) {
String versionKey = dep.version.replaceAll(/[\$\{\}]/, '')
// use resolution from model.properties first, then try System.properties
version = model.properties.getProperty(versionKey) ?: System.properties[versionKey] ?: dep.version
} else {
version = dep.version
}
new Dependency(groupId: dep.groupId, artifactId: dep.artifactId, version: version, scope: dep.scope)
}
newModel.dependencies.addAll(dependencies)
def writer = new MavenXpp3Writer()
writer.write(new FileWriter("./target/pom.xml"), newModel)
]]>
</script>
</scripts>
</configuration>
<dependencies>

<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.22</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.9.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
<version>3.9.8</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.4.2</version>
</dependency>

</dependencies>
</plugin>

</plugins>
</build>

Expand Down

0 comments on commit 61119f2

Please sign in to comment.