-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (95 loc) · 3.21 KB
/
ci.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
on:
pull_request:
push:
branches: [main]
tags: ["v*"]
env:
DOTNET_VERSION: "8.0.x"
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: dotnet restore
run: dotnet restore src/TutorBot.sln
- name: dotnet build
run: dotnet build src/TutorBot.sln
- name: dotnet test
run: dotnet test src/TutorBot.Tests/TutorBot.Tests.csproj --no-restore --verbosity normal
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: dotnet restore
run: dotnet restore src/TutorBot.sln
- name: dotnet build
run: dotnet build src/TutorBot.sln
- name: dotnet publish
run: |
dotnet publish src/TutorBot.Cli/TutorBot.Cli.csproj --configuration Release --self-contained --runtime win-x64 -p:PublishSingleFile=true --output dist/win-x64 -p:IncludeNativeLibrariesForSelfExtract=true
dotnet publish src/TutorBot.Cli/TutorBot.Cli.csproj --configuration Release --self-contained --runtime linux-x64 -p:PublishSingleFile=true --output dist/linux-x64 -p:IncludeNativeLibrariesForSelfExtract=true
- name: prepare staging
run: |
mkdir -p ${{ runner.temp }}/staging
cp dist/win-x64/gh-tutorbot.exe ${{ runner.temp }}/staging/tutorbot-windows-amd64.exe
cp dist/linux-x64/gh-tutorbot ${{ runner.temp }}/staging/tutorbot-linux-amd64
- name: publish artifacts
uses: actions/upload-artifact@v3
with:
name: executables
path: ${{ runner.temp }}/staging/*
publish:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
environment: create_release
permissions:
contents: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: validate tag on main
shell: pwsh
run: |
git checkout main
$mainsha = $(git show-ref refs/heads/main --hash)
$tagsha = $(git show-ref ${{ github.ref }} --hash)
Write-Output "refs/heads/main: $mainsha"
Write-Output "${{ github.ref }}: $tagsha"
if ($mainsha -ne $tagsha) {
Write-Error "tag must match HEAD of main"
exit 1
}
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: executables
path: ${{ runner.temp }}/dist
- name: create release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: |
${{ runner.temp }}/dist/tutorbot-windows-amd64.exe
${{ runner.temp }}/dist/tutorbot-linux-amd64