This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
182 lines (162 loc) · 5.03 KB
/
build.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
---
name: Build Simulator
on:
push:
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
defaults:
run:
shell: ${{ matrix.config.shell }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04 x86_64",
os: ubuntu-20.04,
shell: "bash",
cc: "gcc",
cxx: "g++",
install_target: "install/strip",
artifact: "mrisc32-simulator-linux-x86_64.tar.gz",
archive_type: "tar",
}
- {
name: "macOS arm64 + x86_64",
os: macos-latest,
shell: "bash",
cc: "clang",
cxx: "clang++",
extra_cmake_flags: "-DCMAKE_OSX_ARCHITECTURES=x86_64\\;arm64",
install_target: "install/strip",
artifact: "mrisc32-simulator-macos.zip",
archive_type: "zip",
}
- {
name: "Windows x86_64",
os: windows-2022,
shell: cmd,
environment_script: "call \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat\" amd64",
cc: "cl",
cxx: "cl",
install_target: "install",
artifact: "mrisc32-simulator-win-x86_64.zip",
archive_type: "zip",
}
steps:
- name: Setup CMake and Ninja
uses: lukka/get-cmake@latest
- name: Install dependencies (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update
sudo apt install -y xorg-dev
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build
env:
CC: "${{ matrix.config.cc }}"
CXX: "${{ matrix.config.cxx }}"
run: |
${{ matrix.config.environment_script }}
mkdir out
mkdir mrisc32-simulator
cd out
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ${{ matrix.config.extra_cmake_flags }} -DCMAKE_INSTALL_PREFIX=../mrisc32-simulator ../sim
cmake --build .
cmake --build . --target ${{ matrix.config.install_target }}
- name: Pack archive (tar)
if: ${{ matrix.config.archive_type == 'tar' }}
run: |
tar -cv -I "gzip -9" -f ${{ matrix.config.artifact }} mrisc32-simulator
- name: Pack archive (zip)
if: ${{ matrix.config.archive_type == 'zip' }}
run: |
7z a -tzip -mx=9 ${{ matrix.config.artifact }} mrisc32-simulator
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
path: ${{ matrix.config.artifact }}
name: ${{ matrix.config.artifact }}
release:
name: Release
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-20.04
needs: build
steps:
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Store release URL
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
- name: Upload release URL
uses: actions/upload-artifact@v1
with:
path: ./upload_url
name: upload_url
publish:
name: ${{ matrix.config.name }}
if: contains(github.ref, 'tags/v')
runs-on: ubuntu-20.04
needs: release
strategy:
fail-fast: false
matrix:
config:
- {
name: "Ubuntu 20.04 x86_64",
artifact: "mrisc32-simulator-linux-x86_64.tar.gz",
artifact_content_type: "application/x-tar",
}
- {
name: "macOS arm64 + x86_64",
artifact: "mrisc32-simulator-macos.zip",
artifact_content_type: "application/zip",
}
- {
name: "Windows x86_64",
artifact: "mrisc32-simulator-win-x86_64.zip",
artifact_content_type: "application/zip",
}
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ matrix.config.artifact }}
path: ./
- name: Download release URL
uses: actions/download-artifact@v1
with:
name: upload_url
path: ./
- name: Set upload URL
id: set_upload_url
run: |
upload_url=`cat ./upload_url`
echo ::set-output name=upload_url::$upload_url
- name: Upload artifact to release
id: upload_to_release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
asset_path: ${{ matrix.config.artifact }}
asset_name: ${{ matrix.config.artifact }}
asset_content_type: ${{ matrix.config.artifact_content_type }}