ci: setup building nuget packages in CI #28
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: | |
name: .NET | |
jobs: | |
windows-build: | |
runs-on: windows-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Install rustup using win.rustup.rs | |
run: | | |
# disable download progress bar | |
$ProgressPreference = "SilentlyContinue" | |
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe | |
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc --default-toolchain=none | |
del rustup-init.exe | |
rustup target add x86_64-pc-windows-msvc | |
rustup target add i686-pc-windows-msvc | |
shell: powershell | |
- name: build | |
run: | | |
.\windows\build\build.ps1 -output_dir .\bin | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-bin | |
path: bin/* | |
macos-build: | |
runs-on: macos-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Install rustup using rustup.rs | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup target add x86_64-apple-darwin | |
rustup target add aarch64-apple-darwin | |
shell: bash | |
- name: build | |
run: | | |
chmod +x ./windows/build/build.sh | |
./windows/build/build.sh -o ./bin | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macos-bin | |
path: bin/* | |
linux-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Install rustup using rustup.rs | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup target add x86_64-unknown-linux-gnu | |
rustup target add aarch64-unknown-linux-gnu | |
shell: bash | |
- name: build | |
run: | | |
chmod +x ./windows/build/build.sh | |
./windows/build/build.sh -o ./bin -t x86_64-unknown-linux-gnu -t aarch64-unknown-linux-gnu | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-bin | |
linux-musl-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Install rustup using rustup.rs | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup target add x86_64-unknown-linux-musl | |
rustup target add aarch64-unknown-linux-musl | |
shell: bash | |
- name: Install musl | |
run: sudo apt-get install -y --no-install-recommends musl-tools | |
- name: build | |
run: | | |
chmod +x ./windows/build/build.sh | |
./windows/build/build.sh -o ./bin -t x86_64-unknown-linux-musl -t aarch64-unknown-linux-musl | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-musl-bin | |
pack: | |
runs-on: windows-latest | |
needs: [windows-build, macos-build, linux-build, linux-musl-build] | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Download Windows artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-bin | |
path: bin | |
- name: Download mac artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: macos-bin | |
path: bin | |
- name: Download linux artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: linux-bin | |
path: bin | |
- name: pack | |
run: | | |
$sha = "${{ github.sha }}".SubString(0, 8) | |
dotnet pack .\windows\libdatadog.csproj -p:LibDatadogBinariesOutputDir=..\bin -p:LibDatadogVersion="42.0.0+${sha}" -o .nuget\packages\ | |
- name: store artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: .nuget/packages/* | |
if-no-files-found: error |