-
-
Notifications
You must be signed in to change notification settings - Fork 49
146 lines (129 loc) · 5.55 KB
/
main.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
name: Java CI with Maven
env:
# find out this value by opening `https://api.github.com/repos/<owner>/<repo>/releases`. then find the correct release.
# in your browser and copy the full "upload_url" value including the {?name,label} part.
UPLOAD_URL: https://uploads.github.com/repos/MarginallyClever/Robot-Overlord-App/releases/28206919/assets{?name,label}
RELEASE_ID: 28206919 # same as above (id can just be taken out the upload_url, it's used to find old releases)
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Build and Test with Maven
timeout-minutes: 15
run: ./mvnw -B test
- name: Generate JaCoCo Badge
if: github.ref != 'refs/heads/master'
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
- name: Commit and push the badge (if it changed)
if: github.ref != 'refs/heads/master'
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'commit badge'
add: '*.svg'
- name: Package with Maven
run: ./mvnw -B clean package -DskipTests
- name: Prepare universal package
shell: bash
run: |
mkdir -p target/universal-package &&
cp src/main/package/*.bat target/universal-package/ &&
cp src/main/package/start* target/universal-package/ &&
cp CONTRIBUTING.md target/universal-package/ &&
cp LICENSE target/universal-package/ &&
cp README.md target/universal-package/ &&
cp target/RobotOverlord-*-with-dependencies.jar target/universal-package/ &&
cd target/universal-package/ &&
7z a -tzip RobotOverlord.zip . &&
mv RobotOverlord.zip ../..
- name: prepare package for distro
shell: bash
run: |
mkdir -p target/package
cp src/main/package/*.bat target/package/ &&
cp src/main/package/start* target/package/ &&
cp CONTRIBUTING.md target/package/ &&
cp LICENSE target/package/ &&
cp README.md target/package/
- name: Deploy universal release
if: github.repository == 'MarginallyClever/Robot-Overlord-App' && github.ref == 'refs/heads/master'
uses: WebFreak001/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # automatically provided by github actions
with:
upload_url: ${{ env.UPLOAD_URL }}
release_id: ${{ env.RELEASE_ID }}{
asset_path: RobotOverlord.zip # path to archive to upload
asset_name: RobotOverlord-nightly-$$.zip # name to upload the release as, use $$ to insert date (YYYYMMDD) and 6 letter commit hash
asset_content_type: application/zip # required by GitHub API
max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted
- name: Upload artifact for package
uses: actions/[email protected]
with:
name: jar
retention-days: 1
path: |
src/main/package/jpackage*
src/main/package/logo*
LICENSE
README
target/package/*
package:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- uses: actions/[email protected]
with:
name: jar
- name: Check files
run: ls -l target/package/
- name: Build installation package
shell: bash
run: |
set -x
set -o pipefail
APP_VERSION=$(ls -1 target/package/RobotOverlord-*-with-dependencies.jar | sed "s/.*RobotOverlord-\([^-]*\)-with-dependencies.jar/\1/") &&
sed -i.bak "s/\(--app-version\).*/\1 $APP_VERSION/" src/main/package/jpackage.cfg &&
jpackage "@src/main/package/jpackage.cfg" "@src/main/package/jpackage-${{matrix.os}}.cfg" --main-jar "RobotOverlord-$APP_VERSION-with-dependencies.jar" &&
ls &&
BINARY=$(find . -maxdepth 1 -iname 'robotoverlord*' | grep -E '(msi$|dmg$|deb$)' | sed "s,./,," | head -1) &&
BINARY_NIGHTLY=$(echo $BINARY | sed 's/\(.*\)\.\(.*\)/\1-nightly-$$.\2/') &&
echo "BINARY=$BINARY" | tee -a $GITHUB_ENV &&
echo "BINARY_NIGHTLY=$BINARY_NIGHTLY" | tee -a $GITHUB_ENV
- name: Deploy installation release
if: github.repository == 'MarginallyClever/Robot-Overlord-App' && github.ref == 'refs/heads/master'
uses: WebFreak001/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # automatically provided by github actions
with:
upload_url: ${{ env.UPLOAD_URL }}
release_id: ${{ env.RELEASE_ID }}
asset_path: ${{ env.BINARY }} # path to archive to upload
asset_name: ${{ env.BINARY_NIGHTLY }} # name to upload the release as, use $$ to insert date (YYYYMMDD) and 6 letter commit hash
asset_content_type: application/zip # required by GitHub API
max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted
- name: Upload artifact for testing purpose
# if: github.repository == 'MarginallyClever/Robot-Overlord-App' || github.ref != 'refs/heads/master'
uses: actions/[email protected]
with:
name: ${{ env.BINARY }}
retention-days: 2
path: ${{ env.BINARY }}