-
Notifications
You must be signed in to change notification settings - Fork 305
220 lines (205 loc) · 7.92 KB
/
uploadReleaseArtifacts.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
name: Upload Release Artifacts
on:
release:
types: [created]
workflow_dispatch:
inputs:
os:
type: choice
description: Operating System target
default: linux
options:
- linux
- macos
- windows
# The following options only influence workflow_dispatch, and are ignored otherwise.
runTests:
description: Run CIRCT tests
default: false
type: boolean
llvm_enable_assertions:
description: Build with assertions.
default: false
type: boolean
cmake_build_type:
required: true
type: choice
options:
- Release
- RelWithDebInfo
- Debug
default: Release
# Run every day at 0700 UTC which is:
# - 0000 PDT / 2300 PST
# - 0300 EDT / 0200 EST
schedule:
- cron: '0 7 * * *'
jobs:
publish-sources:
if: github.ref_type == 'tag'
runs-on: ubuntu-20.04
permissions:
contents: write # Upload assets to release.
steps:
# Clone the CIRCT repo and its submodules. Do shallow clone to save clone
# time.
- name: Get CIRCT and LLVM
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: "true"
# Package up sources for distribution, as the default source bundles from GitHub don't include LLVM.
- name: Create Source Archive
run: |
touch circt-full-sources.tar.gz
tar \
--exclude-vcs \
--exclude=circt-full-sources.tar.gz \
-czf \
circt-full-sources.tar.gz .
shasum -a 256 circt-full-sources.tar.gz | cut -d ' ' -f1 > circt-full-sources.tar.gz.sha256
- name: Upload Source Archive
uses: AButler/[email protected]
with:
# The * will grab the .sha256 as well
files: circt-full-sources.tar.gz*
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.ref_name }} # Upload to release tag when manually run.
# This job sets up the build matrix.
choose-matrix:
runs-on: ubuntu-20.04
steps:
- name: Add Linux
id: add-linux
if: github.event_name != 'workflow_dispatch' || inputs.os == 'linux'
env:
os: linux
runner: ubuntu-20.04
arch: x64
tar: tar czf
archive: tar.gz
sha256: shasum -a 256
cont: '\'
setup:
cmake_c_compiler: clang-12
cmake_cxx_compiler: clang++-12
run: |
json=$(echo '${{ toJSON(env) }}' | jq -c)
echo $json
echo "out=$json" >> $GITHUB_OUTPUT
- name: Add macOS
id: add-macos
if: github.event_name == 'release' || ( github.event_name == 'workflow_dispatch' && inputs.os == 'macos' )
env:
os: macos
runner: macos-11
arch: x64
tar: gtar czf
archive: tar.gz
sha256: shasum -a 256
cont: '\'
setup:
cmake-args:
cmake_c_compiler: clang
cmake_cxx_compiler: clang++
run: |
json=$(echo '${{ toJSON(env) }}' | jq -c)
echo $json
echo "out=$json" >> $GITHUB_OUTPUT
- name: Add Windows
id: add-windows
if: github.event_name == 'release' || ( github.event_name == 'workflow_dispatch' && inputs.os == 'windows' )
env:
os: windows
runner: windows-2022
arch: x64
tar: tar czf
archive: zip
sha256: sha256sum
cont: '`'
setup: ./utils/find-vs.ps1
cmake-args:
cmake_c_compiler: cl
cmake_cxx_compiler: cl
run: |
json=$(echo '${{ toJSON(env) }}' | jq -c)
echo $json
echo "out=$json" >> $GITHUB_OUTPUT
- name: Add Build Config for firtool and om-linker
id: add-build-config-firtool
run: |
# Default configuration template.
json='{"name":"firtool","install_target":"install-firtool install-om-linker","package_name_prefix":"firrtl-bin","mode":"release","assert":"OFF","shared":"OFF","stats":"ON"}'
case ${{ github.event_name }} in
# Workflow dispatch looks to input knobs for asserts and build type.
workflow_dispatch)
json=$(echo $json | jq -c '.assert = "${{ inputs.llvm_enable_assertions && 'ON' || 'OFF' }}" | .mode = "${{ inputs.cmake_build_type }}"')
;;
# Scheulded runs are Release but with Asserts + Debug.
schedule)
json=$(echo $json | jq -c '.assert = "ON" | .mode = "relwithdebinfo"')
;;
esac
echo "out=$json" >> $GITHUB_OUTPUT
- name: Add Build Config for CIRCT-full (shared)
id: add-build-config-circt-full-shared
run: |
json='{"name":"CIRCT-full shared","install_target":"install","package_name_prefix":"circt-full-shared","mode":"release","assert":"OFF","shared":"ON","stats":"ON"}'
echo "out=$json" >> $GITHUB_OUTPUT
- name: Add Build Config for CIRCT-full (static)
id: add-build-config-circt-full-static
run: |
json='{"name":"CIRCT-full static","install_target":"install","package_name_prefix":"circt-full-static","mode":"release","assert":"OFF","shared":"OFF","stats":"ON"}'
echo "out=$json" >> $GITHUB_OUTPUT
- name: Build JSON Payloads
id: build-json-payloads
run: |
echo '${{ steps.add-build-config-firtool.outputs.out }}' '${{ steps.add-build-config-circt-full-shared.outputs.out }}' '${{ steps.add-build-config-circt-full-static.outputs.out }}' | jq -sc . > build_configs.json
echo '${{ steps.add-linux.outputs.out }}' '${{ steps.add-macos.outputs.out }}' '${{ steps.add-windows.outputs.out }}' | jq -sc . > runners.json
cat runners.json build_configs.json | jq -sc '[combinations | add]' > matrix-raw.json
# Exclude job, `BUILD_SHARED_LIBS` option is not supported on Windows
cat matrix-raw.json | jq -c 'del(.[] | select(.os == "windows" and .shared == "ON"))' > matrix.json
echo matrix=`cat matrix.json` >> $GITHUB_OUTPUT
echo "Generated Matrix" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
cat matrix.json | jq >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
case ${{ github.event_name }} in
workflow_dispatch)
ENV='{"runTests":${{ inputs.runTests }}}'
;;
schedule)
ENV='{"runTests":false}'
;;
*)
ENV='{"runTests":true}'
;;
esac
echo environment=$ENV >> $GITHUB_OUTPUT
echo "Environment Configuration:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
echo $ENV | jq >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
outputs:
matrix: ${{ steps.build-json-payloads.outputs.matrix }}
environment: ${{ steps.build-json-payloads.outputs.environment }}
publish:
needs:
- choose-matrix
strategy:
matrix:
generated: ${{ fromJSON(needs.choose-matrix.outputs.matrix) }}
permissions:
contents: write # Upload assets to release.
uses: ./.github/workflows/unifiedBuildTestAndInstall.yml
with:
runner: ${{ matrix.generated.runner }}
cmake_build_type: ${{ matrix.generated.mode }}
build_shared_libs: ${{ matrix.generated.shared }}
llvm_enable_assertions: ${{ matrix.generated.assert }}
llvm_force_enable_stats: ${{ matrix.generated.stats }}
runTests: ${{ fromJSON(needs.choose-matrix.outputs.environment).runTests }}
install: ${{ matrix.generated.install_target }}
package_name_prefix: ${{ matrix.generated.package_name_prefix }}
cmake_c_compiler: ${{ matrix.generated.cmake_c_compiler }}
cmake_cxx_compiler: ${{ matrix.generated.cmake_cxx_compiler }}