-
-
Notifications
You must be signed in to change notification settings - Fork 63
66 lines (62 loc) · 2.34 KB
/
Copy pathdotnet-release.yml
File metadata and controls
66 lines (62 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Dotnet Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
env:
BUILD_CONFIGURATION: Release
SDK_VERSION: 10.0.201
OUTPUT_DIR: bin\AnyCPU\Release\net10.0-windows10.0.22000.0\win-x64
steps:
- name: Checkout repository
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git init
git remote add origin "https://x-access-token:${env:GITHUB_TOKEN}@github.com/${env:GITHUB_REPOSITORY}.git"
git fetch --depth=1 origin "${env:GITHUB_SHA}"
git checkout --force FETCH_HEAD
- name: Install .NET SDK
shell: pwsh
run: |
$installScript = Join-Path $env:RUNNER_TEMP "dotnet-install.ps1"
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile $installScript
& $installScript -Version "${env:SDK_VERSION}" -InstallDir "$env:RUNNER_TEMP\dotnet"
Add-Content -Path $env:GITHUB_PATH -Value "$env:RUNNER_TEMP\dotnet"
- name: Restore
run: dotnet restore SystemTrayMenu.csproj
- name: Build
run: dotnet build SystemTrayMenu.csproj -c ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: Create release archive
shell: pwsh
run: |
$archiveName = "SystemTrayMenu-${env:GITHUB_REF_NAME}-win-x64.zip"
$archivePath = Join-Path $env:RUNNER_TEMP $archiveName
if (Test-Path $archivePath)
{
Remove-Item $archivePath -Force
}
Compress-Archive -Path "${env:OUTPUT_DIR}\*" -DestinationPath $archivePath
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_ASSET_PATH=$archivePath"
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_ASSET_NAME=$archiveName"
- name: Publish GitHub Release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release view "${env:GITHUB_REF_NAME}" --repo "${env:GITHUB_REPOSITORY}" *> $null
if ($LASTEXITCODE -eq 0)
{
gh release upload "${env:GITHUB_REF_NAME}" "${env:RELEASE_ASSET_PATH}#${env:RELEASE_ASSET_NAME}" --repo "${env:GITHUB_REPOSITORY}" --clobber
}
else
{
gh release create "${env:GITHUB_REF_NAME}" "${env:RELEASE_ASSET_PATH}#${env:RELEASE_ASSET_NAME}" --repo "${env:GITHUB_REPOSITORY}" --generate-notes
}