Repository navigation
85 lines (81 loc) · 3 KB
/
Copy pathci.yml
File metadata and controls
85 lines (81 loc) · 3 KB
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
name: CI and release
on:
push:
branches: [master]
tags: ['v*']
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27']
steps:
- uses: actions/checkout@v4
- name: Build and check on Java ${{ matrix.java }}
env:
JAVA_VERSION: ${{ matrix.java }}
run: |
# Java 27 is only published in Docker's official azul-zulu image.
image="azul/zulu-openjdk:$JAVA_VERSION"
if [ "$JAVA_VERSION" = 27 ]; then image="azul-zulu:27"; fi
jar="IFADHttpsClientTest-java$JAVA_VERSION.jar"
case "$JAVA_VERSION" in
7|8) target="-source $JAVA_VERSION -target $JAVA_VERSION" ;;
*) target="--release $JAVA_VERSION" ;;
esac
mkdir -p dist
docker run --rm -v "$PWD:/workspace" -w /workspace "$image" sh -c "
rm -rf build/classes && mkdir -p build/classes &&
javac $target -d build/classes src/main/java/org/ifad/portal/httpsclienttest/HttpsClientTest.java &&
jar cfe dist/$jar org.ifad.portal.httpsclienttest.HttpsClientTest -C build/classes ."
test -s "dist/$jar"
set +e
smoke=$(docker run --rm -v "$PWD/dist/$jar:/app.jar:ro" "$image" java -jar /app.jar --help 2>&1)
smoke_status=$?
set -e
printf '%s\n' "$smoke"
if [ "$smoke_status" -ne 0 ]; then
echo "::error::Docker smoke exit $smoke_status: ${smoke//$'\n'/ }"
exit "$smoke_status"
fi
set +e
output=$(docker run --rm -v "$PWD/dist/$jar:/app.jar:ro" "$image" java -jar /app.jar \
https://dv-g3b-emudhra.we-have-a-problem.com/ \
https://dv-g3b-aaa-emudhra.we-have-a-problem.com/ 2>&1)
status=$?
set -e
printf '%s\n' "$output"
case "$status" in
0) result=REJECTED ;;
1) result=TRUSTED ;;
2) result=INCONCLUSIVE ;;
*) echo "::error::Docker exit $status: ${output//$'\n'/ }"; exit "$status" ;;
esac
echo "Java $JAVA_VERSION ($image): $result" >> "$GITHUB_STEP_SUMMARY"
if [ "$status" -eq 2 ]; then exit 2; fi
- uses: actions/upload-artifact@v4
with:
name: jar-java${{ matrix.java }}
path: dist/*.jar
if-no-files-found: error
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: jar-java*
path: dist
merge-multiple: true
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" dist/*.jar --repo "$GITHUB_REPOSITORY" --generate-notes