-
Notifications
You must be signed in to change notification settings - Fork 467
165 lines (160 loc) · 6.26 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: CI/CD
on:
push:
branches:
- dev4
pull_request:
branches:
- dev4
workflow_dispatch:
inputs:
is-a-release:
description: Publish release? (Only works on master, and for untagged versions)
type: boolean
permissions:
contents: write
jobs:
test:
name: Run test suite
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
java-version: [ 22 ]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 22
check-latest: true
# The project version extract NEEDS to have the gradle wrapper already downloaded.
# So we have a dummy step here just to initialize it.
- name: Download Gradle wrapper
run: ./gradlew --version
# Run the tests and upload results/coverage
- name: Run tests
run: ./gradlew test
- name: Upload test coverage to CodeCov.io
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: test-artifacts
retention-days: 21
path: |
**/TEST-*
**/hs_err_pid*
# Build the distribution jar and upload it, without bundling JavaFX in the jar
- name: Create distribution jar
run: ./gradlew assemble -x compileTestJava -Dskip.jfx.bundle=true
- name: Upload distribution jar
if: always()
uses: actions/upload-artifact@v3
with:
name: snapshot-build
retention-days: 30
path: |
recaf-ui/build/libs/recaf-ui-*-all.jar
# Publishes the test results from prior task work
publish-test-results:
name: Publish tests results
needs: test
if: always()
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: test-artifacts
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
check_name: Unit test results
files: |
**/*.xml
# Builds the projects and attempts to publish a release if the current project version
# does not match any existing tags in the repository.
build-and-release:
name: Publish release
needs: test
if: inputs.is-a-release && github.repository == 'Col-E/Recaf' && github.ref == 'refs/heads/master'
strategy:
fail-fast: false
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required depth for JReleaser
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 22
# The project version extract NEEDS to have the gradle wrapper already downloaded.
# So we have a dummy step here just to initialize it.
- name: Download Gradle wrapper
run: ./gradlew --version
# Set environment variable for the project version: "var_to_set=$(command_to_run)" >> sink
# - For maven: echo "PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
# - For gradle: echo "PROJECT_VERSION=$(./gradlew properties | grep -Po '(?<=version: ).*')" >> $GITHUB_ENV
- name: Extract project version to environment variable
run: echo "PROJECT_VERSION=$(./gradlew properties | grep -Po '(?<=version\W ).*')" >> $GITHUB_ENV
# Check if a tag exists that matches the current project version.
# Write the existence state to the step output 'tagExists'.
- name: Check the package version has corresponding Git tag
id: tagged
shell: bash
run: |
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.PROJECT_VERSION }}" && echo "tagExists=1" >> $GITHUB_OUTPUT || echo "tagExists=0" >> $GITHUB_OUTPUT
git show-ref --tags --verify --quiet -- "refs/tags/${{ env.PROJECT_VERSION }}" && echo "Tag for current version exists" || echo "Tag for current version does not exist"
# If the tag could not be fetched, show a message and abort the job.
# The wonky if logic is a workaround for: https://github.com/actions/runner/issues/1173
- name: Abort if tag exists, or existence check fails
if: ${{ false && steps.tagged.outputs.tagExists }}
run: |
echo "Output of 'tagged' step: ${{ steps.tagged.outputs.tagExists }}"
echo "Failed to check if tag exists."
echo "PROJECT_VERSION: ${{ env.PROJECT_VERSION }}"
echo "Tags $(git tag | wc -l):"
git tag
git show-ref --tags --verify -- "refs/tags/${{ env.PROJECT_VERSION }}"
exit 1
# Run build to generate the release artifacts.
# Tag does not exist AND trigger was manual. Deploy release artifacts!
- name: Build release artifacts
run: ./gradlew publish # TODO: Publish all modules' artifacts into a single directory
# Make release with JReleaser, only running when the project version does not exist as a tag on the repository.
- name: Publish release
uses: jreleaser/release-action@v2
with:
arguments: full-release
env:
JRELEASER_PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_DEPLOY_MAVEN_NEXUS2_USERNAME }}
JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_DEPLOY_MAVEN_NEXUS2_PASSWORD }}
# Upload JRelease debug log
- name: JReleaser output
uses: actions/upload-artifact@v3
if: always()
with:
name: jreleaser-release
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties