Skip to content

Bump actions/download-artifact from 4 to 5 (#395) #42

Bump actions/download-artifact from 4 to 5 (#395)

Bump actions/download-artifact from 4 to 5 (#395) #42

Workflow file for this run

name: Build
on:
push:
branches:
- main
tags:
- '*'
paths-ignore:
- README.md
pull_request:
branches:
- main
paths-ignore:
- README.md
env:
# When we create a tag, we set the NuGet version to the tag number, the below values are only for PR builds.
CurrentSemanticVersionBase: '99.0.0' # Only used for PR builds
NugetPackageVersion: '99.0.0-preview${{ github.run_number }}' # Only used for PR builds
NET_VERSION: '9.0.x'
RunPoliCheck: false
PathToLibrarySolution: 'src/CommunityToolkit.Maui.Markup.sln'
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Markup.Sample.sln'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui.Markup/CommunityToolkit.Maui.Markup.csproj'
PathToCommunityToolkitSampleCsproj: 'samples/CommunityToolkit.Maui.Markup.Sample/CommunityToolkit.Maui.Markup.Sample.csproj'
PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit.Maui.Markup.UnitTests/CommunityToolkit.Maui.Markup.UnitTests.csproj'
PathToCommunityToolkitSourceGeneratorsCsproj: 'src/CommunityToolkit.Maui.Markup.SourceGenerators/CommunityToolkit.Maui.Markup.SourceGenerators.csproj'
Xcode_Version: '16.3'
ShouldCheckDependencies: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build_sample:
name: Build Sample App using Latest .NET SDK
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-15]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set Latest Xcode Version
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Install Latest .NET SDK, v${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.NET_VERSION }}
dotnet-quality: 'ga'
- uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '17'
- name: Install .NET MAUI Workload
run: |
dotnet workload install maui
dotnet workload update
- name: Install Tizen Workload
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
shell: pwsh
- name: Display dotnet info
run: dotnet --info
- name: Build CommunityToolkit.Maui.Markup.Sample
run: dotnet build -c Release ${{ env.PathToCommunityToolkitSampleCsproj }}
build_library:
name: Build Library
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-15]
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set NuGet Version to Tag Number
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "Setting NuGet version from tag: ${GITHUB_REF#refs/tags/}"
echo "NugetPackageVersion=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
shell: bash
- name: Set NuGet Version to PR Version
if: ${{ github.event_name == 'pull_request' }}
run: echo "NugetPackageVersion=${{ env.CurrentSemanticVersionBase }}-build-${{ github.event.pull_request.number }}.${{ github.run_number }}+${{ github.sha }}" >> $GITHUB_ENV
shell: bash
- name: Set Xcode Version
if: runner.os == 'macOS'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.Xcode_Version }}
- name: Install .NET SDK v${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.NET_VERSION }}
dotnet-quality: 'ga'
- uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '17'
- name: Install .NET MAUI Workload
run: |
dotnet workload install maui
dotnet workload update
- name: Install Tizen Workload
run: |
Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1'
.\workload-install.ps1
shell: pwsh
- name: Display dotnet info
run: dotnet --info
- name: 'Build CommunityToolkit.Maui.Markup.SourceGenerators'
run: dotnet build ${{ env.PathToCommunityToolkitSourceGeneratorsCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.Markup'
run: dotnet build ${{ env.PathToCommunityToolkitCsproj }} -c Release
- name: 'Build CommunityToolkit.Maui.Markup.UnitTests'
run: dotnet build ${{ env.PathToCommunityToolkitUnitTestCsproj }} -c Release
- name: Run Unit Tests
run: dotnet run -c Release --project ${{ env.PathToCommunityToolkitUnitTestCsproj }} --results-directory "${{ runner.temp }}" --coverage --coverage-output "${{ runner.temp }}/coverage.cobertura.xml" --coverage-output-format cobertura
- name: Publish Code Coverage Results
if: ${{ runner.os == 'Windows' && (success() || failure()) }}
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:'${{ runner.temp }}\*cobertura.xml' -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub'
cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
shell: bash
- name: Build and Pack CommunityToolkit.Maui.Markup
run: dotnet pack -c Release ${{ env.PathToCommunityToolkitCsproj }} -p:PackageVersion=${{ env.NugetPackageVersion }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
- name: 'Check Dependencies'
if: ${{ runner.os == 'Windows' && (success() || failure()) }}
run: |
cd src
dotnet list package --include-transitive # Print all transitive packages
dotnet list package --vulnerable --include-transitive | findstr /S /c:"has the following vulnerable packages"; # Print all transitive packages with vulnerabilities
if ($LastExitCode -ne 1)
{
dotnet list package --vulnerable --include-transitive;
exit 1;
}
exit 0;
shell: pwsh
- name: Copy NuGet Packages to Staging Directory
if: ${{ runner.os == 'Windows' }} && !startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p ${{ github.workspace }}/nuget
Get-ChildItem -Path "./src" -Recurse | Where-Object { $_.Extension -match "nupkg" } | Copy-Item -Destination "${{ github.workspace }}/nuget"
shell: pwsh
- name: Upload Package List
uses: actions/upload-artifact@v4
if: ${{ runner.os == 'Windows' }}
with:
name: nuget-list
if-no-files-found: error
path: |
${{ github.workspace }}/.github/workflows/SignClientFileList.txt
- name: Publish Packages
if: ${{ runner.os == 'Windows' }}
uses: actions/upload-artifact@v4
with:
name: packages
path: ${{ github.workspace }}/nuget/
sign:
needs: [build_library]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: windows-latest
permissions:
id-token: write # Required for requesting the JWT
steps:
- name: Install .NET SDK v${{ env.NET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.NET_VERSION }}
dotnet-quality: 'ga'
- name: Download NuGet List
uses: actions/download-artifact@v5
with:
name: nuget-list
path: ./
- name: Download Package List
uses: actions/download-artifact@v5
with:
name: packages
path: ./packages
- name: Install Signing Tool
run: dotnet tool install --tool-path ./tools sign --version 0.9.1-beta.23356.1
- name: Sign Packages
run: >
./tools/sign code azure-key-vault
**/*.nupkg
--base-directory "${{ github.workspace }}/packages"
--file-list "${{ github.workspace }}/SignClientFileList.txt"
--timestamp-url "http://timestamp.digicert.com"
--publisher-name ".NET Foundation"
--description "Community Toolkit MAUI"
--description-url "https://github.com/CommunityToolkit/Maui"
--azure-key-vault-url "${{ secrets.SIGN_KEY_VAULT_URL }}"
--azure-key-vault-client-id ${{ secrets.SIGN_CLIENT_ID }}
--azure-key-vault-client-secret "${{ secrets.SIGN_CLIENT_SECRET }}"
--azure-key-vault-tenant-id ${{ secrets.SIGN_TENANT_ID }}
--azure-key-vault-certificate "${{ secrets.SIGN_CERTIFICATE }}"
--verbosity Information
- name: Publish Packages
uses: actions/upload-artifact@v4
with:
name: signed-packages
if-no-files-found: error
path: |
${{ github.workspace }}/packages/**/*.nupkg
release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: [sign]
environment: nuget-release-gate # This gates this job until manually approved
runs-on: ubuntu-latest
steps:
- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.NET_VERSION }}
dotnet-quality: 'ga'
- name: Download signed packages for ${{ matrix.platform }}
uses: actions/download-artifact@v5
with:
name: signed-packages
path: ./packages
- name: Push to NuGet.org
run: >
dotnet nuget push
**/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_PACKAGE_PUSH_TOKEN }}
--skip-duplicate