-
Notifications
You must be signed in to change notification settings - Fork 68
86 lines (74 loc) · 3.18 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
name: build
on: [push, pull_request, workflow_dispatch]
# workflow_dispatch should make manually triggered ci/cd possible
# workflow file (like this) with `workflow_dispatch` after on should exist on the **master** or default branch,
# or there will be no ui for a manual trigger. https://github.community/t/workflow-dispatch-event-not-working/128856/2
env:
GRADLE_OPTS: "-Xms128m -Xmx1024m"
ORG_GRADLE_PROJECT_logOutput: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# pull all the commits, so the commit count of the artifact name will be correct
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11' # major or semver Java version will be acceptable, see https://github.com/marketplace/actions/setup-java-jdk#basic
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- name: Cache gradle modules
uses: actions/cache@v2
with:
# gradle packages that need to be cached
path: |
.gradle
$HOME/.gradle
$HOME/.m2
# key to identify the specific cache
# so if we upgrade some modules, the key(hash) of `gradle.properties` will change
# and we will rerun the download to get the newest packages
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# build cache is used when we need to publish the artifact
- name: Cache build outputs
uses: actions/cache@v2
with:
path: ./*
key: ${{ github.run_id }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build via Gradle
run: ./gradlew clean build
- name: Report to Codecov
run: bash <(curl -s https://codecov.io/bash) -t 9c42ff48-d98f-4444-af05-cf734aa1dbd0
snapshot:
name: Publish snapshot to Github Packages
needs: [build]
runs-on: ubuntu-latest
# only publish the snapshot when it is a push on the master or the release branch (starts with r0.x or r1.x)
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/r0.') || startsWith(github.ref, 'refs/heads/r1.')) }}
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }}
steps:
# gradle packages that need to be cached
- name: Cache gradle modules
uses: actions/cache@v2
with:
path: |
.gradle
$HOME/.gradle
$HOME/.m2
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# publish the artifact from the build cache
- name: Cache build outputs
uses: actions/cache@v2
with:
path: ./*
key: ${{ github.run_id }}
- name: Publish to Github Packages
run: ./gradlew publish -PpublishUrl=https://maven.pkg.github.com/${{github.repository}} -PpublishUsername=${{github.actor}} -PpublishPassword=${{secrets.GITHUB_TOKEN}}