-
Notifications
You must be signed in to change notification settings - Fork 4
126 lines (114 loc) · 4.15 KB
/
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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Tag in SemVer format'
required: true
type: string
jobs:
validation:
runs-on: ubuntu-latest
steps:
- name: Validate tag
run: |
echo "${{ github.event.inputs.version }}" | grep -P '^[0-9]+\.[0-9]+\.[0-9]+'
swift:
runs-on: macos-latest
needs: validation
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: "aarch64-apple-ios-sim,aarch64-apple-ios,x86_64-apple-ios"
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- uses: taiki-e/install-action@v2
with:
tool: cargo-swift
- name: Generate Swift package
run: cargo swift package -p ios -n MobileSdkRs --release
- name: Compress XCFramework
run: |
zip -9 -r RustFramework.xcframework.zip MobileSdkRs/RustFramework.xcframework
echo "XCF_CHECKSUM=`swift package compute-checksum RustFramework.xcframework.zip`" >> $GITHUB_ENV
- name: Update Swift Package definition
run: |
sed -i '' 's/.binaryTarget.*/.binaryTarget(name: "RustFramework", url: "https:\/\/github.com\/spruceid\/mobile-sdk-rs\/releases\/download\/${{ github.event.inputs.version }}\/RustFramework.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),/' Package.swift
- name: Update Cocoapods definitions
run: |
sed -i '' -r 's/[0-9]+.[0-9]+.[0-9]+/${{ github.event.inputs.version }}/' SpruceIDMobileSdkRsRustFramework.podspec
sed -i '' -r 's/[0-9]+.[0-9]+.[0-9]+/${{ github.event.inputs.version }}/' SpruceIDMobileSdkRs.podspec
- name: Push changes and tag
run: |
git config user.name github-actions
git config user.email [email protected]
git add Package.swift SpruceIDMobileSdkRs.podspec SpruceIDMobileSdkRsRustFramework.podspec
git commit -m "Release ${{ github.event.inputs.version }}"
git push
git tag ${{ github.event.inputs.version }} -m "${{ github.event.inputs.version }}"
git push --tags
- name: Create release and attach XCFramework binary artifact
uses: ncipollo/release-action@v1
with:
artifacts: "RustFramework.xcframework.zip"
tag: ${{ github.event.inputs.version }}
name: ${{ github.event.inputs.version }}
- name: Publish to CocoaPod register
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push SpruceIDMobileSdkRsRustFramework.podspec
pod trunk push SpruceIDMobileSdkRs.podspec --synchronous
kotlin:
runs-on: ubuntu-latest
needs: validation
defaults:
run:
working-directory: ./kotlin
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: "aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android"
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- uses: taiki-e/install-action@v2
with:
tool: cargo-ndk
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_KEY }}
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Publish package to GHCR
uses: gradle/gradle-build-action@v2
with:
arguments: publish
build-root-directory: ./kotlin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
- name: Publish package to Central
uses: gradle/gradle-build-action@v2
with:
arguments: publishReleasePublicationToCentralPortal
build-root-directory: ./kotlin
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
VERSION: ${{ github.event.inputs.version }}