-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (152 loc) · 5.87 KB
/
ci.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
name: "BuildTestPublish"
on:
push:
branches: [ "*" ]
tags: [ "*" ]
paths-ignore: [ "README.md" ]
workflow_dispatch: { }
env:
JAVA_VERSION: "23"
jobs:
set_variables:
name: "Set build variables"
runs-on: "ubuntu-latest"
outputs:
build_version: "${{ steps.set_variables.outputs.build_version }}"
image_version_short: "${{ steps.set_variables.outputs.image_version_short }}"
java_version: "${{ steps.set_variables.outputs.java_version }}"
docker_image: "${{ steps.set_variables.outputs.docker_image }}"
steps:
- id: "set_variables"
run: |
set -euo pipefail
echo "Setting workflow variables..."
IMAGE_VERSION_SHORT="jdk-${{ env.JAVA_VERSION }}.git-$(echo "$GITHUB_SHA" | head -c 7)"
echo "image_version_short=$IMAGE_VERSION_SHORT" | tee -a "$GITHUB_OUTPUT"
BUILD_VERSION="$IMAGE_VERSION_SHORT.build-$(date +'%Y%m%d%H%M')"
echo "build_version=$BUILD_VERSION" | tee -a "$GITHUB_OUTPUT"
JAVA_VERSION="$(echo "${{ env.JAVA_VERSION }}" | grep -E "^[0-9]+$")"
echo "java_version=$JAVA_VERSION" | tee -a "$GITHUB_OUTPUT"
DOCKER_IMAGE="$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')"
echo "docker_image=$DOCKER_IMAGE" | tee -a "$GITHUB_OUTPUT"
dependency_report:
name: "OWASP DepCheck"
runs-on: "ubuntu-latest"
needs: [ "set_variables" ]
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
with:
persist-credentials: false
- name: "Install JDK"
uses: "actions/setup-java@v4"
with:
distribution: "corretto"
java-version: "${{ needs.set_variables.outputs.java_version }}"
- name: "Cache Maven repository"
uses: "actions/cache@v4"
with:
path: "${{ github.workspace }}/.ci/transient/m2-repo"
key: "${{ runner.os }}-${{ runner.arch }}-owasp-${{ hashFiles('pom.xml') }}"
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-owasp-
- name: "Maven Build"
uses: "./.github/actions/maven"
with:
BUILD_REVISION: "${{ needs.set_variables.outputs.build_version }}"
MAVEN_JOB_ARGS: "dependency-check:check -DnvdApiKey=${{ secrets.NVD_API_KEY }}"
JVMOPT_NATIVE_ACCESS: "ALL-UNNAMED"
- name: "Archive jarfile"
uses: "actions/upload-artifact@v4"
with:
name: "dependency-check-report.html"
path: "target/dependency-check-report.html"
build_hotspot:
name: "Build (HotSpot)"
runs-on: "ubuntu-latest"
needs: [ "set_variables" ]
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
with:
persist-credentials: false
- name: "Install JDK"
uses: "actions/setup-java@v4"
with:
distribution: "corretto"
java-version: "${{ needs.set_variables.outputs.java_version }}"
- name: "Cache Maven repository"
uses: "actions/cache@v4"
with:
path: "${{ github.workspace }}/.ci/transient/m2-repo"
key: "${{ runner.os }}-${{ runner.arch }}-hostpot-${{ hashFiles('pom.xml') }}"
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-hotspot-
- name: "Maven Build"
uses: "./.github/actions/maven"
with:
BUILD_REVISION: "${{ needs.set_variables.outputs.build_version }}"
MAVEN_JOB_ARGS: "verify package"
- name: "Archive jarfile"
uses: "actions/upload-artifact@v4"
with:
name: "mcw.jar"
path: "target/mcw.jar"
publish_hotspot:
name: "Publish (HotSpot)"
needs: [ "set_variables", "build_hotspot" ]
uses: "./.github/workflows/publish.yml"
with:
JAVA_VERSION: "${{ needs.set_variables.outputs.java_version }}"
ARTIFACT_NAME: "mcw.jar"
DOCKER_REGISTRY: "ghcr.io"
DOCKER_IMAGE: "${{ needs.set_variables.outputs.docker_image }}"
DOCKER_TARGET: "hotspot"
DOCKER_TAG_CANONICAL: "${{ needs.set_variables.outputs.build_version }}"
DOCKER_TAG_SHORT: "${{ needs.set_variables.outputs.image_version_short }}"
build_graal:
name: "Build (GraalVM)"
runs-on: "ubuntu-latest"
needs: [ "set_variables", "build_hotspot" ]
container:
image: "ghcr.io/mangadex-pub/jdk-maven:${{ needs.set_variables.outputs.java_version }}-graal"
options: "--user root"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
with:
persist-credentials: false
- name: "Cache Maven repository"
uses: "actions/cache@v4"
with:
path: "${{ github.workspace }}/.ci/transient/m2-repo"
key: "${{ runner.os }}-${{ runner.arch }}-graal-${{ hashFiles('pom.xml') }}"
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-graal-
- name: "Maven Build"
uses: "./.github/actions/maven"
with:
BUILD_REVISION: "${{ needs.set_variables.outputs.build_version }}"
MAVEN_JOB_ARGS: "package -Pnative -DskipTests"
- name: "Archive binary"
uses: "actions/upload-artifact@v4"
with:
name: "mcw-aot"
path: "target/mcw"
- name: "Archive build report"
uses: "actions/upload-artifact@v4"
with:
name: "mcw-aot-build-report.html"
path: "target/mcw-build-report.html"
publish_graal:
name: "Publish (GraalVM)"
needs: [ "set_variables", "build_graal" ]
uses: "./.github/workflows/publish.yml"
with:
JAVA_VERSION: "${{ needs.set_variables.outputs.java_version }}"
ARTIFACT_NAME: "mcw-aot"
DOCKER_REGISTRY: "ghcr.io"
DOCKER_IMAGE: "${{ needs.set_variables.outputs.docker_image }}"
DOCKER_TARGET: "graal"
DOCKER_TAG_CANONICAL: "${{ needs.set_variables.outputs.build_version }}"
DOCKER_TAG_SHORT: "${{ needs.set_variables.outputs.image_version_short }}"