-
Notifications
You must be signed in to change notification settings - Fork 5
138 lines (123 loc) · 5.15 KB
/
on-push.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
name: Handle Push
on:
push:
branches:
- '**' # respond to a push to any branch
tags:
- '[0-9]+.[0-9]+.[0-9]+' # respond to any release tags with semantic versioning
env:
GRADLE_CACHE_PATH: |
~/.gradle/caches
~/.gradle/wrapper
jobs:
# Run the tests on any branch or tag push
run-tests:
strategy:
matrix:
project: [Library, Test App]
include:
- project: Library
gradle-arguments: testReleaseUnitTest
base-folder: Armadillo
test-report-folder: testReleaseUnitTest
- project: Test App
gradle-arguments: :TestApp:testArmlocalReleaseUnitTest
base-folder: TestApp
test-report-folder: testArmlocalReleaseUnitTest
name: Run ${{ matrix.project }} Tests
runs-on: ubuntu-latest
steps:
# Clone the repo
- name: Clone Repo
uses: actions/checkout@v4
# Cache the gradle build dependencies for faster builds
- name: Cache Gradle Dependencies
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle.properties') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-
# Download Java and set version
- name: Set Up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ vars.JDK_VERSION }}
distribution: 'temurin'
# Test using gradle
- name: Run ${{ matrix.project }} Tests
run: ./gradlew ${{ matrix.gradle-arguments }} --warning-mode all
# Upload the html test report as a build artifact for easier debugging
- name: Upload Test Report
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.project }} Test Reports
path: ${{ matrix.base-folder }}/build/reports/tests/${{ matrix.test-report-folder }}/*
# Upload XML logs as build artifacts (accessible from the Summary page of the run)
- name: Upload JUnit Logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.project }} Testing Logs
path: "${{ matrix.base-folder }}/build/test-results/test*UnitTest/TEST-*.xml"
# If the workflow was started on the main branch then publish the library and test app. If started on a release branch publish only the library.
publish-artifact-to-github-packages-or-s3:
name: Publish ${{ matrix.project }} Release
runs-on: ubuntu-latest
needs: run-tests
strategy:
matrix:
include:
- project: Library
gradle-arguments: :Armadillo:assembleRelease
artifact-name: Armadillo.aar
artifact-path: Armadillo/build/outputs/aar/Armadillo-release.aar
retention-days: 400
- project: Test App
gradle-arguments: :TestApp:assembleArmLocalRelease
artifact-name: TestApp.apk
artifact-path: TestApp/build/outputs/apk/armlocal/release/TestApp-armlocal-release.apk
retention-days: 7
steps:
# Retrieve the repo
- name: Clone Repo
uses: actions/checkout@v4
# Cache the gradle build dependencies for faster builds
- name: Cache Gradle Dependencies
uses: actions/cache@v4
with:
path: ${{ env.GRADLE_CACHE_PATH }}
key: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle.properties') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.gradle-cache-buster') }}-gradle-
# Download Java and set version
- name: Set Up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ vars.JDK_VERSION }}
distribution: 'temurin'
# Build using gradle
- name: Build ${{ matrix.project }} Release
run: ./gradlew ${{ matrix.gradle-arguments }}
# On release/main, push build to Github packages
- name: Publish Release
if: matrix.project == 'Library' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ github.token }}
run: |
./gradlew publishReleaseAarPublicationToGitHubPackagesRepository
# On other branches, push snapshot to Github packages
- name: Publish Snapshot
if: matrix.project == 'Library' && !(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_PASSWORD: ${{ github.token }}
run: |
./gradlew publishReleaseSnapshotAarPublicationToGitHubPackagesRepository
# Upload the AAR file as a build artifact (accessible from the Summary page of the run)
- name: Upload AAR file
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
retention-days: ${{ matrix.retention-days }}