-
-
Notifications
You must be signed in to change notification settings - Fork 1
152 lines (148 loc) · 5.38 KB
/
publish.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
name: Publish
on:
push:
tags: ["*"]
concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref_name}}
jobs:
build:
runs-on: ${{matrix.os}}
name: Build ${{matrix.platform}} packages
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: common
targets: publishKotlinMultiplatformPublicationToLocalRepository
- os: ubuntu-latest
platform: JVM
targets: publishJvmPublicationToLocalRepository
- os: ubuntu-latest
platform: Android
targets: publishAndroidReleasePublicationToLocalRepository
- os: ubuntu-latest
platform: JS
targets: publishJsPublicationToLocalRepository
- os: ubuntu-latest
platform: Linux
targets: >-
publishLinuxX64PublicationToLocalRepository
publishLinuxArm64PublicationToLocalRepository
- os: windows-latest
platform: Windows
targets: publishMingwX64PublicationToLocalRepository
- os: macos-14
platform: macOS/iOS
targets: >-
publishMacosX64PublicationToLocalRepository
publishMacosArm64PublicationToLocalRepository
publishIosArm64PublicationToLocalRepository
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: gradle
cache-dependency-path: |
gradle/libs.versions.toml
gradle/wrapper/gradle-wrapper.properties
- name: Set up cross compilation
run: sudo apt-get install -qy {binutils,gcc}-aarch64-linux-gnu
if: matrix.platform == 'Linux' || matrix.platform == 'common'
- name: Get the cache versions
id: versions
shell: sh
run: |-
{
sed -n 's/kotlin-stdlib = "\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)"/kotlin=\1.\2.\3/p' gradle/libs.versions.toml
} >> "$GITHUB_OUTPUT"
- name: Restore Kotlin/Native prebuilt
uses: actions/cache/restore@v4
with:
path: ${{runner.tool_cache}}/konan/kotlin-native-prebuilt-*
key: konan-${{runner.os}}-prebuilt-${{steps.versions.outputs.kotlin}}
- name: Restore Kotlin/Native dependencies
uses: actions/cache/restore@v4
if: matrix.platform != 'JVM' && matrix.platform != 'Android' && matrix.platform != 'JS'
with:
path: ${{runner.tool_cache}}/konan/dependencies
key: konan-${{runner.os}}-dependencies
- name: Build packages
run: ./gradlew --no-daemon ${{matrix.targets}}
env:
SIGNING_KEY: ${{secrets.SIGNING_KEY}}
SIGNING_PASSWORD: ${{secrets.SIGNING_PASSWORD}}
KONAN_DATA_DIR: ${{runner.tool_cache}}/konan
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: kbigint-${{matrix.platform == 'macOS/iOS' && 'macOS-iOS' || matrix.platform}}
path: |
build/repo/**
!build/repo/**/maven-metadata.*
retention-days: 2
publish:
runs-on: ubuntu-latest
name: Publish packages on Maven Central
needs: [build]
environment:
name: sonatype
url: https://central.sonatype.com/artifact/io.github.observeroftime.kbigint/kbigint
env:
SONATYPE_API: https://central.sonatype.com/api/v1/publisher
SONATYPE_AUTH: "Authorization: Bearer ${{secrets.SONATYPE_TOKEN}}"
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: kbigint
pattern: kbigint-*
merge-multiple: true
- name: Upload bundle
run: |-
url="$SONATYPE_API/upload?name=kbigint-${GITHUB_REF_NAME}.zip&publishingType=USER_MANAGED"
(cd kbigint && zip -qr ../kbigint.zip *)
printf >> "$GITHUB_ENV" 'DEPLOYMENT_ID=%s\n' $(curl -Ssf [email protected] -H "$SONATYPE_AUTH" "$url")
- name: Verify status
timeout-minutes: 5
run: |-
url="$SONATYPE_API/status?id=$DEPLOYMENT_ID"
while [[ ${state:=PENDING} == PENDING ]] || [[ $state == VALIDATING ]]; do
state=$(curl -Ssf -XPOST -H "$SONATYPE_AUTH" "$url" | jq -r .deploymentState)
done
if [[ $state == FAILED ]]; then
printf '::error title=Publication failed::Check https://central.sonatype.com/publishing/deployments\n'
exit 1
fi
- name: Publish deployment
run: curl -fi -XPOST -H "$SONATYPE_AUTH" "$SONATYPE_API/deployment/$DEPLOYMENT_ID"
release:
runs-on: ubuntu-latest
name: Create GitHub release
needs: [publish]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
uses: orhun/git-cliff-action@v3
id: cliff
with:
args: -v --current
config: .github/cliff.toml
env:
OUTPUT: changes.md
GITHUB_TOKEN: ${{github.token}}
GITHUB_REPO: ${{github.repository}}
- name: Create release
run: gh release create $GITHUB_REF_NAME -F '${{steps.cliff.outputs.changelog}}'
env:
GH_TOKEN: ${{github.token}}