Skip to content

Commit fc0c92c

Browse files
committed
Migrate to JReleaser via github actions for creating releases
1 parent 20266c3 commit fc0c92c

File tree

5 files changed

+166
-67
lines changed

5 files changed

+166
-67
lines changed

.drone.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
permissions:
12+
checks: write
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
build:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
# Alternative for testing on multiple platforms. Ubuntu runs the quickest with the latest JVM.
22+
# os: [ubuntu-latest, windows-latest, macos-latest]
23+
# java-version: [11, 17]
24+
os: [ ubuntu-latest ]
25+
java-version: [ 17 ]
26+
runs-on: ${{ matrix.os }}
27+
timeout-minutes: 10
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0 # Required depth for JReleaser
33+
- name: Setup Java JDK
34+
uses: actions/setup-java@v3
35+
with:
36+
distribution: adopt-hotspot
37+
java-version: ${{ matrix.java-version }}
38+
39+
# Run tests & build artifact
40+
- name: Run tests & build release
41+
run: ./mvnw package
42+
43+
# Upload test results
44+
- name: Upload Test Results
45+
uses: actions/[email protected]
46+
if: always()
47+
with:
48+
name: Event File
49+
retention-days: 21
50+
path: |
51+
**/TEST-*
52+
**/hs_err_pid*
53+
54+
# Set JReleaser version to the project version: "var_to_set=$(command_to_run)" >> sink
55+
# - For maven: echo "JRELEASER_PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
56+
# - For gradle: echo "JRELEASER_PROJECT_VERSION=$(./gradlew properties | grep -Po '(?<=version: ).*')" >> $GITHUB_ENV
57+
- name: Extract project version to environment variable
58+
run: echo "JRELEASER_PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
59+
60+
# Check if a tag exists that matches the current project version.
61+
# Write the existence state to the step output 'tagExists'.
62+
- name: 'Check: package version has corrosponding git tag'
63+
id: tagged
64+
shell: bash
65+
run: git show-ref --tags --verify --quiet -- "refs/tags/${{ env.JRELEASER_PROJECT_VERSION }}" && echo "tagExists=1" >> $GITHUB_OUTPUT || echo "tagExists=0" >> $GITHUB_OUTPUT
66+
67+
# Make release with JReleaser, only running when the project version does not exist as a tag on the repository.
68+
- name: Release
69+
if: steps.tagged.outputs.tagExists == 0
70+
uses: jreleaser/release-action@v2
71+
with:
72+
arguments: full-release
73+
env:
74+
JRELEASER_PROJECT_VERSION: ${{ env.JRELEASER_PROJECT_VERSION }}
75+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
# Upload JRelease debug log
78+
- name: JReleaser output
79+
if: steps.tagged.outputs.tagExists == 0
80+
uses: actions/upload-artifact@v3
81+
with:
82+
name: jreleaser-release
83+
path: |
84+
out/jreleaser/trace.log
85+
out/jreleaser/output.properties
86+
87+
# Taken from: https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#support-fork-repositories-and-dependabot-branches
88+
# - Required for test-results to be published
89+
event_file:
90+
name: "Event File"
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Upload
94+
uses: actions/upload-artifact@v2
95+
with:
96+
name: Event File
97+
path: ${{ github.event_path }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# taken from https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.20/README.md#support-fork-repositories-and-dependabot-branches
2+
name: Unit Test Results
3+
4+
on:
5+
workflow_run:
6+
workflows:
7+
- CI
8+
types:
9+
- completed
10+
11+
jobs:
12+
unit-test-results:
13+
name: Unit Test Results
14+
runs-on: ubuntu-latest
15+
if: github.event.workflow_run.conclusion != 'skipped'
16+
17+
steps:
18+
- name: Download and Extract Artifacts
19+
env:
20+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
21+
run: |
22+
mkdir -p artifacts && cd artifacts
23+
24+
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
25+
26+
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
27+
do
28+
IFS=$'\t' read name url <<< "$artifact"
29+
gh api $url > "$name.zip"
30+
unzip -d "$name" "$name.zip"
31+
done
32+
- name: Publish Unit Test Results
33+
uses: EnricoMi/publish-unit-test-result-action@v1
34+
with:
35+
commit: ${{ github.event.workflow_run.head_sha }}
36+
event_file: artifacts/Event File/event.json
37+
event_name: ${{ github.event.workflow_run.event }}
38+
files: "artifacts/**/*.xml"

.releaserc.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

jreleaser.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
project:
2+
name: lljzip
3+
description: Lower level ZIP support for Java.
4+
longDescription: Lower level ZIP support for Java, for when abstraction is not desired.
5+
links:
6+
homepage: https://github.com/Col-E/LL-Java-Zip
7+
authors:
8+
- Matt Coley
9+
license: MIT
10+
inceptionYear: 2022
11+
stereotype: none
12+
java:
13+
version: 11
14+
groupId: software.coley
15+
artifactId: lljzip
16+
17+
release:
18+
github:
19+
overwrite: true
20+
tagName: '{{projectVersion}}'
21+
changelog:
22+
formatted: ALWAYS
23+
preset: conventional-commits
24+
contributors:
25+
format: '- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}'
26+
27+
distributions:
28+
dist:
29+
type: SINGLE_JAR
30+
artifacts:
31+
- path: target/{{projectName}}-{{projectVersion}}.jar

0 commit comments

Comments
 (0)