Zxing.Net.Maui: build & publish Zxing.Net package #343
Workflow file for this run
This file contains hidden or 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/setup-dotnet@v1.7.2 | |
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: | | |
sed -i 's/_IncludeAndroid>true/_IncludeAndroid>/g' Directory.Build.Override.props | |
dotnet build Microsoft.Maui.BuildTasks.slnf | |
dotnet build -c Release Mali.slnf | |
- name: Pack MAUI | |
run: dotnet pack Mali.slnf | |
- name: Build Mali.ZXing | |
run: | | |
cd src/ZXing.Net.Maui | |
dotnet build -c Release --framework=net8.0-gtk ZXing.Net.MAUI/ZXing.Net.MAUI.csproj | |
dotnet build -c Release --framework=net8.0-gtk ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj | |
- name: Pack Mali.ZXing | |
run: | | |
dotnet pack src/ZXing.Net.Maui/ZXing.Net.MAUI/ZXing.Net.MAUI.csproj --no-build --no-restore | |
dotnet pack src/ZXing.Net.Maui/ZXing.Net.MAUI.Controls/ZXing.Net.MAUI.Controls.csproj --no-build --no-restore | |
- name: Check package versions | |
run: | | |
version_prefix=$(cat GitInfo.txt | tr -d '\n' | cut -d'-' -f1) | |
# fail if at least one of *.nupkg files' names' version portion doesn't start with version string stored in GitInfo.txt | |
# ( and ) have to be escaped when used in find command regex | |
count=$(find . -type f -name "*.nupkg" ! -regex "\(.*\/\)*\([a-zA-Z]+\.\)+${version_prefix}.*" | wc -l) | |
if [ "$count" -gt 0 ]; then | |
echo "Packages have versions that are inconsistent with version stored in GitInfo.txt. Aborting." | |
exit 1 | |
fi | |
- 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 | |