forked from uli/huc
-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (160 loc) · 5.38 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
name: build
# Github Actions aren't supporting anchors yet
# upvote here https://github.com/github/feedback/discussions/4501
on:
push:
pull_request:
branches:
- master
# activating dispatch to allow manual runs
# workflow_dispatch:
env:
MSYS2_INSTALL_FOLDER: C:\msys64\ # provided by GitHub Actions VMs
jobs:
build:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macos-11, macos-12, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: Check out code from the repository
uses: actions/checkout@v3
- name: Build on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
make
echo Build Complete
- name: Build on Windows
if: startsWith(matrix.os, 'windows')
run: |
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -c "pacman -S binutils make mingw-w64-x86_64-gcc git --noconfirm"
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -where %CD% -c "make"
echo Build Complete
- name: Build on Mac
if: startsWith(matrix.os, 'macos')
run: |
brew install make # need gnumake
gmake
echo Build Complete
- name: Archive toolchain
uses: actions/upload-artifact@v3
with:
name: toolchain-${{ matrix.os }}
path: |
bin
examples/**/*.iso
examples/**/*.pce
examples/**/*.sgx
tgemu/tgemu
test:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macos-11, macos-12, windows-2022]
runs-on: ${{ matrix.os }}
needs: build
steps:
- name: Check out code from the repository
uses: actions/checkout@v3
- name: Get previoulsy built artifacts
uses: actions/download-artifact@v3
with:
name: toolchain-${{ matrix.os }}
- name: Restore Execute Flags
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: |
chmod +x bin/* # Github Action artifacts don't keep exec flags https://github.com/actions/upload-artifact#permission-loss'
chmod +x tgemu/tgemu
- name: Run tests on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update && sudo apt-get install -y dos2unix
make check
make test
echo Test Complete
- name: Setup Msys2
if: startsWith(matrix.os, 'windows')
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: coreutils make git dos2unix
- name: Run tests on Windows
if: startsWith(matrix.os, 'windows')
shell: msys2 {0}
run: |
make check
make test
echo Build Complete
- name: Run tests on Mac
if: startsWith(matrix.os, 'macos')
run: |
brew install make md5sha1sum dos2unix # need gnumake and md5sum to run make check
gmake check
gmake test
echo Build Complete
package:
strategy:
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
runs-on: ${{ matrix.os }}
needs: build
steps:
- name: Check out code from the repository
uses: actions/checkout@v3
- name: Get previoulsy built artifacts
uses: actions/download-artifact@v3
with:
name: toolchain-${{ matrix.os }}
- name: Package ${{ matrix.os }}
if: startsWith(matrix.os, 'ubuntu')
run: |
make package
echo Package Complete
- name: Package ${{ matrix.os }}
if: startsWith(matrix.os, 'windows')
run: |
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -c "pacman -S binutils make git zip --noconfirm"
${{ env.MSYS2_INSTALL_FOLDER }}\msys2_shell.cmd -mingw64 -no-start -defterm -where %CD% -c "make package"
echo Package Complete
- name: Package ${{ matrix.os }}
if: startsWith(matrix.os, 'macos')
run: |
brew install make # need gnumake
gmake package
echo Package Complete
- name: Archive package
uses: actions/upload-artifact@v3
with:
name: package-${{ matrix.os }}
path: |
*.zip
if-no-files-found: error
publish_package:
runs-on: ubuntu-latest
needs: [package, test]
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
steps:
- name: Check out code from the repository
uses: actions/checkout@v3
- name: Get previoulsy built artifacts win64
uses: actions/download-artifact@v3
with:
name: package-windows-2022
- name: Get previoulsy built artifacts macos
uses: actions/download-artifact@v3
with:
name: package-macos-12
- name: Get previoulsy built artifacts linux
uses: actions/download-artifact@v3
with:
name: package-ubuntu-20.04
# https://github.com/pyTooling/Actions/tree/main/releaser
# need to use composite on windows, since docker isn't available
- name: publish package
uses: pyTooling/Actions/releaser@r0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
rm: true # do not keep old latest artifacts
files: |
*.zip