-
Notifications
You must be signed in to change notification settings - Fork 5
220 lines (206 loc) · 8.76 KB
/
native-nuget-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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Matrix Build and publish Ziti Native to nuget
on:
workflow_dispatch:
inputs:
version:
description: Version of CSDK/Nuget Package
default: _CHANGE_
required: true
debugOrRelease:
description: Debug or Release
default: Release
required: true
env:
ZITI_SDK_C_BRANCH: ${{ github.event.inputs.version }}
ZITI_DEBUG_OR_RELEASE: ${{ github.event.inputs.debugOrRelease }}
NUGET_SOURCE: https://api.nuget.org/v3/index.json
BUILD_NUMBER: ${{ github.run_number }}
BASEDIR: ${{ github.workspace }}/ZitiNativeApiForDotnetCore
TARGETDIR: ${{ github.workspace }}/ZitiNativeApiForDotnetCore/build
jobs:
set-build-info:
runs-on: ubuntu-latest
outputs:
now: ${{ steps.buildinfo.outputs.now }}
repo: ${{ steps.buildinfo.outputs.repo }}
branch: ${{ steps.buildinfo.outputs.branch }}
qualifier: ${{ steps.qualifierinfo.outputs.qualifier }}
steps:
- name: Set now, repo, branch, build num
id: buildinfo
run: |
echo "now=$(date '+%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
if [ "${{ github.repository }}" == 'openziti/ziti-sdk-csharp' ]; then
echo "repo=" >> $GITHUB_OUTPUT
else
echo "repo=${{github.repository_owner}}" >> $GITHUB_OUTPUT
fi
echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///')" >> $GITHUB_ENV
echo "branch=$(echo $GITHUB_REF | sed 's/refs\/heads\///')" >> $GITHUB_OUTPUT
- name: Set qualifier
id: qualifierinfo
run: |
if [ "${BRANCH_NAME}" = "main" ]; then
echo "qualifier=.${{github.run_number}}" >> $GITHUB_OUTPUT
else
echo "qualifier=-${BRANCH_NAME}rc${{github.run_number}}" >> $GITHUB_OUTPUT
fi
native-matrix-build:
if: "!contains(github.event.head_commit.message, 'ci skip') && ${{ github.actor != 'dependabot[bot]' }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- ext: so
prefix: lib
dist: linux
os: ubuntu-20.04
arch: x64
preset: linux-x64
- ext: so
prefix: lib
dist: 'Linux-arm'
os: ubuntu-20.04
arch: arm
preset: linux-arm
- ext: so
prefix: lib
dist: 'Linux-arm64'
os: ubuntu-20.04
arch: arm64
preset: linux-arm64
- ext: dylib
prefix: lib
dist: macos
os: macOS-13
arch: x64
preset: macOS-x64
- ext: dylib
prefix: lib
dist: macos
os: macOS-13
arch: arm64
preset: macOS-arm64
- ext: dylib
prefix: lib
dist: iOS
os: macOS-13
arch: arm64
preset: ios-arm64
- ext: dll
dist: win
os: windows-2022
arch: x64
preset: win64
- ext: dll
dist: win
arch: x86
cmake_arch_flag: '-A Win32'
os: windows-2022
preset: win32
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Linux pkg-config
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt update -y
sudo apt install -y pkg-config ninja-build
- name: Install Crossbuild tools
if: matrix.os == 'ubuntu-20.04' && contains(matrix.arch, 'arm')
run: |
sudo apt update -y
sudo apt install -y crossbuild-essential-armhf crossbuild-essential-arm64
- name: Install MacOS Ninja
if: matrix.os == 'macOS-13'
run: |
brew install ninja
- name: Set up MSVC 2019
if: matrix.dist == 'win'
uses: microsoft/setup-msbuild@v1.1
- name: Restore vcpkg packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: vcpkg integrate install
- name: Set VCPKG_ROOT
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'macOS-13'
run: echo "VCPKG_ROOT=/usr/local/share/vcpkg" >> $GITHUB_ENV
- name: Set VCPKG_ROOT
if: matrix.dist == 'win'
run: echo "VCPKG_ROOT=C:/vcpkg" >> $env:GITHUB_ENV
- name: configure / build CMake
working-directory: ${{ github.workspace }}/ZitiNativeApiForDotnetCore
run: |
echo "VCPKG_ROOT = ${{ env.VCPKG_ROOT }}"
cmake -E make_directory ${{ env.TARGETDIR }}
cmake -S ${{ env.BASEDIR }} -B ${{ env.TARGETDIR }} --preset ${{ matrix.preset }} ${{ matrix.cmake_arch_flag }}
cmake --build ${{ env.TARGETDIR }} --config ${{ env.ZITI_DEBUG_OR_RELEASE }}
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.dist }}.${{ matrix.arch }}.${{ matrix.prefix }}ziti4dotnet.${{ matrix.ext }}
path: ${{ env.TARGETDIR }}/library/${{ env.ZITI_DEBUG_OR_RELEASE }}/${{ matrix.prefix }}ziti4dotnet.${{ matrix.ext }}
if-no-files-found: error
create-nuget-package:
needs: [set-build-info, native-matrix-build]
env:
now: ${{needs.set-build-info.outputs.now}}
repo: ${{needs.set-build-info.outputs.repo}}
branch: ${{needs.set-build-info.outputs.branch}}
qualifier: ${{needs.set-build-info.outputs.qualifier}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set resolves version to env
run: |
echo "resolvedversion=${{ env.ZITI_SDK_C_BRANCH }}${repo}${qualifier}" >> $GITHUB_ENV
- run: mkdir ${{github.workspace}}/native
- name: download all artifacts
uses: actions/download-artifact@v3
with:
path: ${{github.workspace}}/native
- name: move files to expected locations
run: |
echo "locating all the built libraries:"
find . -name "*ziti4dotnet.*"
echo "creating the RIDs"
mkdir -p ${{github.workspace}}/runtimes/osx-x64/native
mkdir -p ${{github.workspace}}/runtimes/osx-arm64/native
mkdir -p ${{github.workspace}}/runtimes/ios-arm64/native
mkdir -p ${{github.workspace}}/runtimes/linux-arm/native
mkdir -p ${{github.workspace}}/runtimes/linux-arm64/native
mkdir -p ${{github.workspace}}/runtimes/linux-x64/native
mkdir -p ${{github.workspace}}/runtimes/win-x86/native
mkdir -p ${{github.workspace}}/runtimes/win-x64/native
echo "moving the build libraries to the RIDs"
mv ${{github.workspace}}/native/macos.x64.libziti4dotnet.dylib/libziti4dotnet.dylib ${{github.workspace}}/runtimes/osx-x64/native
mv ${{github.workspace}}/native/macos.arm64.libziti4dotnet.dylib/libziti4dotnet.dylib ${{github.workspace}}/runtimes/osx-arm64/native
mv ${{github.workspace}}/native/iOS.arm64.libziti4dotnet.dylib/libziti4dotnet.dylib ${{github.workspace}}/runtimes/ios-arm64/native
mv ${{github.workspace}}/native/Linux-arm64.arm64.libziti4dotnet.so/libziti4dotnet.so ${{github.workspace}}/runtimes/linux-arm64/native
mv ${{github.workspace}}/native/Linux-arm.arm.libziti4dotnet.so/libziti4dotnet.so ${{github.workspace}}/runtimes/linux-arm/native
mv ${{github.workspace}}/native/linux.x64.libziti4dotnet.so/libziti4dotnet.so ${{github.workspace}}/runtimes/linux-x64/native
mv ${{github.workspace}}/native/win.x64.ziti4dotnet.dll/ziti4dotnet.dll ${{github.workspace}}/runtimes/win-x64/native
mv ${{github.workspace}}/native/win.x86.ziti4dotnet.dll/ziti4dotnet.dll ${{github.workspace}}/runtimes/win-x86/native
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.x
- name: Create the Nuget package
run: nuget pack -version ${{env.resolvedversion}} ${{ github.workspace }}/native-package.nuspec
- name: upload nuget package
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/OpenZiti.NET.native.${{env.resolvedversion}}.nupkg
name: OpenZiti.NET.native.${{env.resolvedversion}}.nupkg
if-no-files-found: error
- name: Upload OpenZiti.NET.native to job
uses: actions/upload-artifact@v3
with:
name: OpenZiti.NET.native.${{env.resolvedversion}}.nupkg
path: OpenZiti.NET.native.${{env.resolvedversion}}.nupkg
if-no-files-found: error
- name: Publish OpenZiti.NET.native
if: "${{ github.repository == 'openziti/ziti-sdk-csharp'}}"
run: dotnet nuget push OpenZiti.NET.native.${{env.resolvedversion}}.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json