Skip to content

Commit 1784e7e

Browse files
authored
#4: Add release workflow (#2)
1 parent aa49121 commit 1784e7e

File tree

6 files changed

+345
-6
lines changed

6 files changed

+345
-6
lines changed

.github/workflows/clean-runs.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Delete cancelled workflow runs
2+
on:
3+
schedule:
4+
- cron: '0 6 * * *'
5+
6+
jobs:
7+
del_runs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Delete cancelled workflow runs
11+
uses: Mattraks/delete-workflow-runs@v2
12+
with:
13+
token: ${{ github.token }}
14+
repository: ${{ github.repository }}
15+
retain_days: 0
16+
keep_minimum_runs: 0
17+
delete_run_by_conclusion_pattern: cancelled
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Nightly CI Build and Snapshot Release
2+
on:
3+
schedule:
4+
- cron: '0 2 * * *'
5+
6+
jobs:
7+
verify_commit:
8+
runs-on: ubuntu-latest
9+
name: Verify latest commit
10+
outputs:
11+
RUN_BUILD: ${{ steps.verify_commit.outputs.RUN_BUILD }}
12+
steps:
13+
- uses: actions/checkout@v3
14+
- id: verify_commit
15+
name: Verify latest commit is less than 24 hours
16+
if: ${{ github.event_name == 'schedule' }}
17+
run: echo '::set-output name=RUN_BUILD::'$(test -n "$(git log --format=%H --since='24 hours ago')" && echo 'true' || echo 'false')
18+
19+
build-natives:
20+
name: Build native images
21+
runs-on: ${{ matrix.os }}
22+
needs: verify_commit
23+
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }}
24+
strategy:
25+
matrix:
26+
os: [windows-latest, ubuntu-latest, macos-latest]
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
submodules: recursive
32+
33+
- uses: graalvm/setup-graalvm@v1
34+
with:
35+
java-version: '17.0.7'
36+
distribution: 'graalvm'
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
native-image-job-reports: 'true'
39+
40+
- name: Build native images with nativ maven plugin and extract in tar.gz
41+
shell: bash
42+
run: |
43+
mvn -B -ntp -Pnative -DskipTests=true package
44+
45+
- uses: actions/upload-artifact@v3
46+
with:
47+
name: natives
48+
path: cli/target/*.tar.gz
49+
50+
build:
51+
name: Build Project and Deploy
52+
needs: [build-natives, verify_commit]
53+
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }}
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout code
57+
uses: actions/checkout@v3
58+
with:
59+
submodules: recursive
60+
- name: Set up JDK
61+
uses: actions/setup-java@v1
62+
with:
63+
java-version: '17'
64+
- uses: actions/download-artifact@v3
65+
- name: Make natives available and build project
66+
run: |
67+
mv ./natives/* ./cli/
68+
mvn -B -ntp -Dstyle.color=always install
69+
- name: Deploy to OSSRH nexus
70+
env:
71+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
72+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
73+
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dstyle.color=always -B -ntp deploy
74+
75+
cancel:
76+
name: Cancel this workflow
77+
runs-on: ubuntu-latest
78+
needs: verify_commit
79+
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'false' }}
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
OWNER: ${{ github.repository_owner }}
83+
REPO: ${{ github.event.repository.name }}
84+
RUN_ID: ${{ github.run_id }}
85+
steps:
86+
- run: |
87+
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"

.github/workflows/release.yml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
1-
name: Release
1+
name: Build and deploy a release including native-images
22

33
# Runs manually
44
on:
55
workflow_dispatch
66

77
jobs:
8+
build-natives:
9+
name: Build native images
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [windows-latest, macos-latest, ubuntu-latest]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
submodules: recursive
19+
20+
- uses: graalvm/setup-graalvm@v1
21+
with:
22+
java-version: '17.0.7'
23+
distribution: 'graalvm'
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
native-image-job-reports: 'true'
26+
27+
- name: Build native images with nativ maven plugin and extract in tar.gz
28+
shell: bash
29+
run: |
30+
maven_config="$(cat .mvn/maven.config)"
31+
current_version="${maven_config/#*-Drevision=}"
32+
current_version="${current_version/ */}"
33+
cd cli
34+
mvn -B -ntp -Pnative -DskipTests=true package
35+
36+
- uses: actions/upload-artifact@v3
37+
with:
38+
name: natives
39+
path: cli/target/*.tar.gz
40+
841
release:
942
name: Release on Sonatype OSS
1043
runs-on: ubuntu-latest
44+
needs: [build-natives]
1145

1246
steps:
1347
- name: Checkout
@@ -23,8 +57,13 @@ jobs:
2357
cache: 'maven'
2458
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
2559
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase
60+
61+
- uses: actions/download-artifact@v3
2662
- name: Publish to Apache Maven Central
2763
run: |
64+
maven_config="$(cat .mvn/maven.config)"
65+
current_version="${maven_config/#*-Drevision=}"
66+
current_version="${current_version/ */}"
2867
maven_config="$(cat .mvn/maven.config)"
2968
current_version="${maven_config/#*-Drevision=}"
3069
current_version="${current_version/ */}"
@@ -37,6 +76,7 @@ jobs:
3776
git tag -a "release/${next_version}" -m "tagged version ${next_version}"
3877
export GPG_TTY=$TTY
3978
mvn --settings .mvn/settings.xml -B -ntp deploy -Pdeploy -Dgpg.pin.entry.mode=loopback -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
79+
mv ./natives/* ./cli/target/
4080
env:
4181
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
4282
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
@@ -58,8 +98,8 @@ jobs:
5898
git push
5999
git push --tags
60100
noDotVersion="${current_version//.}"
61-
gh release create "release/${current_version}" --title "${current_version}" --notes "# Download
62-
https://repo1.maven.org/maven2/com/devonfw/tools/ide/devonfw-ide-cli/${current_version}/devonfw-ide-cli-${current_version}.tar.gz
101+
gh release create "release/${current_version}" ./cli/target/*.tar.gz --title "${current_version}" --notes "# Download
102+
https://repo1.maven.org/maven2/com/devonfw/tools/IDEasy/ide-cli/${current_version}/ide-cli-${current_version}.tar.gz
63103
# Changes
64104
https://github.com/devonfw/IDEasy/blob/main/CHANGELOG.asciidoc#${noDotVersion}"
65105
env:

.github/workflows/test-release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and deploy a release including native-images
2+
on: push
3+
jobs:
4+
build-natives:
5+
name: Build native images
6+
runs-on: ${{ matrix.os }}
7+
strategy:
8+
matrix:
9+
os: [windows-latest, ubuntu-latest, macos-latest]
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
ref: feature/release-workflow
15+
16+
- uses: graalvm/setup-graalvm@v1
17+
with:
18+
java-version: '17.0.7'
19+
distribution: 'graalvm'
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
native-image-job-reports: 'true'
22+
23+
- name: Build native images with nativ maven plugin and extract in tar.gz
24+
shell: bash
25+
run: |
26+
maven_config="$(cat .mvn/maven.config)"
27+
current_version="${maven_config/#*-Drevision=}"
28+
current_version="${current_version/ */}"
29+
cd cli
30+
mvn -B -ntp -Pnative -DskipTests=true package
31+
32+
- uses: actions/upload-artifact@v3
33+
with:
34+
name: natives
35+
path: cli/target/*.tar.gz
36+
37+
38+
attach-artifacts:
39+
name: Attach OS specific tar.gz and create release
40+
runs-on: ubuntu-latest
41+
needs: [build-natives]
42+
43+
steps:
44+
- uses: actions/checkout@v3
45+
with:
46+
submodules: recursive
47+
- name: Set up JDK
48+
uses: actions/setup-java@v1
49+
with:
50+
java-version: '17'
51+
- uses: actions/download-artifact@v3
52+
- name: Create release for Nexus and Github
53+
run: |
54+
maven_config="$(cat .mvn/maven.config)"
55+
current_version="${maven_config/#*-Drevision=}"
56+
current_version="${current_version/ */}"
57+
ls -R
58+
mvn -B -ntp -DskipTests=true -Dstyle.color=always install
59+
mv ./natives/* ./cli/target/
60+
gh release create ${current_version} ./cli/target/*.tar.gz
61+
62+
env:
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cli/pom.xml

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
<properties>
1515
<mainClass>com.devonfw.tools.ide.cli.Ide</mainClass>
1616
<imageName>ide</imageName>
17+
<releaseName>${project.artifactId}-${os.detected.classifier}-${os.detected.arch}</releaseName>
1718
<java.version>17</java.version>
18-
<native.maven.plugin.version>0.9.22</native.maven.plugin.version>
19+
<native.maven.plugin.version>0.9.23</native.maven.plugin.version>
1920
</properties>
2021

2122
<dependencies>
@@ -91,6 +92,46 @@
9192
</build>
9293

9394
<profiles>
95+
<profile>
96+
<id>deploy</id>
97+
<build>
98+
<plugins>
99+
<plugin>
100+
<groupId>org.codehaus.mojo</groupId>
101+
<artifactId>build-helper-maven-plugin</artifactId>
102+
<version>3.4.0</version>
103+
<executions>
104+
<execution>
105+
<id>attach-artifacts</id>
106+
<phase>package</phase>
107+
<goals>
108+
<goal>attach-artifact</goal>
109+
</goals>
110+
<configuration>
111+
<artifacts>
112+
<artifact>
113+
<file>${releaseName}</file>
114+
<type>tar.gz</type>
115+
<classifier>linux</classifier>
116+
</artifact>
117+
<artifact>
118+
<file>${releaseName}</file>
119+
<type>tar.gz</type>
120+
<classifier>windows</classifier>
121+
</artifact>
122+
<artifact>
123+
<file>${releaseName}</file>
124+
<type>tar.gz</type>
125+
<classifier>mac</classifier>
126+
</artifact>
127+
</artifacts>
128+
</configuration>
129+
</execution>
130+
</executions>
131+
</plugin>
132+
</plugins>
133+
</build>
134+
</profile>
94135
<profile>
95136
<id>native</id>
96137
<build>
@@ -117,18 +158,81 @@
117158
</execution>
118159
</executions>
119160
<configuration>
161+
<metadataRepository>
162+
<enabled>true</enabled>
163+
</metadataRepository>
120164
<agent>
121165
<enabled>true</enabled>
122166
</agent>
167+
<imageName>
168+
${imageName}
169+
</imageName>
123170
<buildArgs>
124171
<arg>--enable-url-protocols=https</arg>
125-
<arg>--static</arg>
172+
<arg>-H:IncludeResources="nls/.*"</arg>
173+
<arg>--initialize-at-build-time=org.apache.commons.compress</arg>
126174
</buildArgs>
127175
</configuration>
128176
</plugin>
177+
<plugin>
178+
<groupId>org.apache.maven.plugins</groupId>
179+
<artifactId>maven-assembly-plugin</artifactId>
180+
<executions>
181+
<execution>
182+
<id>create-distribution</id>
183+
<phase>package</phase>
184+
<goals>
185+
<goal>single</goal>
186+
</goals>
187+
<configuration>
188+
<finalName>${releaseName}</finalName>
189+
<appendAssemblyId>false</appendAssemblyId>
190+
<descriptors>
191+
<descriptor>/src/main/assembly/exec.xml</descriptor>
192+
</descriptors>
193+
</configuration>
194+
</execution>
195+
</executions>
196+
</plugin>
129197
</plugins>
130198
</build>
131199
</profile>
200+
<profile>
201+
<id>Windows</id>
202+
<activation>
203+
<os>
204+
<family>Windows</family>
205+
</os>
206+
</activation>
207+
<properties>
208+
<os.detected.classifier>windows</os.detected.classifier>
209+
<os.detected.arch>x64</os.detected.arch>
210+
</properties>
211+
</profile>
212+
<profile>
213+
<id>MacOS</id>
214+
<activation>
215+
<os>
216+
<family>Mac</family>
217+
</os>
218+
</activation>
219+
<properties>
220+
<os.detected.classifier>mac</os.detected.classifier>
221+
<os.detected.arch>x64</os.detected.arch>
222+
</properties>
223+
</profile>
224+
<profile>
225+
<id>Linux</id>
226+
<activation>
227+
<os>
228+
<name>Linux</name>
229+
</os>
230+
</activation>
231+
<properties>
232+
<os.detected.classifier>linux</os.detected.classifier>
233+
<os.detected.arch>x64</os.detected.arch>
234+
</properties>
235+
</profile>
132236
</profiles>
133237

134-
</project>
238+
</project>

0 commit comments

Comments
 (0)