Skip to content

Commit 382b6eb

Browse files
committed
ci: update build config
1 parent 96f2530 commit 382b6eb

File tree

2 files changed

+48
-38
lines changed

2 files changed

+48
-38
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,37 @@
1-
name: .NET
1+
name: Build
22

33
on:
44
pull_request:
55
branches: [ master ]
66
workflow_dispatch:
7+
push:
78

89
jobs:
910
build:
1011
runs-on: windows-latest
1112

12-
strategy:
13-
matrix:
14-
versions: [ 11.0.10, 11.1.0-beta1 ]
15-
1613
steps:
1714
- uses: actions/checkout@v2
1815
with:
1916
submodules: 'true'
20-
- name: Install component on windows 2022
21-
shell: pwsh
22-
run: |
23-
Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
24-
$InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
25-
$componentsToAdd = @(
26-
"Microsoft.Net.Component.4.6.1.SDK"
27-
)
28-
[string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_}
29-
$Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
30-
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
31-
if ($process.ExitCode -eq 0)
32-
{
33-
Write-Host "components have been successfully added"
34-
}
35-
else
36-
{
37-
Write-Host "components were not installed"
38-
exit 1
39-
}
40-
- name: Clean
41-
run: dotnet clean
42-
env:
43-
AVA_VER: ${{ matrix.versions }}
44-
- name: Restore
45-
run: dotnet restore
17+
- name: Build Nuget packages
4618
env:
47-
AVA_VER: ${{ matrix.versions }}
48-
- name: Build
49-
run: dotnet build --no-restore
19+
is_release: ${{ startsWith(github.ref, 'refs/tags/') }}
20+
run: |
21+
ls
22+
pwsh -ep Bypass -c ./tools/publish-nupkg.ps1 $env:is_release
23+
- name: Upload Nuget packages to GitHub registry
24+
if: ${{ github.event_name != 'pull_request' }}
5025
env:
51-
AVA_VER: ${{ matrix.versions }}
52-
- name: Test
53-
run: dotnet test --no-build --verbosity normal
26+
GHPKG_KEY: ${{ secrets.GHPKG_KEY }}
27+
run: |
28+
dotnet nuget add source --username HelloWRC --password $env:GHPKG_KEY --store-password-in-clear-text --name github "https://nuget.pkg.github.com/ClassIsland/index.json"
29+
dotnet nuget push .\out\*.nupkg -k $env:GHPKG_KEY --source "github" --skip-duplicate
30+
- name: Upload Nuget packages to NuGet Gallery
31+
if: ${{ github.event.inputs.release_tag && github.event_name != 'pull_request' }}
5432
env:
55-
AVA_VER: ${{ matrix.versions }}
33+
NUGET_KEY: ${{ secrets.NUGET_ORG_KEY }}
34+
run: |
35+
ls
36+
cd out
37+
dotnet nuget push *.nupkg -k $env:NUGET_KEY -s https://api.nuget.org/v3/index.json --skip-duplicate

tools/publish-nupkg.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
param($is_release)
2+
3+
$ErrorActionPreference = "Stop"
4+
5+
$PUBLISH_TARGET = "..\out\ClassIsland"
6+
7+
if ($(Test-Path ./out) -eq $false) {
8+
mkdir out
9+
} else {
10+
rm out/* -Recurse -Force
11+
}
12+
$tag = $(git describe --tags --abbrev=0)
13+
$count = $(git rev-list --count HEAD)
14+
$ver = [System.Version]::Parse($tag)
15+
16+
if ($is_release -eq "true") {
17+
$version = $($ver -as [string])
18+
} else {
19+
$version = $($ver -as [string]) + "-dev" + $count
20+
}
21+
echo PackageVersion:$($version -as [string])
22+
echo Version:$($ver -as [string])
23+
#dotnet clean
24+
25+
dotnet build -c Release -p:Platform="Any CPU" -p:Version=$($ver -as [string]) -p:PackageVersion=$($version -as [string]) -p:GeneratePackageOnBuild=True
26+
Copy-Item -Recurse -Force "./**/bin/**/Release/*.nupkg" ./out
27+
28+
Get-ChildItem ./out

0 commit comments

Comments
 (0)