Upload Release Artifacts #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload Release Artifacts | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
inputs: | |
os: | |
type: choice | |
description: Operating System target | |
default: linux | |
options: | |
- linux | |
- macos | |
- windows | |
runTests: | |
type: choice | |
description: Run CIRCT tests | |
default: false | |
options: | |
- true | |
- false | |
# 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 | |
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/upload-release-assets@v2.0 | |
with: | |
# The * will grab the .sha256 as well | |
files: circt-full-sources.tar.gz* | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# 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-2019 | |
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: | | |
json='{"name":"firtool","install_target":"install-firtool install-om-linker","package_name_prefix":"firrtl-bin","mode":"release","assert":"OFF","shared":"OFF","stats":"ON"}' | |
if [[ ${{ github.event_name }} == 'schedule' ]] || [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then | |
json=$(echo $json | jq -c '.assert = "ON" | .mode = "relwithdebinfo"') | |
fi | |
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: 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 }}' | 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) }} | |
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 }} |