-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (75 loc) · 2.79 KB
/
ci_cd.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
name: CI/CD
on:
# Push on main excluding tags
push:
branches:
- 'main'
tags-ignore:
- '*.*'
# PR
pull_request:
branches:
- 'main'
# When a release is published
release:
types: [published]
# Manual trigger
workflow_dispatch:
jobs:
build:
name: CI/CD
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17 and gradle cache
id: java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Check if main repo
id: is_main_repo
run: |
if [ $REPO_NAME == 'openremote/console-android' ]; then
echo "value=true" >> $GITHUB_OUTPUT
fi
env:
REPO_NAME: ${{ github.repository }}
- name: Run assemble
if: ${{ !steps.is_main_repo.outputs.value || github.event_name == 'pull_request' }}
run: |
gradle assemble
- name: Run assemble and publish
if: ${{ steps.is_main_repo.outputs.value && github.event_name != 'pull_request' }}
run: |
echo "$KEYSTORE_BASE64" | base64 -d > keystore
command="gradle assemble publishToSonatype closeSonatypeStagingRepository"
command="$command -PsigningKey=$MAVEN_SIGNING_KEY -PsigningPassword=$MAVEN_SIGNING_PASSWORD -PpublishUsername=$MAVEN_USERNAME -PpublishPassword=$MAVEN_PASSWORD"
command="$command -PkeystoreKeyAlias=$KEYSTORE_KEY_ALIAS -PkeystoreKeyPassword=$KEYSTORE_KEY_PASSWORD -PkeystoreFile=$PWD/keystore -PkeystorePassword=$KEYSTORE_PASSWORD"
$command
env:
EVENT_NAME: ${{ github.event_name }}
MAVEN_SIGNING_KEY: ${{ secrets._TEMP_MAVEN_SIGNING_KEY || secrets.MAVEN_SIGNING_KEY }}
MAVEN_SIGNING_PASSWORD: ${{ secrets._TEMP_MAVEN_SIGNING_PASSWORD || secrets.MAVEN_SIGNING_PASSWORD }}
MAVEN_USERNAME: ${{ secrets._TEMP_MAVEN_USERNAME || secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets._TEMP_MAVEN_PASSWORD || secrets.MAVEN_PASSWORD }}
MAVEN_TAG: ${{ github.ref_name }}
KEYSTORE_BASE64: |
${{ secrets.ANDROID_KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
KEYSTORE_KEY_ALIAS: ${{ secrets.ANDROID_KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }}
- name: Upload build outputs
if: success()
uses: actions/upload-artifact@v4
with:
name: build-outputs
path: |
**/build/outputs/**/*.aar
**/build/outputs/**/*.apk