generated from will-molloy/java-template
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (106 loc) · 3.9 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
name: build
on:
pull_request:
push:
branches: [ main ]
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build
run: ./gradlew projects clean build --no-daemon --refresh-dependencies
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.5.0
with:
flags: unit-tests-${{ matrix.os }}
fail_ci_if_error: true
integration-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
- name: Setup HandBrake (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt install handbrake-cli
- name: Setup HandBrake (Windows)
if: matrix.os == 'windows-latest'
run: choco install handbrake-cli
- name: Setup HandBrake (Mac)
if: matrix.os == 'macos-latest'
run: brew install handbrake
# Need to generate encoded files for the integration tests on the GitHub Actions agent.
# Can't simply use the ones stored in git, guessing different hardware, OS, etc. results in
# slightly different output.
- name: Generate test data
run: |
HandBrakeCLI --preset "Production Standard" -i auto-handbrake-cfr/src/integrationTest/resources/Big_Buck_Bunny_360_10s_1MB.mp4 -o auto-handbrake-cfr/src/integrationTest/resources/Big_Buck_Bunny_360_10s_1MB.cfr.mp4
HandBrakeCLI --preset "Production Standard" -i auto-handbrake-cfr/src/integrationTest/resources/Big_Buck_Bunny_360_10s_2MB.mp4 -o auto-handbrake-cfr/src/integrationTest/resources/Big_Buck_Bunny_360_10s_2MB.cfr.mp4
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Integration Test
# use retry cause the integration tests can be flaky. E.g. HandBrake crashing on the agent.
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 10
command: ./gradlew projects clean integrationTest --no-daemon --refresh-dependencies
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.5.0
with:
flags: integration-tests-${{ matrix.os }}
fail_ci_if_error: true
release:
needs: [ build, integration-test ]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
- name: Bump version
id: version
uses: paulhatch/semantic-version@v5.4.0
- name: Build base image
run: docker build -t handbrake-java-base -f base.Dockerfile .
- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker images
run: ./gradlew jib -Djib.to.tags=${{ steps.version.outputs.version }}
- name: Create GitHub tag and release
uses: softprops/action-gh-release@v2.0.8
with:
tag_name: ${{ steps.version.outputs.version_tag }}
generate_release_notes: true