-
Notifications
You must be signed in to change notification settings - Fork 4
265 lines (237 loc) · 11.4 KB
/
pipeline.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: "pipeline"
on:
push:
branches: ['main']
workflow_dispatch:
inputs:
dry-run:
description: 'dry run mode'
required: true
default: true
type: boolean
pull_request:
branches: ['main']
jobs:
setup:
runs-on: ubuntu-latest
outputs:
# changed files output, might be relevant for other jobs
global_any_modified: ${{ steps.changed-files-yaml.outputs.global_any_modified }}
global_all_modified_files: ${{ steps.changed-files-yaml.outputs.global_all_modified_files }}
staging_area_all_modified_files: ${{ steps.changed-files-yaml.outputs.packages_all_modified_files }}
staging_area_any_modified: ${{ steps.changed-files-yaml.outputs.packages_any_modified }}
tests_all_modified_files: ${{ steps.changed-files-yaml.outputs.tests_all_modified_files }}
tests_any_modified: ${{ steps.changed-files-yaml.outputs.tests_any_modified }}
api_all_modified_files: ${{ steps.changed-files-yaml.outputs.api_all_modified_files }}
api_any_modified: ${{ steps.changed-files-yaml.outputs.api_any_modified }}
client_all_modified_files: ${{ steps.changed-files-yaml.outputs.client_all_modified_files }}
client_any_modified: ${{ steps.changed-files-yaml.outputs.client_any_modified }}
index_all_modified_files: ${{ steps.changed-files-yaml.outputs.index_all_modified_files }}
index_any_modified: ${{ steps.changed-files-yaml.outputs.index_any_modified }}
# dry run so we can do manual diagnostics
is_dry_run: ${{ steps.decide-on-dry-run.outputs.dry_run }}
# trigger other jobs
trigger-build-and-test-projects: ${{steps.set-triggers.outputs.trigger-build-and-test-projects}}
trigger-release-index: ${{steps.set-triggers.outputs.trigger-release-index}}
trigger-release-client: ${{steps.set-triggers.outputs.trigger-release-client}}
trigger-release-api: ${{steps.set-triggers.outputs.trigger-release-api}}
trigger-test-staging-area: ${{steps.set-triggers.outputs.trigger-test-staging-area}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get all relevant file changes
id: changed-files-yaml
uses: tj-actions/changed-files@v42
with:
files_yaml: |
global:
- '**'
packages:
- StagingArea/**
tests:
- tests/**
api:
- src/PackageRegistryService/**
client:
- src/AVPRClient/**
index:
- src/AVPRIndex/**
- name: decide on dry run
id: decide-on-dry-run
run: |
if [[ ${{ github.event_name == 'workflow_dispatch' }} == true ]]; then
dr=${{ inputs.dry-run }}
else
dr=false
fi
echo "dry_run=$dr" >> $GITHUB_OUTPUT
echo "$GITHUB_OUTPUT"
echo "dry_run=$dr"
- name: set triggers
id: set-triggers
run: |
echo "trigger-build-and-test-projects=${{ steps.changed-files-yaml.outputs.tests_any_modified == 'true' || steps.changed-files-yaml.outputs.api_any_modified == 'true' || steps.changed-files-yaml.outputs.client_any_modified == 'true' || steps.changed-files-yaml.outputs.index_any_modified == 'true'}}" >> $GITHUB_OUTPUT
echo "trigger-release-index=${{github.event_name == 'push' && steps.decide-on-dry-run.outputs.dry_run == 'false' && contains(steps.changed-files-yaml.outputs.index_all_modified_files, 'RELEASE_NOTES.md')}}" >> $GITHUB_OUTPUT
echo "trigger-release-client=${{github.event_name == 'push' && steps.decide-on-dry-run.outputs.dry_run == 'false' && contains(steps.changed-files-yaml.outputs.client_all_modified_files, 'RELEASE_NOTES.md')}}" >> $GITHUB_OUTPUT
echo "trigger-test-staging-area=${{steps.changed-files-yaml.outputs.packages_any_modified == 'true' && steps.decide-on-dry-run.outputs.dry_run == 'false'}}" >> $GITHUB_OUTPUT
echo "trigger-release-api=${{github.event_name == 'push' && steps.decide-on-dry-run.outputs.dry_run == 'false' && steps.changed-files-yaml.outputs.api_any_modified == 'true' }}" >> $GITHUB_OUTPUT
echo "$GITHUB_OUTPUT"
- name: list outputs
run: |
echo "global:"
echo "- any: ${{ steps.changed-files-yaml.outputs.global_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.global_all_modified_files }}"
echo "staging area:"
echo "- any: ${{ steps.changed-files-yaml.outputs.packages_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.packages_all_modified_files }}"
echo "tests:"
echo "- any: ${{ steps.changed-files-yaml.outputs.tests_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.tests_all_modified_files }}"
echo "api:"
echo "- any: ${{ steps.changed-files-yaml.outputs.api_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.api_all_modified_files }}"
echo "client:"
echo "- any: ${{ steps.changed-files-yaml.outputs.client_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.client_all_modified_files }}"
echo "index:"
echo "- any: ${{ steps.changed-files-yaml.outputs.index_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.index_all_modified_files }}"
echo "computed outputs:"
echo "dry run: ${{ steps.decide-on-dry-run.outputs.dry_run }}"
echo "trigger build-and-test-projects: ${{steps.set-triggers.outputs.trigger-build}}"
echo "trigger release-index: ${{steps.set-triggers.outputs.trigger-release-index}}"
echo "trigger release-client: ${{steps.set-triggers.outputs.trigger-release-client}}"
echo "trigger release-index: ${{steps.set-triggers.outputs.trigger-release-index}}"
echo "trigger release-api: ${{steps.set-triggers.outputs.trigger-release-api}}"
echo "trigger test-staging-area: ${{steps.set-triggers.outputs.trigger-test-staging-area}}"
- name: list triggered jobs
run: |
echo "this should trigger the following jobs:"
echo "build-and-test-projects: ${{steps.set-triggers.outputs.trigger-build-and-test-projects}}"
echo "release-index: ${{steps.set-triggers.outputs.trigger-release-index}}"
echo "release-client: ${{steps.set-triggers.outputs.trigger-release-client}}"
echo "release-api: ${{steps.set-triggers.outputs.trigger-release-api}}"
echo "test-staging-area: ${{steps.set-triggers.outputs.trigger-test-staging-area}}"
build-and-test-projects:
name: "Build and test projects"
needs: setup
# https://github.com/actions/runner/issues/1173
if: needs.setup.outputs.trigger-build-and-test-projects == 'true'
uses: nfdi4plants/arc-validate-package-registry/.github/workflows/build-and-test-solution.yml@main
with:
solution: ./arc-validate-package-registry.sln
configuration: Release
release-index-package:
name: "Release index package"
needs: [setup, build-and-test-projects]
if: needs.setup.outputs.trigger-release-index == 'true'
uses: nfdi4plants/arc-validate-package-registry/.github/workflows/release-package.yml@main
with:
project: src/AVPRIndex/AVPRIndex.fsproj
secrets:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
release-client-package:
name: "Release client package"
needs: [setup, build-and-test-projects]
if: needs.setup.outputs.trigger-release-client == 'true'
uses: nfdi4plants/arc-validate-package-registry/.github/workflows/release-package.yml@main
with:
project: src/AVPRClient/AVPRClient.csproj
secrets:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
release-api-image:
name: "Release API image"
needs: [setup, build-and-test-projects]
if: needs.setup.outputs.trigger-release-api == 'true'
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: nfdi4plants/avpr
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
file: ./src/PackageRegistryService/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
test-staging-area:
name: "Test staging area"
needs: setup
# https://github.com/actions/runner/issues/1173
if: needs.setup.outputs.trigger-test-staging-area == 'true'
uses: nfdi4plants/arc-validate-package-registry/.github/workflows/build-and-test-solution.yml@main
with:
solution: ./PackageStagingArea.sln
configuration: Release
windows: true
ubuntu: false
macos: false
staging-area-pre-publish-checks:
name: "Staging area pre-publish checks"
needs: test-staging-area
runs-on: ubuntu-latest
outputs:
trigger-update-preview-index: ${{ steps.set-output.outputs.trigger-update-preview-index }}
trigger-publish-pending-packages: ${{ steps.set-output.outputs.trigger-publish-pending-packages }}
steps:
- uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: Run pre-publish checks
id: ppc
run: |
dotnet run --project ./src/AVPRCI/AVPRCI.fsproj -- --verbose check
- name: set-output
id: set-output
run: |
echo "trigger-update-preview-index=$UPDATE_PREVIEW_INDEX"
echo "trigger-update-preview-index=$UPDATE_PREVIEW_INDEX" >> $GITHUB_OUTPUT
echo "trigger-publish-pending-packages=$PUBLISH_PENDING_PACKAGES"
echo "trigger-publish-pending-packages=$PUBLISH_PENDING_PACKAGES" >> $GITHUB_OUTPUT
- name: list triggered jobs
run: |
echo "this should trigger the following jobs:"
echo "trigger-update-preview-index: ${{steps.set-output.outputs.trigger-update-preview-index}}"
echo "trigger-publish-pending-packages: ${{steps.set-output.outputs.trigger-publish-pending-packages}}"
update-preview-index:
needs: staging-area-pre-publish-checks
runs-on: ubuntu-latest
if: needs.staging-area-pre-publish-checks.outputs.trigger-update-preview-index == 'true' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x.x
- name: re-generate preview index
run: dotnet run --project ./src/AVPRCI/AVPRCI.fsproj -- --verbose gen-index
- name: publish preview index
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "preview-index"
prerelease: false
title: "Latest preview index release"
files: |
avpr-preview-index.json