Skip to content

Commit 0387832

Browse files
committed
Improve Versioning in Workflow
and added gradle task to output version.
1 parent dce0c9f commit 0387832

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ name: Publish
33
on:
44
workflow_dispatch:
55
push:
6-
paths-ignore:
7-
- '.gitignore'
8-
- 'CONTRIBUTING.md'
9-
- 'LICENSE'
10-
- 'README.md'
11-
- 'licenseheader.txt'
6+
branches:
7+
- 'main'
8+
paths-ignore:
9+
- '.gitignore'
10+
- 'CONTRIBUTING.md'
11+
- 'LICENSE'
12+
- 'README.md'
13+
- 'licenseheader.txt'
1214

1315
jobs:
1416
build:
@@ -27,14 +29,17 @@ jobs:
2729
uses: gradle/actions/wrapper-validation@v4
2830
- name: Build Project with Gradle
2931
run: ./gradlew build
32+
# print github project version to an environment variable.
33+
- name: Print project version from build.gradle
34+
run: echo "VERSION_INFORMATION=$(${{github.workspace}}/gradlew -q printVersion)" >> $GITHUB_ENV
3035
- name: Archive Artifacts to Action.
3136
uses: actions/upload-artifact@v4
3237
if: success()
3338
with:
34-
name: DCIFileReader
39+
name: DCIFileReader-${{ env.VERSION_INFORMATION }}
3540
path: build/libs/DCIFileReader-*.jar
3641
# https://cli.github.com/manual/gh_release_create
3742
- name: Create release
38-
run: gh release create draft build/libs/DCIFileReader-*.jar --draft --latest --notes "https://github.com/${{github.repository}}/commit/${{github.sha}} https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}"
43+
run: gh release create ${{ env.VERSION_INFORMATION }} build/libs/DCIFileReader-*.jar --draft --latest --notes "**Full Changelog:** https://github.com/${{github.repository}}/commit/${{github.sha}} --- [Action Run & Artifacts](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}})"
3944
env:
4045
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ repositories {
1010
maven { url = 'https://repo.erdbeerbaerlp.de/repository/maven-public/' }
1111
}
1212

13+
tasks.register("printVersion") {
14+
println project.version
15+
}
16+
1317
dependencies {
1418
compileOnly 'de.erdbeerbaerlp:dcintegration.common:3.1.0'
1519
compileOnly group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'

0 commit comments

Comments
 (0)