Skip to content

Update NuGet packages to latest versions in submodule #15

Update NuGet packages to latest versions in submodule

Update NuGet packages to latest versions in submodule #15

Workflow file for this run

name: Build .NET
on:
push:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.github/workflows/*.yml'
- '.version/*.json'
- '.gitignore'
- '*.png'
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: windows-latest
steps:
- name: Extract repo name
run: |
$repoName = "${{ github.repository }}".Split('/')[1]
echo "REPO_NAME=$repoName" | Out-File -FilePath $env:GITHUB_ENV -Append
shell: pwsh
- uses: actions/checkout@v3
with:
submodules: 'recursive'
token: ${{ secrets.BUILD_TOKEN }}
- name: Install .NET SDK
run: |
$url = "https://download.visualstudio.microsoft.com/download/pr/2b2d6133-c4f9-46dd-9ab6-86443a7f5783/340054e2ac7de2bff9eea73ec9d4995a/dotnet-sdk-${{ secrets.DOTNET_VERSION }}-win-x64.zip"
$output = "dotnet-sdk-${{ secrets.DOTNET_VERSION }}-win-x64.zip"
Invoke-WebRequest -Uri $url -OutFile $output
Expand-Archive $output -DestinationPath $Env:ProgramFiles\dotnet -Force
$env:PATH = "$Env:ProgramFiles\dotnet;" + $env:PATH
[Environment]::SetEnvironmentVariable("PATH", $env:PATH, [EnvironmentVariableTarget]::Machine)
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ secrets.DOTNET_VERSION }}
- name: Add GitHub Packages source
run: |
nuget sources Add -Name "GitHub" -Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" -Username ${{ github.repository_owner }} -Password ${{ secrets.BUILD_TOKEN }}
- name: Restore NuGet packages
run: dotnet restore $env:GITHUB_ENV.sln /p:ServerBuild=true
env:
NUGET_AUTH_TOKEN: ${{ secrets.BUILD_TOKEN }}
- name: Build with version
run: dotnet build $env:GITHUB_ENV.sln /p:BuildNumber=${{ github.run_number }} /p:ServerBuild=true
env:
UsePackageReferences: true
- name: Print Run Number
run: echo "Run number $env:GITHUB_RUN_NUMBER"
shell: pwsh
- name: Check Latest Release
id: latest_release
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/releases/latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Compare with version.json and Write to Script
run: |
$versionFile = ".version/version.json"
$versionJson = Get-Content $versionFile | ConvertFrom-Json
$latestReleaseTag = ""
try {
$latestReleaseResponse = Invoke-RestMethod -Uri "https://api.github.com/repos/${{ github.repository }}/releases/latest" -Headers @{Authorization = "Bearer ${{ secrets.BUILD_TOKEN }}"}
$latestReleaseTag = $latestReleaseResponse.tag_name
} catch {
echo "No latest release found"
}
if ($latestReleaseTag -ne $versionJson.version) {
"`$release_needed='true'" | Out-File -FilePath release-info.ps1 -Encoding UTF8
"`$version='$($versionJson.version)'" | Add-Content -Path release-info.ps1
} else {
"`$release_needed='false'" | Out-File -FilePath release-info.ps1 -Encoding UTF8
}
shell: pwsh
- name: Create Release
run: |
. .\release-info.ps1
if ($release_needed -eq 'true') {
$tag_name = $version
$release_name = "Release $tag_name"
$release_notes = "Release $tag_name"
$uri = "https://api.github.com/repos/${{ github.repository }}/releases"
$headers = @{
Authorization = "Bearer ${{ secrets.BUILD_TOKEN }}"
Accept = "application/vnd.github.v3+json"
}
$body = @{
tag_name = $tag_name
name = $release_name
body = $release_notes
}
echo "uri: $uri"
Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body ($body | ConvertTo-Json)
}
shell: pwsh
env:
DOTNET_ROOT: C:\Users\runneradmin\AppData\Local\Microsoft\dotnet