-
Notifications
You must be signed in to change notification settings - Fork 4
224 lines (190 loc) · 8.25 KB
/
release.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
name: Release
on:
workflow_dispatch:
inputs:
new_engine_version:
description: 'New engine version. If empty, run number will be used and no commit/tag/release will be created'
default: ''
required: false
should_push_new_nuget_version:
description: 'Push new NuGet version'
type: boolean
default: true
required: false
should_commit_new_version:
description: 'Commit and push version increment. If true, this new commit will be the one tagged (in case Tag version release is also set to true)'
type: boolean
default: true
required: false
should_tag_new_version:
description: 'Tag version release. If false, no release will be created either'
type: boolean
default: true
required: false
should_create_github_release:
description: 'Create GitHub Release'
type: boolean
default: true
required: false
env:
DOTNET_VERSION: 8.0.x
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_TieredPGO: 1
DOTNET_ReadyToRun: 0
DOTNET_TC_QuickJitForLoops: 1
jobs:
publish-artifacts:
runs-on: ${{ matrix.os }}
strategy:
matrix:
runtime-identifier: [win-x64, win-arm64, linux-x64, linux-arm64, linux-arm, linux-musl-x64, osx-x64, osx-arm64]
include:
- runtime-identifier: win-x64
os: windows-latest
- runtime-identifier: win-arm64
os: windows-latest
- runtime-identifier: linux-x64
os: ubuntu-latest
- runtime-identifier: linux-arm64
os: ubuntu-latest
- runtime-identifier: linux-arm
os: ubuntu-latest
- runtime-identifier: linux-musl-x64
os: ubuntu-latest
- runtime-identifier: osx-x64
os: macos-latest
- runtime-identifier: osx-arm64
os: macos-latest
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Nuget cache
uses: actions/cache@v3
with:
path:
~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Set version to ${{ github.event.inputs.new_engine_version }}
shell: pwsh
run: |
$input_path = "Directory.Build.props"
$regex = "(?<=<Version>).*(?=</Version>)"
(Get-Content $input_path) -Replace $regex, '${{ github.event.inputs.new_engine_version }}' | Out-File $input_path
- name: Publish ${{ matrix.runtime-identifier }} version
run: dotnet publish src/Lynx.Cli/Lynx.Cli.csproj -c Release --runtime ${{ matrix.runtime-identifier }} --self-contained /p:Optimized=true /p:DeterministicBuild=true -o artifacts/${{ matrix.runtime-identifier }}
- name: Upload Lynx-${{ matrix.runtime-identifier }} artifact
if: github.event.inputs.new_engine_version != ''
uses: actions/upload-artifact@v3
with:
name: Lynx-${{ github.event.inputs.new_engine_version }}-${{ matrix.runtime-identifier }}
path: |
artifacts/${{ matrix.runtime-identifier }}/
!artifacts/**/*.pdb
if-no-files-found: error
- name: Upload Lynx-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }}-${{ matrix.runtime-identifier }} artifact
if: github.event.inputs.new_engine_version == ''
uses: actions/upload-artifact@v3
with:
name: Lynx-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }}-${{ matrix.runtime-identifier }}
path: |
artifacts/${{ matrix.runtime-identifier }}/
!artifacts/**/*.pdb
if-no-files-found: error
- name: Deterministic build
if: matrix.runtime-identifier == 'linux-x64'
run: dotnet clean -c Release && dotnet build -c Release /p:DeterministicBuild=true
- name: Pack NuGet package
if: matrix.runtime-identifier == 'linux-x64'
run: dotnet pack -c Release --no-build src/Lynx/Lynx.csproj --include-symbols -o artifacts/nuget
- name: Upload Lynx-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }} NuGet package
if: matrix.runtime-identifier == 'linux-x64' && github.event.inputs.new_engine_version != ''
uses: actions/upload-artifact@v3
with:
name: Lynx-${{ github.event.inputs.new_engine_version }}-nuget
path: |
artifacts/nuget/*.nupkg
artifacts/nuget/*.snupkg
if-no-files-found: error
- name: Upload Lynx-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }} NuGet package
if: matrix.runtime-identifier == 'linux-x64' && github.event.inputs.new_engine_version == ''
uses: actions/upload-artifact@v3
with:
name: Lynx-${{ env.GITHUB_REF_SLUG }}-${{ github.run_number }}-nuget
path: |
artifacts/nuget/*.nupkg
artifacts/nuget/*.snupkg
if-no-files-found: error
release:
needs: publish-artifacts
if: github.event.inputs.new_engine_version != ''
runs-on: ubuntu-latest
steps:
- name: Install hub tool
if: github.event.inputs.should_create_github_release == 'true'
run: |
sudo apt-get update && sudo apt-get install -y hub
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_RELEASE }}
- name: Configure git user
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Set version to ${{ github.event.inputs.new_engine_version }}
shell: pwsh
run: |
$input_path = "Directory.Build.props"
$regex = "(?<=<Version>).*(?=</Version>)"
(Get-Content $input_path) -Replace $regex, '${{ github.event.inputs.new_engine_version }}' | Out-File $input_path
- name: Commit and push version increment
if: github.event.inputs.should_commit_new_version == 'true'
continue-on-error: true
run: |
git switch ${{ env.GITHUB_REF_NAME }}
git status
git commit -am "🚀 Release v${{ github.event.inputs.new_engine_version }}"
git push
- name: Create git tag
if: github.event.inputs.should_tag_new_version == 'true'
run: |
git switch ${{ env.GITHUB_REF_NAME }}
git status
git tag -a v${{ github.event.inputs.new_engine_version }} -m "v${{ github.event.inputs.new_engine_version }}"
git push --tags
- uses: actions/download-artifact@v3
with:
path: artifacts/
- name: Push NuGet package to nuget.org
if: github.event.inputs.should_push_new_nuget_version == 'true'
run: nuget push 'artifacts/Lynx-${{ github.event.inputs.new_engine_version }}-nuget/*.nupkg' -ApiKey ${{ secrets.NUGET_APIKEY }} -Source https://api.nuget.org/v3/index.json -SkipDuplicate -Verbosity detailed
- name: Push NuGet package to GitHub
if: github.event.inputs.should_push_new_nuget_version == 'true'
run: nuget push 'artifacts/Lynx-${{ github.event.inputs.new_engine_version }}-nuget/*.nupkg' -ApiKey ${{ secrets.GITHUB_TOKEN }} -Source https://nuget.pkg.github.com/lynx-chess/index.json -SkipDuplicate -Verbosity detailed
- name: Compress artifacts again
if: github.event.inputs.should_create_github_release == 'true' && github.event.inputs.should_tag_new_version == 'true'
run: for i in artifacts/*[!-nuget]; do zip -0 -r -q -j "${i%/}.zip" "$i" & done; wait
- name: Create GitHub release and upload assets
if: github.event.inputs.should_create_github_release == 'true' && github.event.inputs.should_tag_new_version == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in artifacts/*.zip; do
assets+=("-a" "$asset")
done
for asset in artifacts/Lynx-${{ github.event.inputs.new_engine_version }}-nuget/*; do
assets+=("-a" "$asset")
done
tag_name="v${{ github.event.inputs.new_engine_version }}"
hub release create "${assets[@]}" --draft --message "$tag_name" "$tag_name"