Skip to content

Commit

Permalink
#563 Optimize workflows (#749)
Browse files Browse the repository at this point in the history
* #563: Improved deployment workflows
improved nightly build deployment workflow
adjusted upload and download artifact actions
changed native image build phase from package to compile
renamed assembly xml files accordingly

* #563: fixed image names

* #563: adjusted assemblies
made sure that assemblies use matrix os names
removed merge-multiple to extract artifacts into own folders

* #563: adjusted assemblies
added new build profile for assemblies
adjusted assembly xml files

* #563: adjusted assemblies
builds only one image for tests
changed build maven profile to assembly

* #563: adjusted workflow
set build phase from install to package
made sure that only cli gets built

* #563: fixed tar archive name

* #563: skipped tests

* #563: fixed build

* #563: re-enabled other runners

* #563: re-enabled tests

* #563: removed build documentation step
adjusted workflow steps
changed deploy assembly step to be run on package instead of install
adjusted pom assembly phase
skipped tests in build step

* #563: separated build of docs
adjusted comments

* #563: fixed cd

* #563: test

* #563: test

* #563: re-enabled image build

* #563: re-enabled other image builds
removed pwd

* #563: use doc file from dependency
changed phase of create assemblies to install
added documentation file from ide-doc dependency to artifact

* #563: applied changes from nightly-build to release
added assembly profile to deploy
disabled other operating systems for test purposes

* #563: removed upload for test projects

* #563: re-enabled runners

* #563: added documentation file

* #563: implemented requested changes
added links to external resources
added examples for id

* #563: implemented requested changes
re-enabled tests on release deploy step
removed assembly step of nightly build and moved to deploy phase
removed skip of install on nightly build

* #563: implemented requested changes
adjusted actions-upload link
  • Loading branch information
jan-vcapgemini authored Nov 22, 2024
1 parent 6b41eef commit 10fc17b
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 150 deletions.
45 changes: 6 additions & 39 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,13 @@ on:
workflow_dispatch

