-
Notifications
You must be signed in to change notification settings - Fork 288
76 lines (67 loc) · 3.14 KB
/
Copy pathsnapshot-kmp.yml
File metadata and controls
76 lines (67 loc) · 3.14 KB
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
name: Publish KMP snapshot
on:
push:
branches:
- master
paths:
- "meshtastic/**/*.proto"
- "nanopb.proto"
- "packages/kmp/**"
# Allow republishing on demand (e.g. after a versioning-scheme change that
# touches only this workflow, which the push paths above don't match).
workflow_dispatch:
permissions:
contents: read
jobs:
publish-snapshot:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Set version name
run: |
# Name the snapshot after the latest tag (v-stripped), the commit count
# since that tag, and the short SHA, e.g. 2.7.26.88-gd77b460-SNAPSHOT.
#
# The count goes after a DOT, not a hyphen, and that is load-bearing. In
# Maven's ComparableVersion a dot-separated numeric segment outranks ANY
# hyphen-nested token, so these sort ABOVE the legacy `<tag>-<sha>-SNAPSHOT`
# snapshots still in the repo - whose SHA can tokenize to a huge integer
# (e.g. 678281c -> 678281) that would otherwise dwarf the count and mask
# every new snapshot from dependency bots. Among themselves, higher count =
# newer commit sorts higher, so bots pick the newest. Still sorts ABOVE the
# tag's release (no downgrade) and BELOW the next release. `--long` forces
# the -<N>-g<sha> suffix even on a tagged commit, so a bare `-SNAPSHOT`
# (which sorts below its base) is never produced. (Local fallback in
# build.gradle.kts still uses bare `-SNAPSHOT`.)
#
# Parsed right-to-left (describe = <tag>-<N>-g<sha>) so a hyphenated tag
# like v1.2.3-rc1 would still split correctly.
DESCRIBE=$(git describe --tags --long); DESCRIBE=${DESCRIBE#v}
SHA=${DESCRIBE##*-}; REST=${DESCRIBE%-*}; COUNT=${REST##*-}; TAG=${REST%-*}
echo "VERSION_NAME=${TAG}.${COUNT}-${SHA}-SNAPSHOT" >> "$GITHUB_ENV"
- name: Build KMP package
run: packages/kmp/gradlew --no-daemon -p packages/kmp build -PVERSION_NAME=${{ env.VERSION_NAME }}
- name: Publish snapshot to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_SIGNING_KEY }}
run: |
set -euo pipefail
if [ -z "${ORG_GRADLE_PROJECT_mavenCentralUsername}" ] || [ -z "${ORG_GRADLE_PROJECT_mavenCentralPassword}" ]; then
echo "Missing Maven Central secrets - skipping snapshot publish." >&2
exit 0
fi
packages/kmp/gradlew --no-daemon -p packages/kmp publishAllPublicationsToMavenCentralRepository -PVERSION_NAME=${{ env.VERSION_NAME }}