-
Notifications
You must be signed in to change notification settings - Fork 10
189 lines (158 loc) · 6.03 KB
/
package-ffi-engine.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Package FFI Engine
on:
pull_request:
branches:
- main
push:
tags: ["flipt-engine-ffi-v**"]
workflow_dispatch:
inputs:
tag:
description: "Tag (e.g. v0.1.0)"
required: true
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use_cross: false
- name: Linux-arm64
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
use_cross: true
- name: Linux-x86_64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
use_cross: true
- name: Linux-arm64-musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
use_cross: true
- name: Darwin-arm64
os: macos-latest
target: aarch64-apple-darwin
use_cross: false
- name: Darwin-x86_64
os: macos-latest
target: x86_64-apple-darwin
use_cross: false
- name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
use_cross: false
- name: iOS-arm64
os: macos-latest
target: aarch64-apple-ios
use_cross: false
- name: iOS-arm64-sim
os: macos-latest
target: aarch64-apple-ios-sim
use_cross: false
- name: Android-arm64
os: ubuntu-latest
target: aarch64-linux-android
use_cross: true
- name: Android-x86_64
os: ubuntu-latest
target: x86_64-linux-android
use_cross: true
runs-on: ${{ matrix.platform.os }}
env:
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.platform.name }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.platform.target }}
override: true
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.platform.target}}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Set RUSTFLAGS
if: endsWith(matrix.platform.target, '-musl') || endsWith(matrix.platform.target, '-android')
run: |
echo "RUSTFLAGS=-C target-feature=-crt-static" >> $GITHUB_ENV
- name: Install cross from GitHub
run: |
which cross || cargo install cross --git https://github.com/cross-rs/cross
- name: Build ${{ matrix.platform.name }}
uses: actions-rs/cargo@v1
with:
command: build
args: -p flipt-engine-ffi --target ${{ matrix.platform.target }} --release
use-cross: ${{ matrix.platform.use_cross }}
- if: startsWith(matrix.platform.name, 'Darwin')
run: |
strip -x target/${{ matrix.platform.target }}/release/libfliptengine.dylib
- if: startsWith(matrix.platform.name, 'Linux-x86_64')
run: |
strip -x target/${{ matrix.platform.target }}/release/libfliptengine.so
- if: ${{ !startsWith(matrix.platform.name, 'Windows') }}
run: |
tar -czvf flipt-engine-ffi-${{ matrix.platform.name }}.tar.gz \
target/${{ matrix.platform.target }}/release/libfliptengine.* \
|| true
- if: startsWith(matrix.platform.name, 'Windows')
run: |
7z a -tzip flipt-engine-ffi-${{ matrix.platform.name }}.zip `
target\${{ matrix.platform.target }}\release\fliptengine.* `
|| true
- name: Upload Artifact (Pull Request)
uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: flipt-engine-ffi-${{ matrix.platform.name }}${{ startsWith(matrix.platform.name, 'Windows') && '.zip' || '.tar.gz' }}
path: flipt-engine-ffi-${{ matrix.platform.name }}${{ startsWith(matrix.platform.name, 'Windows') && '.zip' || '.tar.gz' }}
retention-days: 1
- name: Upload Release Assets (Tag)
uses: softprops/action-gh-release@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/flipt-engine-ffi-v')
with:
tag_name: ${{ github.ref_name }}
files: |
flipt-engine-ffi-${{ matrix.platform.name }}${{ startsWith(matrix.platform.name, 'Windows') && '.zip' || '.tar.gz' }}
- name: Upload Release Assets (Workflow Dispatch)
uses: softprops/action-gh-release@v2
if: github.event_name == 'workflow_dispatch' && !endswith(github.event.inputs.tag, 'pre')
with:
tag_name: flipt-engine-ffi-${{ github.event.inputs.tag }}
files: |
flipt-engine-ffi-${{ matrix.platform.name }}${{ startsWith(matrix.platform.name, 'Windows') && '.zip' || '.tar.gz' }}
notify:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
platform:
- name: Android
workflow: test-android-sdk.yml
- name: iOS
workflow: test-swift-sdk.yml
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.FLIPT_RELEASE_BOT_APP_ID }}
private_key: ${{ secrets.FLIPT_RELEASE_BOT_APP_PEM }}
installation_id: ${{ secrets.FLIPT_RELEASE_BOT_INSTALLATION_ID }}
- name: "Trigger Test ${{ matrix.platform.name }} SDK"
run: |
curl -X POST -H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/flipt-io/flipt-client-sdks/actions/workflows/${{ matrix.platform.workflow }}/dispatches \
-d '{"ref":"${{ github.head_ref }}", "inputs":{"caller_run_id":"${{ github.run_id }}"}}'