@@ -2,7 +2,7 @@ name: Build
2
2
3
3
on :
4
4
push :
5
- branches : [ master ]
5
+ branches : [ main ]
6
6
pull_request :
7
7
release :
8
8
types : [ published ]
19
19
20
20
jobs :
21
21
22
- version :
23
- name : Identify build version
24
- runs-on : ubuntu-latest
25
- outputs :
26
- BuildVersion : ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
27
- steps :
28
- - name : Checkout
29
- uses : actions/checkout@v2
30
- - name : Fetch all Git tags
31
- run : git fetch --prune --unshallow --tags
32
- - name : Configure build version
33
- id : configureBuildVersion
34
- run : |
35
- $githubRunId = $env:GITHUB_RUN_ID;
36
- $prNumber = $env:PR_NUMBER;
37
- $gitSourceVersion = git describe --tags --abbrev=7 --always 2>$1;
38
- $gitSourceVersionSplit = [regex]::split($gitSourceVersion, "-(?=\d+-\w+)");
39
- $version = $(if($gitSourceVersionSplit.length -eq 1){"0.0.0"}else{$gitSourceVersionSplit[0]});
40
- $commitsSinceTag = '0';
41
- $commitHash = $gitSourceVersionSplit[0];
42
- if ($gitSourceVersionSplit.length -eq 2) {
43
- $gitMetadata = $gitSourceVersionSplit[1].split("-");
44
- $commitsSinceTag = $gitMetadata[0];
45
- $commitHash = $gitMetadata[1];
46
- }
47
- $buildMetadata = "$($commitHash)-$($githubRunId)";
48
- $customSuffix = $(if($prNumber -ne ''){"-PR$($prNumber)"}elseif($commitsSinceTag -ne '0'){"-dev"});
49
- echo "::set-output name=BUILD_VERSION::$($version)$($customSuffix)+$($buildMetadata)";
50
- shell : pwsh
51
- env :
52
- PR_NUMBER : ${{github.event.number}}
53
- - name : Print build version
54
- run : echo ${{steps.configureBuildVersion.outputs.BUILD_VERSION}}
55
-
56
-
57
22
build :
58
23
name : Build ${{matrix.os}}
59
24
runs-on : ${{matrix.os}}
60
- needs : version
61
- env :
62
- BUILD_VERSION : ${{needs.version.outputs.BuildVersion}}
63
25
strategy :
64
26
matrix :
65
27
os : [ubuntu-latest, windows-latest, macOS-latest]
@@ -81,11 +43,11 @@ jobs:
81
43
- name : Install dependencies
82
44
run : dotnet restore
83
45
- name : Build
84
- run : dotnet build -c Release -- no-restore /p:Version=${{env.BUILD_VERSION}}
46
+ run : dotnet build -- no-restore -c Release
85
47
- name : Test with Coverage
86
- run : dotnet test --logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings
48
+ run : dotnet test --no-restore -- logger trx --results-directory ${{env.BUILD_ARTIFACT_PATH}}/coverage --collect "XPlat Code Coverage" --settings CodeCoverage.runsettings /p:SkipBuildVersioning=true
87
49
- name : Pack
88
- run : dotnet pack -c Release -- no-build /p:Version=${{env.BUILD_VERSION}} /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}}
50
+ run : dotnet pack -- no-build -c Release /p:PackageOutputPath=${{env.BUILD_ARTIFACT_PATH}}
89
51
- name : Publish artifacts
90
52
uses : actions/upload-artifact@v2
91
53
with :
@@ -115,14 +77,39 @@ jobs:
115
77
with :
116
78
name : coverage-report
117
79
path : Cobertura.xml
118
-
119
- release :
120
- name : Release
80
+
81
+ push-to-github-packages :
82
+ name : ' Push GitHub Packages'
83
+ needs : build
84
+ if : github.ref == 'refs/heads/main' || github.event_name == 'release'
85
+ environment :
86
+ name : ' GitHub Packages'
87
+ url : https://github.com/TurnerSoftware/InfinityCrawler/packages
88
+ permissions :
89
+ packages : write
121
90
runs-on : ubuntu-latest
91
+ steps :
92
+ - name : ' Download build'
93
+ uses : actions/download-artifact@v2
94
+ with :
95
+ name : ' ubuntu-latest'
96
+ - name : ' Add NuGet source'
97
+ run : dotnet nuget add source https://nuget.pkg.github.com/TurnerSoftware/index.json --name GitHub --username Turnerj --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text
98
+ - name : ' Upload NuGet package'
99
+ run : dotnet nuget push *.nupkg --api-key ${{secrets.GH_PACKAGE_REGISTRY_API_KEY}} --source GitHub --skip-duplicate --no-symbols true
100
+
101
+ push-to-nuget :
102
+ name : ' Push NuGet Packages'
122
103
needs : build
123
104
if : github.event_name == 'release'
105
+ environment :
106
+ name : ' NuGet'
107
+ url : https://www.nuget.org/packages/InfinityCrawler
108
+ runs-on : ubuntu-latest
124
109
steps :
125
- - name : Download build
126
- uses : actions/download-artifact@v2
127
- - run : ls /ubuntu-latest
128
- # TODO: Upload to NuGet & GitHub Packages
110
+ - name : ' Download build'
111
+ uses : actions/download-artifact@v2
112
+ with :
113
+ name : ' ubuntu-latest'
114
+ - name : ' Upload NuGet package and symbols'
115
+ run : dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}}
0 commit comments