Skip to content

Commit

Permalink
Merge pull request #36 from egvijayanand/working
Browse files Browse the repository at this point in the history
MauiToolkit build automation
  • Loading branch information
egvijayanand authored Jun 18, 2022
2 parents 075be42 + 98d3500 commit 3f75d36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/build-maui-toolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

# Allows you to run this workflow manually from the Actions tab
env:
DOTNET_VERSION: '6.0.300'
DOTNET_VERSION: '6.0.x'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -31,17 +31,17 @@ jobs:
uses: actions/setup-dotnet@v2
with:
# Optional SDK version to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-version: ${{ secrets.DOTNET_VERSION }}
# Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.
include-prerelease: false

# Install Maui workload
- name: Install Maui workload
run: dotnet workload install maui --from-rollback-file https://aka.ms/dotnet/maui/6.0.300.json --source https://aka.ms/dotnet6/nuget/index.json --source https://api.nuget.org/v3/index.json
run: dotnet workload install maui --from-rollback-file https://aka.ms/dotnet/maui/${{ secrets.DOTNET_VERSION }}.json --source https://aka.ms/dotnet6/nuget/index.json --source https://api.nuget.org/v3/index.json

# Install WebAssembly workload
- name: Install WebAssembly workload
run: dotnet workload install wasm-tools --from-rollback-file https://aka.ms/dotnet/maui/6.0.300.json --source https://aka.ms/dotnet6/nuget/index.json --source https://api.nuget.org/v3/index.json
run: dotnet workload install wasm-tools --from-rollback-file https://aka.ms/dotnet/maui/${{ secrets.DOTNET_VERSION }}.json --source https://aka.ms/dotnet6/nuget/index.json --source https://api.nuget.org/v3/index.json

# List installed workload
- name: List installed workloads
Expand All @@ -53,5 +53,16 @@ jobs:

# Build the project in Release mode
- name: Build the Solution in Release mode
shell: cmd
run: .\Create-Package.bat Release
run: .\Create-Package.bat ${{ secrets.BUILD_CONFIG }} ${{ secrets.MAUI_TOOLKIT_PKG_VERSION }}

- name: Archive VijayAnand.MauiToolkit.Core NuGet package
uses: actions/upload-artifact@v3
with:
name: archive-core-nuget-package
path: src/VijayAnand.MauiToolkit/VijayAnand.MauiToolkit.Core/bin/${{ secrets.BUILD_CONFIG }}/VijayAnand.MauiToolkit.Core.${{ secrets.MAUI_TOOLKIT_PKG_VERSION }}.nupkg

- name: Archive VijayAnand.MauiToolkit NuGet package
uses: actions/upload-artifact@v3
with:
name: archive-toolkit-nuget-package
path: src/VijayAnand.MauiToolkit/VijayAnand.MauiToolkit/bin/${{ secrets.BUILD_CONFIG }}/VijayAnand.MauiToolkit.${{ secrets.MAUI_TOOLKIT_PKG_VERSION }}.nupkg
31 changes: 17 additions & 14 deletions src/VijayAnand.MauiToolkit/Create-Package.bat
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
:: Creates a new NuGet package from the project file
@echo off

if [%1]==[] (call Error "Build configuration input is not provided." & goto end)
if [%1]==[] (echo Build configuration input is not provided. & goto end)

set config=%1

if not [%2]==[] (set pkgVersion=%2)

:: Package Name

if not exist CorePackageName.txt (call Error "Core package name file not available." & goto end)
if not exist CorePackageName.txt (echo Core package name file not available. & goto end)

set /P corePkgName=<CorePackageName.txt

if [%corePkgName%]==[] (call Error "Core package name not configured." & goto end)
if [%corePkgName%]==[] (echo Core package name not configured. & goto end)

if not exist ToolkitPackageName.txt (call Error "Toolkit package name file not available." & goto end)
if not exist ToolkitPackageName.txt (echo Toolkit package name file not available. & goto end)

set /P toolkitPkgName=<ToolkitPackageName.txt

if [%toolkitPkgName%]==[] (call Error "Toolkit package name not configured." & goto end)
if [%toolkitPkgName%]==[] (echo Toolkit package name not configured. & goto end)

:: Package Version

if not exist PackageVersion.txt (call Error "Version file not available." & goto end)
if not exist PackageVersion.txt (echo Version file not available. & goto end)

set /P pkgVersion=<PackageVersion.txt
:: If value of pkgVersion is still blank, attempt to read from the PackageVersion file
if [%pkgVersion%]==[] (set /P pkgVersion=<PackageVersion.txt)

if [%pkgVersion%]==[] (call Error "Version # not configured." & goto end)
if [%pkgVersion%]==[] (echo Version # not configured. & goto end)

:: .NET SDK Version

dotnet --version

:: Package Configuration

call Info "Core Package: %corePkgName% ver. %pkgVersion%"
call Info "Toolkit Package: %toolkitPkgName% ver. %pkgVersion%"
echo Core Package: %corePkgName% ver. %pkgVersion%
echo Toolkit Package: %toolkitPkgName% ver. %pkgVersion%

call Info "Delete existing package ..."
echo Delete existing package ...

if exist .\VijayAnand.MauiToolkit.Core\bin\%config%\%corePkgName%.%pkgVersion%.nupkg del .\VijayAnand.MauiToolkit.Core\bin\%config%\%corePkgName%.%pkgVersion%.nupkg

if exist .\VijayAnand.MauiToolkit\bin\%config%\%toolkitPkgName%.%pkgVersion%.nupkg del .\VijayAnand.MauiToolkit\bin\%config%\%toolkitPkgName%.%pkgVersion%.nupkg

call Info "Creating NuGet package ..."
echo Creating NuGet package ...

dotnet build .\VijayAnand.MauiToolkit.Core\VijayAnand.MauiToolkit.Core.csproj -c %config% -p:PackageVersion=%pkgVersion% -p:ContinuousIntegrationBuild=true

if not %errorlevel% == 0 (call Error "Core package creation failed." & goto end)
if not %errorlevel% == 0 (echo Core package creation failed. & goto end)

echo.
:: Adding NuGet reference
Expand All @@ -55,6 +58,6 @@ echo.
dotnet build .\VijayAnand.MauiToolkit\VijayAnand.MauiToolkit.csproj -c %config% -p:PackageVersion=%pkgVersion% -p:ContinuousIntegrationBuild=true

echo.
if %errorlevel% == 0 (call Success "Process completed.") else (call Error "Toolkit package creation failed.")
if %errorlevel% == 0 (echo Process completed.) else (echo Toolkit package creation failed.)

:end

0 comments on commit 3f75d36

Please sign in to comment.