Skip to content

Commit

Permalink
#4: Add release workflow (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfeilex authored Sep 28, 2023
1 parent aa49121 commit 1784e7e
Show file tree
Hide file tree
Showing 6 changed files with 345 additions and 6 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/clean-runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Delete cancelled workflow runs
on:
schedule:
- cron: '0 6 * * *'

jobs:
del_runs:
runs-on: ubuntu-latest
steps:
- name: Delete cancelled workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 0
delete_run_by_conclusion_pattern: cancelled
87 changes: 87 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Nightly CI Build and Snapshot Release
on:
schedule:
- cron: '0 2 * * *'

jobs:
verify_commit:
runs-on: ubuntu-latest
name: Verify latest commit
outputs:
RUN_BUILD: ${{ steps.verify_commit.outputs.RUN_BUILD }}
steps:
- uses: actions/checkout@v3
- id: verify_commit
name: Verify latest commit is less than 24 hours
if: ${{ github.event_name == 'schedule' }}
run: echo '::set-output name=RUN_BUILD::'$(test -n "$(git log --format=%H --since='24 hours ago')" && echo 'true' || echo 'false')

build-natives:
name: Build native images
runs-on: ${{ matrix.os }}
needs: verify_commit
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: Build native images with nativ maven plugin and extract in tar.gz
shell: bash
run: |
mvn -B -ntp -Pnative -DskipTests=true package
- uses: actions/upload-artifact@v3
with:
name: natives
path: cli/target/*.tar.gz

build:
name: Build Project and Deploy
needs: [build-natives, verify_commit]
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }}
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'
- uses: actions/download-artifact@v3
- name: Make natives available and build project
run: |
mv ./natives/* ./cli/
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 -Dstyle.color=always -B -ntp deploy

cancel:
name: Cancel this workflow
runs-on: ubuntu-latest
needs: verify_commit
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
RUN_ID: ${{ github.run_id }}
steps:
- run: |
curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/cancel"
46 changes: 43 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
name: Release
name: Build and deploy a release including native-images

# Runs manually
on:
workflow_dispatch

jobs:
build-natives:
name: Build native images
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: Build native images with nativ maven plugin and extract in tar.gz
shell: bash
run: |
maven_config="$(cat .mvn/maven.config)"
current_version="${maven_config/#*-Drevision=}"
current_version="${current_version/ */}"
cd cli
mvn -B -ntp -Pnative -DskipTests=true package
- uses: actions/upload-artifact@v3
with:
name: natives
path: cli/target/*.tar.gz

release:
name: Release on Sonatype OSS
runs-on: ubuntu-latest
needs: [build-natives]

steps:
- name: Checkout
Expand All @@ -23,8 +57,13 @@ jobs:
cache: 'maven'
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase

- uses: actions/download-artifact@v3
- name: Publish to Apache Maven Central
run: |
maven_config="$(cat .mvn/maven.config)"
current_version="${maven_config/#*-Drevision=}"
current_version="${current_version/ */}"
maven_config="$(cat .mvn/maven.config)"
current_version="${maven_config/#*-Drevision=}"
current_version="${current_version/ */}"
Expand All @@ -37,6 +76,7 @@ jobs:
git tag -a "release/${next_version}" -m "tagged version ${next_version}"
export GPG_TTY=$TTY
mvn --settings .mvn/settings.xml -B -ntp deploy -Pdeploy -Dgpg.pin.entry.mode=loopback -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
mv ./natives/* ./cli/target/
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
Expand All @@ -58,8 +98,8 @@ jobs:
git push
git push --tags
noDotVersion="${current_version//.}"
gh release create "release/${current_version}" --title "${current_version}" --notes "# Download
https://repo1.maven.org/maven2/com/devonfw/tools/ide/devonfw-ide-cli/${current_version}/devonfw-ide-cli-${current_version}.tar.gz
gh release create "release/${current_version}" ./cli/target/*.tar.gz --title "${current_version}" --notes "# Download
https://repo1.maven.org/maven2/com/devonfw/tools/IDEasy/ide-cli/${current_version}/ide-cli-${current_version}.tar.gz
# Changes
https://github.com/devonfw/IDEasy/blob/main/CHANGELOG.asciidoc#${noDotVersion}"
env:
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build and deploy a release including native-images
on: push
jobs:
build-natives:
name: Build native images
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
with:
ref: feature/release-workflow

- uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: Build native images with nativ maven plugin and extract in tar.gz
shell: bash
run: |
maven_config="$(cat .mvn/maven.config)"
current_version="${maven_config/#*-Drevision=}"
current_version="${current_version/ */}"
cd cli
mvn -B -ntp -Pnative -DskipTests=true package
- uses: actions/upload-artifact@v3
with:
name: natives
path: cli/target/*.tar.gz


attach-artifacts:
name: Attach OS specific tar.gz and create release
runs-on: ubuntu-latest
needs: [build-natives]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: '17'
- uses: actions/download-artifact@v3
- name: Create release for Nexus and Github
run: |
maven_config="$(cat .mvn/maven.config)"
current_version="${maven_config/#*-Drevision=}"
current_version="${current_version/ */}"
ls -R
mvn -B -ntp -DskipTests=true -Dstyle.color=always install
mv ./natives/* ./cli/target/
gh release create ${current_version} ./cli/target/*.tar.gz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110 changes: 107 additions & 3 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<properties>
<mainClass>com.devonfw.tools.ide.cli.Ide</mainClass>
<imageName>ide</imageName>
<releaseName>${project.artifactId}-${os.detected.classifier}-${os.detected.arch}</releaseName>
<java.version>17</java.version>
<native.maven.plugin.version>0.9.22</native.maven.plugin.version>
<native.maven.plugin.version>0.9.23</native.maven.plugin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -91,6 +92,46 @@
</build>

<profiles>
<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>${releaseName}</file>
<type>tar.gz</type>
<classifier>linux</classifier>
</artifact>
<artifact>
<file>${releaseName}</file>
<type>tar.gz</type>
<classifier>windows</classifier>
</artifact>
<artifact>
<file>${releaseName}</file>
<type>tar.gz</type>
<classifier>mac</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>native</id>
<build>
Expand All @@ -117,18 +158,81 @@
</execution>
</executions>
<configuration>
<metadataRepository>
<enabled>true</enabled>
</metadataRepository>
<agent>
<enabled>true</enabled>
</agent>
<imageName>
${imageName}
</imageName>
<buildArgs>
<arg>--enable-url-protocols=https</arg>
<arg>--static</arg>
<arg>-H:IncludeResources="nls/.*"</arg>
<arg>--initialize-at-build-time=org.apache.commons.compress</arg>
</buildArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-distribution</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${releaseName}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>/src/main/assembly/exec.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<os.detected.classifier>windows</os.detected.classifier>
<os.detected.arch>x64</os.detected.arch>
</properties>
</profile>
<profile>
<id>MacOS</id>
<activation>
<os>
<family>Mac</family>
</os>
</activation>
<properties>
<os.detected.classifier>mac</os.detected.classifier>
<os.detected.arch>x64</os.detected.arch>
</properties>
</profile>
<profile>
<id>Linux</id>
<activation>
<os>
<name>Linux</name>
</os>
</activation>
<properties>
<os.detected.classifier>linux</os.detected.classifier>
<os.detected.arch>x64</os.detected.arch>
</properties>
</profile>
</profiles>

</project>
</project>
Loading

0 comments on commit 1784e7e

Please sign in to comment.