-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (73 loc) · 2.82 KB
/
build.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
name: Build
on:
pull_request:
push:
release:
types: [published]
jobs:
build:
name: Build
env:
NUPKG_MAJOR: 3.0
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.0
- name: NuGet Restore
run: msbuild /t:Restore /p:Configuration=Release .\ZXing.Net.Mobile.sln
- name: Build
run: msbuild /t:Build /p:Configuration=Release .\ZXing.Net.Mobile.sln
- name: Package NuGets
run: |
$pkgVer = ($env:NUPKG_MAJOR + "-alpha" + $env:GITHUB_RUN_ID)
if ($env:GITHUB_EVENT_NAME -eq "release") {
$pkgVer = $env:GITHUB_REF.Substring($env:GITHUB_REF.LastIndexOf('/') + 1)
}
New-Item -ItemType Directory -Force -Path .\artifacts
msbuild /t:Pack /p:Configuration=Release /p:PackageOutputPath=..\artifacts /p:PackageVersion=$pkgVer /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg .\ZXing.Net.Mobile\ZXing.Net.Mobile.csproj
msbuild /t:Pack /p:Configuration=Release /p:PackageOutputPath=..\artifacts /p:PackageVersion=$pkgVer /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg .\ZXing.Net.Mobile.Forms\ZXing.Net.Mobile.Forms.csproj
- name: Upload Artifacts
uses: actions/upload-artifact@v1
with:
name: NuGet
path: .\artifacts
publish-gh:
name: Publish to GitHub Packages
needs: build
runs-on: windows-latest
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'release')
steps:
- name: Download Artifacts
uses: actions/download-artifact@v1
with:
name: NuGet
- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: 'latest'
- name: Push NuGet
run: |
nuget sources add -Name "GPR" -Source "https://nuget.pkg.github.com/Redth/index.json" -UserName Redth -Password ${{ secrets.GITHUB_TOKEN }}
nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source "GPR"
nuget push NuGet\*.nupkg -Source "GPR"
publish-nugetorg:
name: Publish to NuGet.org
needs: build
runs-on: windows-latest
if: github.event_name == 'release'
steps:
- name: Download Artifacts
uses: actions/download-artifact@v1
with:
name: NuGet
- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
nuget-version: 'latest'
- name: Push NuGet
run: |
nuget push NuGet\*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_ORG_API_KEY }}