-
-
Notifications
You must be signed in to change notification settings - Fork 111
158 lines (131 loc) · 4.72 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Build
on: [push, pull_request]
env:
SHA: ${{ GITHUB.SHA }}
REF: ${{ GITHUB.REF }}
RUN_ID: ${{ GITHUB.RUN_ID }}
RUN_NUMBER: ${{ GITHUB.RUN_NUMBER }}
BUILD_RUN_NUMBER: build.${{ GITHUB.RUN_NUMBER }}
GITHUB_TOKEN: ${{ SECRETS.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ SECRETS.COVERALLS_REPO_TOKEN }}
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
9.0.x
include-prerelease: true
- name: Check .NET info
run: dotnet --info
- name: Install dependencies
run: dotnet restore
- name: Build solution
run: dotnet build -c Release --no-restore
- name: Test solution
run: dotnet test -c Release --no-build --no-restore --results-directory test-results --verbosity normal --collect:"XPlat Code Coverage" `
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=json,cobertura,lcov,teamcity,opencover
- name: Upload coverage
if: github.repository_owner == 'casbin' && github.event_name == 'push'
run: |
dotnet tool install coveralls.net --version 3.0.0 --tool-path tools;
$CommitAuthor = git show -s --pretty=format:"%cn";
echo "Coomit author is: $CommitAuthor";
$CommitAuthorEmail = git show -s --pretty=format:"%ce";
echo "Coomit author email is: $CommitAuthorEmail";
$CommitMessage = git show -s --pretty=format:"%s";
echo "Coomit message is: $CommitMessage";
cp test-results/**/*.opencover.xml test-results
tools/csmacnz.Coveralls --opencover -i test-results/coverage.opencover.xml --repoToken $env:COVERALLS_REPO_TOKEN `
--commitId $env:SHA --commitBranch $env:REF --commitAuthor "$CommitAuthor" `
--commitEmail "$CommitAuthorEmail" --commitMessage "$CommitMessage" `
--jobId $env:RUN_NUMBER --serviceName github-actions --useRelativePaths;
if($LastExitCode -ne 0)
{
Write-Warning -Message "Can not upload coverage, last exit code is ${LastExitCode}."
$LastExitCode = 0;
}
- name: Upload test results artefacts
if: github.repository_owner == 'casbin' && github.event_name == 'push'
uses: actions/upload-artifact@v4
with:
name: "drop-ci-test-results"
path: './test-results'
dry-run-semantic-release:
runs-on: ubuntu-latest
needs: build
if: github.repository_owner == 'casbin' && github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Dry run semantic-release
run: |
export PATH=$PATH:$(yarn global bin)
yarn global add [email protected]
semantic-release --dry-run
release-build-version:
runs-on: windows-latest
needs: build
if: github.repository_owner == 'casbin' && github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Git fetch tags
run: git fetch --tags
- name: Check tags
run: git tag -l -n
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
9.0.x
include-prerelease: true
- name: Check .NET info
run: dotnet --info
- name: Install dependencies
run: dotnet restore
- name: Build solution
run: dotnet build -c Release --no-restore
- name: Pack packages
run: |
$LastTag = git describe --tags (git rev-list --tags --max-count=1);
echo "Last tag is: $LastTag";
$Version = ($LastTag).TrimStart('v');
echo "Publishing version: $Version";
$NowBranchName = git rev-parse --abbrev-ref HEAD;
echo "Now branch name: $NowBranchName";
$PackageVersion = ($LastTag).TrimStart('v') + "-" + $env:BUILD_RUN_NUMBER + "." + $NowBranchName + "." + $env:SHA.SubString(0, 7);
echo "Publishing package version: ${PackageVersion}";
dotnet pack -c Release -o packages /p:PackageVersion=$PackageVersion /p:Version=$Version;
if($LastExitCode -ne 0)
{
Write-Warning -Message "Pack packages warming, last exit code is ${LastExitCode}."
$LastExitCode = 0;
}
- name: Upload packages artefacts
uses: actions/upload-artifact@v4
with:
name: "drop-ci-build-packages"
path: './packages'