feat: setup dotnet CI #70
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
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
name: .NET | ||
env: | ||
OUTPUT_DIR: bin | ||
PACKAGES_DIR: packages | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
- os: windows-latest | ||
target: i686-pc-windows-msvc | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
# - os: ubuntu-latest | ||
# target: aarch64-unknown-linux-gnu | ||
# - os: ubuntu-latest | ||
# target: x86_64-alpine-linux-musl | ||
# - os: ubuntu-latest | ||
# target: aarch64-alpine-linux-musl | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install rustup | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
$ProgressPreference = "SilentlyContinue" | ||
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe | ||
.\rustup-init.exe -y --default-host=${{ matrix.target }} --default-toolchain stable --profile minimal | ||
del rustup-init.exe | ||
rustup target add ${{ matrix.target }} | ||
shell: powershell | ||
- name: Install rustup | ||
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
source $HOME/.cargo/env | ||
rustup target add ${{ matrix.target }} | ||
cargo install cbindgen | ||
shell: bash | ||
- name: Build | ||
if: matrix.os == 'windows-latest' | ||
run: ./windows/build-artifacts.ps1 ${{ env.OUTPUT_DIR }} ${{ matrix.target }} | ||
shell: pwsh | ||
- name: Build | ||
if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' | ||
run: ./windows/build-artifacts.sh ${{ env.OUTPUT_DIR }} ${{ matrix.target }} | ||
shell: bash | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.OUTPUT_DIR }}-${{ matrix.target }} | ||
path: | | ||
bin/* | ||
!bin/*/*/build | ||
!bin/*/*/deps | ||
!bin/*/*/examples | ||
!bin/*/*/incremental | ||
!bin/*/*/.fingerprint | ||
!bin/debug | ||
!bin/release | ||
pack: | ||
runs-on: windows-latest | ||
needs: build | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Download x86_64-pc-windows-msvc | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.OUTPUT_DIR }}-x86_64-pc-windows-msvc | ||
path: bin | ||
- name: Download i686-pc-windows-msvc | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.OUTPUT_DIR }}-i686-pc-windows-msvc | ||
path: bin | ||
- name: Download x86_64-apple-darwin | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.OUTPUT_DIR }}-x86_64-apple-darwin | ||
path: bin/x86_64-apple-darwin | ||
- name: Download aarch64-apple-darwin | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.OUTPUT_DIR }}-aarch64-apple-darwin | ||
path: bin/aarch64-apple-darwin | ||
- name: Download x86_64-unknown-linux-gnu | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.OUTPUT_DIR }}-x86_64-unknown-linux-gnu | ||
path: bin/x86_64-unknown-linux-gnu | ||
- name: dotnet pack | ||
run: | | ||
$cargo_content=Get-Content Cargo.toml -Raw | ||
$cargo_content -match '(?m)^version += +"([^"]+)"' | ||
$current_version=$Matches[1] | ||
$version_suffix="ci.${{ github.event.number }}.${{ github.run_number }}" | ||
$version="$current_version-$version_suffix" | ||
echo "NUGET_VERSION=$version" >> "$GITHUB_OUTPUT" | ||
dotnet pack windows/libdatadog.csproj -p:LibDatadogBinariesOutputDir=../${{ env.OUTPUT_DIR }} -p:LibDatadogVersion=$version -o ${{ env.PACKAGES_DIR }} | ||
- name: Upload package | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.PACKAGES_DIR }} | ||
path: ${{ env.PACKAGES_DIR }} | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
NUGET_VERSION: ${{ steps.pack.outputs.NUGET_VERSION }} | ||
Check failure on line 142 in .github/workflows/dotnet.yml GitHub Actions / .NETInvalid workflow file
|
||
strategy: | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
- os: windows-latest | ||
target: i686-pc-windows-msvc | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Download package | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ env.PACKAGES_DIR }} | ||
- name: Install .NET SDK | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 7.0 |