-
Notifications
You must be signed in to change notification settings - Fork 54
90 lines (73 loc) · 2.43 KB
/
build-and-test.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: build and test
on:
push:
branches:
- main
- 'version/**'
pull_request:
branches:
- main
paths:
- '.github/workflows/build-and-test.yml'
- 'AdvancedSharpAdbClient**'
workflow_dispatch:
env:
DOTNET_VERSION: '9.0.x' # The .NET SDK version to use
jobs:
build-and-test:
name: build-and-test-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET Core App
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Dependencies
run: dotnet restore -p:FullTargets=false
- name: Build
run: dotnet build --no-restore -p:FullTargets=false
- name: Test
run: dotnet test --no-restore --blame-hang-timeout 1m -p:FullTargets=false
pack-and-publish:
name: pack-and-publish
needs: build-and-test
runs-on: windows-latest
env:
Solution_Name: AdvancedSharpAdbClient/AdvancedSharpAdbClient.csproj
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET Core App
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Setup NuGet.exe
uses: NuGet/setup-nuget@v2
- name: Install Dependencies
run: msbuild $env:Solution_Name /t:Restore /p:FullTargets=true /p:GITHUB_ACTIONS=false
- name: Pack
run: msbuild $env:Solution_Name /t:Pack /p:FullTargets=true /p:GITHUB_ACTIONS=false /p:Configuration=Release /p:PackageOutputPath=../nugets /p:VersionSuffix=build.${{ github.run_number }}.${{ github.run_attempt }}
- name: Publish
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
run: dotnet nuget push nugets/**.nupkg --source $env:NUGET_SOURCE --skip-duplicate --api-key $env:GITHUB_TOKEN
env:
NUGET_SOURCE: https://nuget.pkg.github.com/SharpAdb/index.json
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: Nuget Package
path: nugets/**