Matrix Build and publish Ziti Native to nuget #154
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Matrix Build and publish Ziti Native to nuget | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: Version of CSDK/Nuget Package | ||
default: _CHANGE_ | ||
required: true | ||
env: | ||
ZITI_SDK_C_BRANCH: ${{ github.event.inputs.version }} | ||
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 }} | ||
qualifier: ${{ steps.buildinfo.outputs.qualifier }} | ||
branch: ${{ steps.buildinfo.outputs.qualifier }} | ||
buildnum: ${{ steps.buildinfo.outputs.buildnum }} | ||
steps: | ||
- name: Set now, repo, qualifier, 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=$(echo $GITHUB_REF | sed 's/refs\/heads\///')" >> $GITHUB_OUTPUT | ||
echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///')" >> $GITHUB_ENV | ||
if [ "${BRANCH_NAME}" = "main" ]; then | ||
echo "qualifier=" >> $GITHUB_OUTPUT | ||
else | ||
echo "qualifier=-rc" >> $GITHUB_OUTPUT | ||
fi | ||
echo "buildnum=.${{github.run_number}}" >> $GITHUB_OUTPUT | ||
native-matrix-build: | ||
needs: set-build-info | ||
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: 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.dist == 'macos' | ||
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.dist == 'macos' | ||
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 Release | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.dist }}.${{ matrix.arch }}.${{ matrix.prefix }}ziti4dotnet.${{ matrix.ext }} | ||
path: ${{ env.TARGETDIR }}/library/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}} | ||
qualifier: ${{needs.set-build-info.outputs.qualifier}} | ||
branch: ${{needs.set-build-info.outputs.branch}} | ||
buildnum: ${{needs.set-build-info.outputs.buildnum}} | ||
resolvedversion: "OpenZiti.NET.native.${{ env.ZITI_SDK_C_BRANCH }}${repo}${qualifier}${buildnum}" | ||
Check failure on line 153 in .github/workflows/native-nuget-publish.yml GitHub Actions / Matrix Build and publish Ziti Native to nugetInvalid workflow file
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- 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/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/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 ${resolvedversion} ${{ github.workspace }}/native-package.nuspec | ||
- name: upload nuget package | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
path: ${{ github.workspace }}/OpenZiti.NET.native.${resolvedversion}.nupkg | ||
name: OpenZiti.NET.native.${resolvedversion}.nupkg | ||
if-no-files-found: error | ||
- name: Upload OpenZiti.NET.native to job | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: OpenZiti.NET.native.${resolvedversion}.nupkg | ||
path: OpenZiti.NET.native.${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.${resolvedversion}.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json |