-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (155 loc) · 5.65 KB
/
build-and-test.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
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
name: Build, test and release
on:
push:
branches: ["main"]
paths-ignore:
- README.md
pull_request:
branches: ["main"]
paths-ignore:
- README.md
jobs:
version:
name: Get versioning information
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_versioning_information.outputs.version }}
next_release_version: ${{ steps.get_versioning_information.outputs.next_release_version }}
create_release: ${{ steps.get_versioning_information.outputs.create_release }}
has_unreleased_changes: ${{ steps.get_versioning_information.outputs.has_unreleased_changes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all tags
- name: Get versioning information
uses: ./.github/actions/get-versioning-information
id: get_versioning_information
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build:
needs: version
strategy:
matrix:
include:
- name: Linux
os: ubuntu-latest
- name: Windows
os: windows-latest
- name: macOS
os: macos-latest
name: Build and test on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: src
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release
- name: Test
run: dotnet test --no-build -c Release --verbosity normal --logger "trx;LogFileName=${{ github.workspace }}/tests/test_results.trx"
- name: Create test report
uses: phoenix-actions/test-reporting@v15
if: success() || failure() # run this step even if previous step failed
with:
name: Tests
path: ${{ github.workspace }}/tests/*.trx
path-replace-backslashes: true # Required for Windows paths
reporter: dotnet-trx
output-to: step-summary
publish:
needs: [version, build]
strategy:
matrix:
include:
- name: Linux amd64
runtime-id: linux-x64
artifact-name: linux_amd64
archive_type: tar
- name: Linux arm64
runtime-id: linux-arm64
artifact-name: linux_arm64
archive_type: tar
- name: Windows amd64
runtime-id: win-x64
artifact-name: windows_amd64
archive_type: zip
- name: Windows arm64
runtime-id: win-arm64
artifact-name: windows_arm64
archive_type: zip
- name: macOS amd64
runtime-id: osx-x64
artifact-name: macos_amd64
archive_type: tar
- name: macOS arm64
runtime-id: osx-arm64
artifact-name: macos_arm64
archive_type: tar
name: Publish ${{ matrix.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Publish
run: dotnet publish src/Stack/Stack.csproj -c Release -r ${{ matrix.runtime-id }} -p:Version=${{ needs.version.outputs.version }} -p:DebugType=None -p:DebugSymbols=false -o ${{ github.workspace }}/publish
- name: Copy changelog to publish folder
run: cp ${{ github.workspace }}/CHANGELOG.md ${{ github.workspace }}/publish
- name: Copy readme to publish folder
run: cp ${{ github.workspace }}/README.md ${{ github.workspace }}/publish
- run: mkdir -p ${{ github.workspace }}/artifacts
- name: Create tar.gz archive
run: tar -czf ${{ github.workspace }}/artifacts/stack_${{ needs.version.outputs.version }}_${{ matrix.artifact-name }}.tar.gz *
working-directory: ${{ github.workspace }}/publish
if: matrix.archive_type == 'tar'
- name: Create zip archive
run: zip -r ${{ github.workspace }}/artifacts/stack_${{ needs.version.outputs.version }}_${{ matrix.artifact-name }}.zip *
working-directory: ${{ github.workspace }}/publish
if: matrix.archive_type == 'zip'
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
overwrite: true
name: ${{ matrix.artifact-name }}
path: ${{ github.workspace }}/artifacts/*
pr_complete:
name: PR checks complete
runs-on: ubuntu-latest
needs: [publish]
if: github.event_name == 'pull_request'
steps:
- run: echo "PR required checks complete"
release:
name: Release
runs-on: ubuntu-latest
needs: [version, publish]
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && needs.version.outputs.create_release == 'true'
permissions:
contents: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all tags
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifacts
- name: List artifacts
run: ls -lR ${{ github.workspace }}/artifacts
- name: Download auto
run: |
curl -kL -o - https://github.com/intuit/auto/releases/download/v11.3.0/auto-linux.gz | gunzip > ${{ runner.temp }}/auto
chmod +x ${{ runner.temp }}/auto
- name: Release
run: ${{ runner.temp }}/auto shipit --no-changelog --only-publish-with-release-label --name github-actions[bot] --email github-actions[bot]@users.noreply.github.com