-
Notifications
You must be signed in to change notification settings - Fork 9
157 lines (138 loc) · 6.54 KB
/
snapshot-release.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
147
148
149
150
151
152
153
154
155
156
157
name: Publish Snapshot builds
on: [pull_request]
permissions:
pull-requests: write # Write access needed to create a comment.
jobs:
publish:
name: Snapshot build and publish
runs-on: ubuntu-latest
outputs:
snapshot_version: ${{ steps.set-snapshot-version.outputs.VERSION }}
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: ./.github/actions/setup-android
# Using branch name for name of snapshot. Makes it easy to remember and can easily trigger new builds of Remote Habits.
- name: Set snapshot version
id: set-snapshot-version
env:
# Get the current branch name and replace all / characters with - as / is invalid in gradle names.
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: echo "VERSION=$(echo ${PR_HEAD_REF} | sed -r 's/\//-/g')-SNAPSHOT" >> $GITHUB_OUTPUT
- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository
env:
OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }}
SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }}
SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
MODULE_VERSION: ${{ steps.set-snapshot-version.outputs.VERSION }}
SNAPSHOT: true
- name: Find old comment to update comment for
uses: peter-evans/find-comment@v3
id: find-previous-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Build available to test
- name: Inform pull request on build of SDK available to test
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-previous-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Build available to test
Version: `${{ steps.set-snapshot-version.outputs.VERSION }}`
Repository: `https://s01.oss.sonatype.org/content/repositories/snapshots/`
edit-mode: replace
token: ${{ secrets.GITHUB_TOKEN }}
# This job depends on the publish job to finish so we can use the snapshot version to verify
# gradle compatibility of the sample apps with actual releases of the SDK with latest changes.
gradle-compatibility-builds:
name: ${{ matrix.sample-app }} build with AGP ${{ matrix.agp-version }}
needs: publish
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Matrix of sample apps and AGP versions to test
# List all sample apps here that you want to test with the AGP versions.
sample-app-with-agp:
- "java_layout_sdk"
- "kotlin_compose_sdk"
- "java_layout_7"
- "kotlin_compose_7"
include:
- sample-app-with-agp: "java_layout_sdk"
sample-app: "java_layout"
cio-siteid-secret-key: "CUSTOMERIO_JAVA_WORKSPACE_SITE_ID"
cio-cdpapikey-secret-key: "CUSTOMERIO_JAVA_WORKSPACE_CDP_API_KEY"
agp-version: "8.3.1"
gradle-version: "8.4"
- sample-app-with-agp: "kotlin_compose_sdk"
sample-app: "kotlin_compose"
cio-siteid-secret-key: "CUSTOMERIO_KOTLIN_WORKSPACE_SITE_ID"
cio-cdpapikey-secret-key: "CUSTOMERIO_KOTLIN_WORKSPACE_CDP_API_KEY"
agp-version: "8.3.1"
gradle-version: "8.4"
- sample-app-with-agp: "java_layout_7"
sample-app: "java_layout"
cio-siteid-secret-key: "CUSTOMERIO_JAVA_WORKSPACE_SITE_ID"
cio-cdpapikey-secret-key: "CUSTOMERIO_JAVA_WORKSPACE_CDP_API_KEY"
agp-version: "7.4.1"
gradle-version: "7.6.4"
- sample-app-with-agp: "kotlin_compose_7"
sample-app: "kotlin_compose"
cio-siteid-secret-key: "CUSTOMERIO_KOTLIN_WORKSPACE_SITE_ID"
cio-cdpapikey-secret-key: "CUSTOMERIO_KOTLIN_WORKSPACE_CDP_API_KEY"
agp-version: "7.4.1"
gradle-version: "7.6.4"
steps:
- uses: actions/checkout@v4
# If using sd on macos, "brew install" works great. for Linux, this is the recommended way.
- name: Install sd CLI to use later in the workflow
uses: kenji-miyake/setup-sd@v2
- name: Install tools from Gemfile (ruby language) used for building our apps with
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Setup local.properties file for sample app
# Use recently published snapshot version to make sure we're testing the latest changes.
run: |
touch "samples/local.properties"
echo "sdkVersion=${{ needs.publish.outputs.snapshot_version }}" >> "samples/local.properties"
echo "siteId=${{ secrets[matrix.cio-siteid-secret-key] }}" >> "samples/local.properties"
echo "cdpApiKey=${{ secrets[matrix.cio-cdpapikey-secret-key] }}" >> "samples/local.properties"
- name: Update files for Gradle compatibility
# If AGP version matches the default value, we don't need to specify further versions.
run: |
./scripts/update-gradle-compatibility.sh \
--agpVersion ${{ matrix.agp-version }} \
--gradleVersion ${{ matrix.gradle-version }}
- name: Install Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Install Android SDK
uses: android-actions/setup-android@v3
- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ matrix.gradle-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-${{ matrix.gradle-version }}-
- name: Verify gradle scripts are valid gradle scripts
uses: gradle/actions/wrapper-validation@v3
- name: Set up Gradle Version ${{ matrix.gradle-version }}
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: ${{ matrix.gradle-version }}
- name: Building ${{ matrix.sample-app }} with AGP version ${{ matrix.agp-version }}
run: ./gradlew ":samples:${{ matrix.sample-app }}:assembleRelease"