jobs:
# Builds documentation pdf file in cli/target/package and uploads artifact to docs
build-documentation:
name: Build documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '17'
- name: Make documentation available
run: |
cd documentation
mvn -B -ntp -Dstyle.color=always -DskipTests=true package
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: documentation/target/generated-docs/*.pdf

# Downloads documentation docs artifact, builds all native images, archives native image for each os with documentation pdf file and uploads artifacts to f.e. natives-windows-latest
# Builds all native images and uploads each binary as a separate artifact
build-natives:
name: Build native images
needs: build-documentation
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest, macos-13 ]

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -45,26 +20,21 @@ jobs:
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Download documentation
uses: actions/download-artifact@v4
with:
name: docs
path: ./cli/target/package
- name: Build native image
shell: bash
run: |
cd cli
mvn -B -ntp -Dideasy.assembly.id=${{ matrix.os }} -Pnative -DskipTests=true package
mvn -B -ntp -Pnative -DskipTests=true compile
- name: Upload native image
uses: actions/upload-artifact@v4
with:
name: natives-${{ matrix.os }}
path: cli/target/*.tar.gz
path: cli/target/ideasy*

# Downloads all native image artifacts to cli/target and builds the project for deployment to OSSRH Nexus
# Downloads all native image artifacts to cli/target and builds the project using assemblies for final deployment to OSSRH Nexus
deploy:
name: Build Project and Deploy
needs: [ build-documentation, build-natives ]
needs: [ build-natives ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -80,11 +50,8 @@ jobs:
with:
pattern: natives-*
path: ./cli/target/
merge-multiple: true
- run: |
mvn -B -ntp -Dstyle.color=always install
- name: Deploy to OSSRH nexus
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dgpg.skip=true -Dstyle.color=always -B -ntp -Pdeploy deploy
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dgpg.skip=true -Dstyle.color=always -B -ntp -Passembly,deploy deploy
46 changes: 9 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,13 @@ on:

jobs:

# Builds documentation pdf file in cli/target/package and uploads artifact to docs
build-documentation:
name: Build documentation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '17'
- name: Make documentation available
run: |
cd documentation
mvn -B -ntp -Dstyle.color=always -DskipTests=true package
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: docs
path: documentation/target/generated-docs/*.pdf

# Downloads documentation docs artifact, builds all native images, archives native image for each os with documentation pdf file and uploads artifacts to f.e. natives-windows-latest
# Adjusts the revision to the latest version, builds images for each OS type/architecture using matrix:os and uploads each binary as a separate artifact
build-natives:
name: Build native images
needs: build-documentation
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, ubuntu-latest, macos-latest, macos-13 ]

steps:
- uses: actions/checkout@v3
with:
Expand All @@ -48,11 +23,6 @@ jobs:
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Download documentation
uses: actions/download-artifact@v4
with:
name: docs
path: ./cli/target/package
- name: Build native image
shell: bash
run: |
Expand All @@ -61,17 +31,20 @@ jobs:
current_version="${current_version/ */}"
next_version="${current_version/-SNAPSHOT/}"
cd cli
mvn -B -ntp -Drevision=${next_version} -Dideasy.assembly.id=${{ matrix.os }} -Pnative -DskipTests=true package
mvn -B -ntp -Drevision=${next_version} -Pnative -DskipTests=true compile
- name: Upload native image
uses: actions/upload-artifact@v4
with:
name: natives-${{ matrix.os }}
path: cli/target/*.tar.gz
path: cli/target/ideasy*

# Downloads all native image artifacts to cli/target and builds the project using assemblies for final deployment to Maven Central.
# The version number for the next build will be incremented automatically.
# A GitHub release and download URLs pointing to the respective OS/architecture archives on Maven Central will be created.
release:
name: Release on Sonatype OSS
runs-on: ubuntu-latest
needs: [ build-documentation, build-natives ]
needs: build-natives
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -91,8 +64,7 @@ jobs:
with:
pattern: natives-*
path: ./cli/target/
merge-multiple: true
- name: Publish to Apache Maven Central
- name: Create assemblies and publish to Apache Maven Central
run: |
maven_config="$(cat .mvn/maven.config)"
current_version="${maven_config/#*-Drevision=}"
Expand All @@ -106,7 +78,7 @@ jobs:
git tag -a "release/${next_version}" -m "tagged version ${next_version}"
export GPG_TTY=$TTY
mkdir -p ./cli/target/
mvn --settings .mvn/settings.xml -B -ntp deploy -Pdeploy -Dgpg.pin.entry.mode=loopback -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
mvn --settings .mvn/settings.xml -B -ntp deploy -Passembly,deploy -Dgpg.pin.entry.mode=loopback -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
Expand Down
98 changes: 28 additions & 70 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,33 @@

<profiles>
<!-- Builds the native image and archives it with the documentation from the github artifact -->
<profile>
<id>assembly</id>
<build>
<plugins>
<!-- Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${assembly.maven.plugin.version}</version>
<executions>
<execution>
<id>create-distribution</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${revision}</finalName>
<appendAssemblyId>true</appendAssemblyId>
<descriptorSourceDirectory>src/main/assembly</descriptorSourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native</id>
<build>
Expand All @@ -189,7 +216,7 @@
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
<phase>compile</phase>
</execution>
<execution>
<id>test-native</id>
Expand All @@ -213,75 +240,6 @@
</buildArgs>
</configuration>
</plugin>
<!-- Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${assembly.maven.plugin.version}</version>
<executions>
<execution>
<id>create-distribution</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.artifactId}-${revision}</finalName>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>/src/main/assembly/release-${ideasy.assembly.id}.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- Attaches artifacts stored in cli/target/*.tgz to the maven build, moves them to documentation/target/nexus-staging/.../*.tgz and deploys them with the name defined in the classifier -->
<profile>
<id>deploy</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.artifactId}-${revision}-windows-x64.tar.gz</file>
<type>tar.gz</type>
<classifier>windows-x64</classifier>
</artifact>
<artifact>
<file>${project.build.directory}/${project.artifactId}-${revision}-linux-x64.tar.gz</file>
<type>tar.gz</type>
<classifier>linux-x64</classifier>
</artifact>
<artifact>
<file>${project.build.directory}/${project.artifactId}-${revision}-mac-x64.tar.gz</file>
<type>tar.gz</type>
<classifier>mac-x64</classifier>
</artifact>
<artifact>
<file>${project.build.directory}/${project.artifactId}-${revision}-mac-arm.tar.gz</file>
<type>tar.gz</type>
<classifier>mac-arm</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${settings.localRepository}/com/devonfw/tools/IDEasy/ide-doc/${project.version}/ide-doc-${project.version}.pdf</source>
<destName>IDEasy.pdf</destName>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<directory>${project.build.directory}/natives-ubuntu-latest</directory>
<outputDirectory>./bin</outputDirectory>
<includes>
<include>${imageName}</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${settings.localRepository}/com/devonfw/tools/IDEasy/ide-doc/${project.version}/ide-doc-${project.version}.pdf</source>
<destName>IDEasy.pdf</destName>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<directory>${project.build.directory}/natives-macos-latest</directory>
<outputDirectory>./bin</outputDirectory>
<includes>
<include>${imageName}</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${settings.localRepository}/com/devonfw/tools/IDEasy/ide-doc/${project.version}/ide-doc-${project.version}.pdf</source>
<destName>IDEasy.pdf</destName>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<directory>${project.build.directory}/natives-macos-13</directory>
<outputDirectory>./bin</outputDirectory>
<includes>
<include>${imageName}</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${settings.localRepository}/com/devonfw/tools/IDEasy/ide-doc/${project.version}/ide-doc-${project.version}.pdf</source>
<destName>IDEasy.pdf</destName>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<directory>${project.build.directory}/natives-windows-latest</directory>
<outputDirectory>./bin</outputDirectory>
<includes>
<include>${imageName}.exe</include>
Expand Down
Loading

0 comments on commit 10fc17b

Please sign in to comment.