Repository navigation
96 lines (84 loc) · 2.75 KB
/
Copy pathjava-ci.yml
File metadata and controls
96 lines (84 loc) · 2.75 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
86
87
88
89
90
91
92
93
94
95
96
name: Java School Utils CI
on:
push:
pull_request:
release:
types: [published]
jobs:
build:
name: Build Distribution
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Java 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "11"
- name: Install Ant
run: |
sudo apt-get update
sudo apt-get install -y ant
- name: Run tests and build distributable artifacts
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
if [ -n "$RELEASE_TAG" ]; then
ant -Dproject.version="${RELEASE_TAG#v}" dist
elif [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]; then
ant -Dproject.version="${GITHUB_REF_NAME#v}" dist
else
ant dist
fi
- name: Package Javadoc archive
if: github.event_name != 'pull_request'
run: |
cd dist
zip -rq java-school-utils-javadoc.zip javadoc
- name: Upload build artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: java-school-utils-dist
path: |
dist/java-school-utils.jar
dist/java-school-utils-sources.jar
dist/java-school-utils-javadoc.zip
if-no-files-found: error
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: java-school-utils-dist
path: release-artifacts
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event.release.tag_name || github.ref_name }}
run: |
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
gh release upload "$TAG_NAME" \
release-artifacts/java-school-utils.jar \
release-artifacts/java-school-utils-sources.jar \
release-artifacts/java-school-utils-javadoc.zip \
--clobber
else
gh release create "$TAG_NAME" \
release-artifacts/java-school-utils.jar \
release-artifacts/java-school-utils-sources.jar \
release-artifacts/java-school-utils-javadoc.zip \
--title "$TAG_NAME" \
--generate-notes
fi