Skip to content

Forced rebuild of runtime.ll #221

Forced rebuild of runtime.ll

Forced rebuild of runtime.ll #221

Workflow file for this run

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/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