-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (162 loc) · 6.26 KB
/
Copy pathpull_request.yml
File metadata and controls
191 lines (162 loc) · 6.26 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Pull Request Checks
run-name: Run Pull Request Checks initiated by ${{ github.actor }} on ${{ github.ref }}
on:
pull_request:
branches:
- main
- develop
jobs:
verify_release_notes:
if: github.event_name == 'pull_request'
name: Verify RELEASE_NOTES.md has been changed on Pull Request
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
if: github.base_ref == 'main'
- name: Verify RELEASE_NOTES.md has been changed on ${{ github.base_ref }}
if: github.base_ref == 'main'
uses: tj-actions/changed-files@v47
id: verify_release_notes
with:
files: |
RELEASE_NOTES.md
- name: Abort If RELEASE_NOTES.md has not been changed on ${{ github.base_ref }}
if: github.base_ref == 'main' && steps.verify_release_notes.outputs.any_changed != 'true'
run: exit 1
- name: Success If RELEASE_NOTES.md has been changed on ${{ github.base_ref }}
run: exit 0
test_pull_request:
name: Run Unit Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- name: Setup
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Restore
run: dotnet restore src/lib/AutoBackend.Sdk
- name: Build
run: dotnet build src/lib/AutoBackend.Sdk --configuration Release --no-restore
- name: Test
run: dotnet test src/lib/AutoBackend.Sdk --no-restore --verbosity normal
create_release_hot:
if: github.event_name == 'pull_request'
name: Create Release Hot Version
needs:
- test_pull_request
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
created_release_version: ${{ steps.get_release_hot_version.outputs.result }}
steps:
- name: Get Release Hot Version
id: get_release_hot_version
uses: actions/github-script@v9
with:
script: |
var major = ${{ vars.DEFAULT_MAJOR_VERSION }};
var minor = ${{ vars.DEFAULT_MINOR_VERSION }};
var patch = ${{ vars.DEFAULT_PATCH_VERSION }};
var latestRelease = { data: { name: `${major}.${minor}.${patch}` } };
try {
latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
} catch {
// do nothing
}
if (/\d+\.\d+\.\d+/.test(latestRelease?.data?.name)) {
var latestVersion = latestRelease.data.name.match(/\d+\.\d+\.\d+/)[0];
var parsed = latestVersion.split('.');
if (parsed.length == 3) {
var major_max = Math.max(major, +parsed[0]);
var minor_max = Math.max(minor, +parsed[1]);
var patch_max = Math.max(patch, +parsed[2]);
return `${major_max}.${minor_max}.${patch_max+1}-hot-${ ${{ github.event.pull_request.number }} }`;
}
throw latestRelease;
}
throw latestRelease;
result-encoding: string
build_package_hot:
if: github.event_name == 'pull_request'
name: Build Package Hot Version
needs:
- test_pull_request
- create_release_hot
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- name: Set Build Hot Version "${{ needs.create_release_hot.outputs.created_release_version }}"
run: |
echo "BUILD_VERSION=${{ needs.create_release_hot.outputs.created_release_version }}" >> ${GITHUB_ENV}
- name: Setup
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Restore
run: dotnet restore src/lib/AutoBackend.Sdk
- name: Build Version "${{ env.BUILD_VERSION }}"
run: dotnet build src/lib/AutoBackend.Sdk --configuration Release --no-restore
- name: Pack Hot Version "${{ env.BUILD_VERSION }}"
run: dotnet pack src/lib/AutoBackend.Sdk --configuration Release --no-restore --output ${{ env.DOTNET_ROOT }}/Package
- uses: actions/upload-artifact@master
with:
name: release_hot_package
path: ${{ env.DOTNET_ROOT }}/Package
publish_myget_hot:
if: github.event_name == 'pull_request'
name: Publish MyGet Package Hot Version
needs:
- test_pull_request
- create_release_hot
- build_package_hot
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Setup
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- uses: actions/download-artifact@master
with:
name: release_hot_package
path: ${{ env.DOTNET_ROOT }}/Package
- name: Publish MyGet Package Hot Version "${{ needs.create_release_hot.outputs.created_release_version }}"
run: dotnet nuget push ${{ env.DOTNET_ROOT }}/Package/*.nupkg --source https://www.myget.org/F/autobackend-hot/auth/${{ secrets.MYGET_API_KEY }}/api/v3/index.json
comment_pull_request:
if: github.event_name == 'pull_request'
name: Comment Pull Request with the Hot Version build's link
needs:
- test_pull_request
- create_release_hot
- build_package_hot
- publish_myget_hot
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Comment Pull Request with the Hot Version "${{ needs.create_release_hot.outputs.created_release_version }}" build's link
uses: actions/github-script@v9
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ Ok. You can find your hot-test package v${{ needs.create_release_hot.outputs.created_release_version }} ' +
'here: https://www.myget.org/feed/autobackend-hot/package/nuget/AutoBackend.SDK/' +
'${{ needs.create_release_hot.outputs.created_release_version }}.\n\n' +
'❗ Please make sure you have checked it carefully.'
})