Build nuget packages in CI and push to nuget.org #316
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: Build Controls.Sample.Gtk | |
on: [push, pull_request] | |
jobs: | |
build_and_test: | |
name: Build & Test | |
runs-on: ubuntu-22.04 | |
env: | |
GtkSharpVersion: 3.24.24.117-develop | |
GtkSharpManifestVersion: 8.0.200 | |
DotnetVersion: 8.0.200 | |
steps: | |
- name: Checkout MAUI repo | |
uses: actions/checkout@v2 | |
- name: Setup .NET SDK ${{ env.DotnetVersion }} | |
uses: actions/[email protected] | |
with: | |
dotnet-version: ${{ env.DotnetVersion }} | |
- name: Install gtk workload | |
run: | | |
# For some reason automatic workload manifest detection doesn't work (see https://github.com/GtkSharp/GtkSharp/issues/355#issuecomment-1446262239), so download and uzip mainfest file manually | |
dotnet nuget add source --name nuget.org "https://api.nuget.org/v3/index.json" | |
wget https://www.nuget.org/api/v2/package/gtksharp.net.sdk.gtk.manifest-${{ env.GtkSharpManifestVersion }}/$GtkSharpVersion -O gtksharp.net.sdk.gtk.manifest-${{ env.GtkSharpManifestVersion }}.nupkg | |
DOTNET_DIR=/home/runner/.dotnet | |
WORKLOAD_MANIFEST_DIR=$DOTNET_DIR/sdk-manifests/${{ env.DotnetVersion }}/gtksharp.net.sdk.gtk | |
mkdir -p $WORKLOAD_MANIFEST_DIR | |
unzip -j gtksharp.net.sdk.gtk.manifest-${{ env.GtkSharpManifestVersion }}.nupkg "data/*" -d $WORKLOAD_MANIFEST_DIR/ | |
rm gtksharp.net.sdk.gtk.manifest-${{ env.GtkSharpManifestVersion }}.nupkg | |
chmod 764 $WORKLOAD_MANIFEST_DIR/* | |
dotnet workload search | |
dotnet workload install gtk --skip-manifest-update | |
- name: Generate pre-release version suffix | |
run: dotnet fsi nugetPreRelease.fsx "" > PreReleaseVersionSuffix.txt | |
- name: Build MAUI | |
run: | | |
mv Directory.Build.Override.props.in Directory.Build.Override.props | |
dotnet build Microsoft.Maui.BuildTasks.slnf | |
dotnet build -c Release Mali.slnf | |
- name: Pack MAUI | |
run: dotnet pack Mali.slnf --no-build --no-restore | |
- name: Upload binaries to nuget (if tag or main branch, and nugetKey is present) | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NUGET_KEY: ${{ secrets.NUGET_KEY }} | |
if: ${{ env.NUGET_KEY != '' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} | |
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
dotnet-format: | |
needs: build_and_test | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Run dotnet format | |
run: | | |
# remark: doesnt work, alwasy fails: | |
# dotnet format whitespace ./src --folder --exclude Templates/src --exclude ZXing.Net.Maui | |
git diff --exit-code | |