-
Notifications
You must be signed in to change notification settings - Fork 2
217 lines (174 loc) · 7.1 KB
/
main.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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: lf-repository-api-client-dotnet-CI
on:
push:
branches:
- v2
pull_request:
branches:
- v2
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
API_VERSION: 'v2'
VERSION_PREFIX: '1.0.1'
GITHUB_PAGES_BRANCH: 'gh-pages'
jobs:
build-n-test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Run unit tests
run: dotnet test tests/unit/Laserfiche.Repository.Api.Client.Test.csproj --no-build --verbosity normal --logger "trx;LogFileName=unit-test-results.trx"
- name: Run integration tests
env:
ACCESS_KEY: ${{ secrets.DEV_CA_PUBLIC_USE_INTEGRATION_TEST_ACCESS_KEY }}
SERVICE_PRINCIPAL_KEY: ${{ secrets.DEV_CA_PUBLIC_USE_TESTOAUTHSERVICEPRINCIPAL_SERVICE_PRINCIPAL_KEY }}
REPOSITORY_ID: ${{ secrets.DEV_CA_PUBLIC_USE_REPOSITORY_ID_1 }}
AUTHORIZATION_TYPE: ${{ secrets.AUTHORIZATION_TYPE }}
TEST_HEADER: ${{ secrets.TEST_HEADER }}
run:
dotnet test tests/integration/Laserfiche.Repository.Api.Client.IntegrationTest.csproj --no-build --verbosity normal --logger "trx;LogFileName=integration-test-results.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Test Results
path: '**/*.trx'
reporter: dotnet-trx
only-summary: 'false'
list-tests: 'failed'
fail-on-error: 'false'
build-documentation:
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [ build-n-test ] # wait for build to finish
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get install doxygen
sudo apt-get install graphviz
- name: Check dependency versions
run: |
doxygen --version
dot -V
- name: Create temporary directory
run: mkdir -p ./generated_documentation/
- name: Rewrite doxygen config
run: |
sed -i 's|PROJECT_NUMBER = version|PROJECT_NUMBER = ${{ env.VERSION_PREFIX }}|i' ./doxygen/doxygen.conf
- name: Dump doxygen.conf to check rewrite
run: head -n 200 ./doxygen/doxygen.conf
- name: Generate doxygen docs
run: doxygen ./doxygen/doxygen.conf
- name: Upload a build artifact
uses: actions/upload-artifact@v4
with:
name: documentation-artifact
path: ${{ github.workspace }}/generated_documentation/html
- name: Delete temporary directory
run: rm -r ./generated_documentation
publish-preview-package:
runs-on: ubuntu-latest
timeout-minutes: 10
environment: preview
if: ${{ github.run_attempt != 1 }}
needs: [ build-n-test, build-documentation ] # wait for build to finish
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration release
- name: Set PACKAGE_VERSION environment
run: echo "PACKAGE_VERSION=${{ env.VERSION_PREFIX }}-beta-${{ github.run_id }}" >> $GITHUB_ENV
- name: Packaging
run: dotnet pack --no-build --configuration release /p:version=${{ env.PACKAGE_VERSION }}
- name: Publish to nuget.org
run: dotnet nuget push ./src/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json
- name: Tag commit
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.API_VERSION }}-${{ env.PACKAGE_VERSION }}
commit_sha: ${{ github.sha }}
message: Workflow run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
publish-production-package:
runs-on: ubuntu-latest
timeout-minutes: 10
environment: production
if: ${{ github.run_attempt != 1 }}
needs: [ build-n-test, build-documentation ] # wait for build to finish
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration release
- name: Set PACKAGE_VERSION environment
run: echo "PACKAGE_VERSION=${{ env.VERSION_PREFIX }}" >> $GITHUB_ENV
- name: Packaging
run: dotnet pack --no-build --configuration release /p:version=${{ env.PACKAGE_VERSION }}
- name: Publish to nuget.org
run: dotnet nuget push ./src/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json
- name: Tag commit
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.API_VERSION }}-${{ env.PACKAGE_VERSION }}
commit_sha: ${{ github.sha }}
message: Workflow run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
publish-documentation:
runs-on: ubuntu-latest
timeout-minutes: 10
environment: github-pages
needs: [ publish-production-package ]
steps:
- name: Set DOCUMENTATION_VERSION environment variable
run: |
version_prefix=${{ env.VERSION_PREFIX }}
major_version=${version_prefix%%.*}
documentation_version=$major_version.x
echo $documentation_version
echo DOCUMENTATION_VERSION=$documentation_version >> $GITHUB_ENV
- name: Print DOCUMENTATION_VERSION environment variable
run: |
echo 'Publishing documentation to ${{ env.GITHUB_PAGES_BRANCH }} for ${{ env.API_VERSION }} ${{ env.DOCUMENTATION_VERSION }}.'
- uses: actions/checkout@v4
with:
ref: ${{ env.GITHUB_PAGES_BRANCH }}
- name: Delete documentation directory
run: rm -f -r ./docs/${{ env.API_VERSION }}/${{ env.DOCUMENTATION_VERSION }}
- name: Create documentation directory
run: mkdir -p ./docs/${{ env.API_VERSION }}/${{ env.DOCUMENTATION_VERSION }}
- name: Download documentation build artifact
uses: actions/download-artifact@v4
with:
name: documentation-artifact
path: ./docs/${{ env.API_VERSION }}/${{ env.DOCUMENTATION_VERSION }}
- name: Create a pull request
uses: peter-evans/create-pull-request@v4
with:
branch: ${{ env.GITHUB_PAGES_BRANCH }}-${{ env.API_VERSION }}-${{ env.DOCUMENTATION_VERSION }}-patch
delete-branch: true
title: "Automated documentation update for ${{ env.API_VERSION }} ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}"
commit-message: "Automated documentation update for ${{ env.API_VERSION }} ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}"
body: "Automated documentation update for ${{ env.API_VERSION }} ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}"
assignees: ${{ github.actor }}