-
Notifications
You must be signed in to change notification settings - Fork 0
234 lines (220 loc) · 7.27 KB
/
Copy pathbuild.yml
File metadata and controls
234 lines (220 loc) · 7.27 KB
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
225
226
227
228
229
230
231
232
233
234
name: Build Quantum C
on:
push:
branches: [ master ]
paths:
- 'version.txt'
jobs:
tag:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.get_version.outputs.version }}
exists: ${{ steps.check_tag.outputs.exists }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: get_version
run: echo "version=$(cat version.txt | tr -d '[:space:]')" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: check_tag
run: |
git fetch --tags
VERSION=$(cat version.txt | tr -d '[:space:]')
if git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then
echo "Tag $VERSION already exists. Skipping release steps."
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Tag $VERSION is new."
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create tag
if: steps.check_tag.outputs.exists != 'true'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git tag ${{ steps.get_version.outputs.version }}
git push origin ${{ steps.get_version.outputs.version }}
build-linux:
needs: [tag]
if: needs.tag.outputs.exists != 'true'
runs-on: ubuntu-latest
container:
image: debian:sid
steps:
- uses: actions/checkout@v4
- name: Install deps
run: |
apt update
apt install -y llvm-21 llvm-21-dev clang-21 libffi-dev pkg-config cmake g++ git libzstd-dev
- name: Generate runtime.ll
run: clang-21 -S -emit-llvm -O0 -o runtime.ll runtime.cpp
- name: Build (Linux)
run: |
cmake -DCMAKE_BUILD_TYPE=Release .
cmake --build . -j$(nproc)
mv qc qc-linux
- name: Upload Linux Binary
uses: actions/upload-artifact@v4
with:
name: qc-linux
path: qc-linux
build-macos:
needs: [tag]
if: needs.tag.outputs.exists != 'true'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
brew install llvm@21 libffi cmake
echo "LLVM_DIR=$(brew --prefix llvm@21)/lib/cmake/llvm" >> $GITHUB_ENV
echo "$(brew --prefix llvm@21)/bin" >> $GITHUB_PATH
- name: Generate runtime.ll
run: clang -S -emit-llvm -O0 -I$(brew --prefix libffi)/include -o runtime.ll runtime.cpp
- name: Build (macOS)
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR=$LLVM_DIR .
cmake --build . -j$(sysctl -n hw.logicalcpu)
mv qc qc-macos
- name: Upload macOS Binary
uses: actions/upload-artifact@v4
with:
name: qc-macos
path: qc-macos
upload-extras:
needs: [tag]
if: needs.tag.outputs.exists != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Upload stdlib
uses: actions/upload-artifact@v4
with:
name: stdlib.qc
path: stdlib.qc
- name: Upload syntax
uses: actions/upload-artifact@v4
with:
name: syntax.qc
path: syntax.qc
- name: Upload test
uses: actions/upload-artifact@v4
with:
name: test.qc
path: test.qc
build-wasm:
runs-on: ubuntu-latest
needs: ['tag']
steps:
- uses: actions/checkout@v4
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v13
with:
version: 'latest'
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y \
cmake ninja-build git \
zlib1g-dev libffi-dev libxml2-dev libedit-dev libzstd-dev
- name: Restore LLVM cache
id: cache-llvm
uses: actions/cache/restore@v4
with:
path: llvm-install
key: llvm-wasm-${{ runner.os }}-21
- name: Build LLVM To WASM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
git clone --depth 1 https://github.com/llvm/llvm-project.git
cd llvm-project
emcmake cmake -S llvm -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/llvm-install \
-DLLVM_TARGETS_TO_BUILD="WebAssembly" \
-DLLVM_ENABLE_PROJECTS="" \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_FFI=OFF \
-DLLVM_ENABLE_ZSTD=OFF
ninja -C build -j$(nproc)
ninja -C build install
- name: Save LLVM cache
if: steps.cache-llvm.outputs.cache-hit != 'true' && success()
uses: actions/cache/save@v4
with:
path: llvm-install
key: llvm-wasm-${{ runner.os }}-21
- name: Build QuantumC (WASM)
run: |
mkdir -p build
cd build
emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR=$GITHUB_WORKSPACE/llvm-install/lib/cmake/llvm \
-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/llvm-install
emmake make -j$(nproc) VERBOSE=1
- name: Upload WASM build
uses: actions/upload-artifact@v4
with:
name: qc-wasm
path: |
build/qc.js
build/qc.wasm
build/qc.data
deploy-to-website:
needs: [build-wasm, tag]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout website repo
uses: actions/checkout@v4
with:
repository: Youg-Otricked/learnhardcode
token: ${{ secrets.PAT_TOKEN }}
path: website
- name: Download WASM artifacts
uses: actions/download-artifact@v4
with:
name: qc-wasm
path: ./wasm-files
- name: Copy WASM files to website repo
run: |
cp wasm-files/qc.js website/QuantumC/
cp wasm-files/qc.wasm website/QuantumC/
cp wasm-files/stdlib.qc website/QuantumC/stdlib.qc
cp wasm-files/qc.data website/QuantumC/
- name: Commit and push to website repo
run: |
cd website
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add QuantumC/qc.js QuantumC/qc.wasm QuantumC/stdlib.qc QuantumC/qc.data
git commit -m "Update Quantum C compiler [automated]" || echo "No changes to commit"
git push
release:
needs: [tag, build-linux, build-macos, upload-extras]
if: always() && needs.tag.outputs.exists != 'true' && needs.tag.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.tag.outputs.version }}
files: |
qc-linux/qc-linux
qc-macos/qc-macos
stdlib.qc/stdlib.qc