-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (73 loc) · 2.57 KB
/
01_build.yaml
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
name: "1 - Build and Test C# Code"
on:
workflow_dispatch:
pull_request:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "6.0.x"
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "6.0.x"
- name: Install dependencies
run: dotnet restore
- name: Test
run: dotnet test
release-reqs-check:
name: Release requirements check
runs-on: ubuntu-latest
steps:
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
- uses: actions/checkout@v4
- name: Get project version from `main`
id: proj_version_main
run: |
git fetch origin main:main
PROJ_VERSION_MAIN=$(git show main:src/Styra.Opa.AspNetCore/Styra.Opa.AspNetCore.csproj | grep -Eo '<Version>.*</Version>' | sed -E 's/<\/?Version>//g')
echo "PROJ_VERSION_MAIN=$PROJ_VERSION_MAIN" >> $GITHUB_ENV
- name: Get current version on this PR
id: proj_version_pr
run: |
PROJ_VERSION_PR=$(git show src/Styra.Opa.AspNetCore/Styra.Opa.AspNetCore.csproj | grep -Eo '<Version>.*</Version>' | sed -E 's/<\/?Version>//g')
echo "PROJ_VERSION_PR=$PROJ_VERSION_PR" >> $GITHUB_ENV
- name: Check for diff for project file changes.
run: |
if [ "$PROJ_VERSION_MAIN" != "$PROJ_VERSION_PR" ]; then
echo "Version changed from $PROJ_VERSION_MAIN to $PROJ_VERSION_PR"
echo "VERSION_CHANGED=true" >> $GITHUB_ENV
else
echo "Version unchanged"
echo "VERSION_CHANGED=false" >> $GITHUB_ENV
fi
- name: Check for other release-required files.
if: env.VERSION_CHANGED == 'true'
run: |
# Check for updated CHANGELOG.
if ! grep -q "^## $PROJ_VERSION_PR" CHANGELOG.md; then
echo "Error: Version $PROJ_VERSION_PR not found in CHANGELOG.md"
exit 1
fi