Skip to content

Commit 7fb4bd4

Browse files
Feat: Adding tag release build yaml
1 parent a8e0c9c commit 7fb4bd4

File tree

1 file changed

+202
-0
lines changed

1 file changed

+202
-0
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: zkLLVM Tag Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Tag to create releases for'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build:
13+
env:
14+
GH_TOKEN: ${{ secrets.GNUS_TOKEN_1 }}
15+
runs-on: ${{matrix.host}}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
target: [Android, iOS, OSX, Linux, Windows]
20+
build-type: [Release]
21+
abi: [""]
22+
include:
23+
- target: Android
24+
host: ubuntu-22.04
25+
abi: arm64-v8a
26+
build-type: Release
27+
- target: Android
28+
host: ubuntu-22.04
29+
abi: armeabi-v7a
30+
build-type: Release
31+
- target: iOS
32+
host: macos-latest
33+
- target: OSX
34+
host: macos-latest
35+
- target: Linux
36+
host: ubuntu-22.04
37+
abi: x86_64
38+
build-type: Release
39+
- target: Linux
40+
host: ubuntu-24.04-arm
41+
abi: aarch64
42+
build-type: Release
43+
- target: Windows
44+
host: windows-latest
45+
exclude:
46+
- target: Android
47+
abi: ""
48+
- target: Linux
49+
abi: ""
50+
steps:
51+
- name: Configure Linux host
52+
if: ${{ runner.os == 'Linux'}}
53+
run: |
54+
sudo update-alternatives --install /usr/bin/cc cc $(which clang) 100
55+
sudo update-alternatives --install /usr/bin/c++ c++ $(which clang++) 100
56+
sudo update-alternatives --set cc $(which clang)
57+
sudo update-alternatives --set c++ $(which clang++)
58+
59+
sudo apt install ccache ninja-build -y
60+
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
61+
62+
- name: Configure Windows host
63+
if: ${{ runner.os == 'Windows'}}
64+
run: |
65+
choco install ccache -y
66+
67+
- name: Configure macOS host
68+
if: ${{ runner.os == 'macOS'}}
69+
run: |
70+
brew install ccache ninja bash
71+
PATH="$HOMEBREW_PREFIX/opt/gnu-tar/libexec/gnubin:$PATH"
72+
echo "PATH=$PATH" >> $GITHUB_ENV
73+
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
74+
75+
- name: Add Android toolchain
76+
if: ${{ matrix.target == 'Android' }}
77+
run: |
78+
NDK_VERSION="r27b"
79+
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip -O ndk.zip
80+
unzip ndk.zip -d $HOME
81+
82+
echo "ANDROID_NDK_HOME=$HOME/android-ndk-$NDK_VERSION" >> $GITHUB_ENV
83+
84+
- name: Checkout
85+
uses: actions/checkout@v4
86+
with:
87+
path: zkLLVM
88+
submodules: "recursive"
89+
ref: ${{ github.event.inputs.tag }}
90+
91+
- name: Set build directory
92+
run: |
93+
if [ '${{matrix.abi}}' ]; then
94+
BUILD_DIRECTORY=${{matrix.build-type}}/${{matrix.abi}}
95+
else
96+
BUILD_DIRECTORY=${{matrix.build-type}}
97+
fi
98+
99+
echo "SOURCE_DIRECTORY=build/${{matrix.target}}" >> $GITHUB_ENV
100+
echo "BUILD_DIRECTORY=$BUILD_DIRECTORY" >> $GITHUB_ENV
101+
shell: bash
102+
103+
- name: Download thirdparty release
104+
working-directory: ${{github.workspace}}
105+
run: |
106+
TAG_NAME="${{ github.event.inputs.tag }}"
107+
echo "Building for tag: ${TAG_NAME}"
108+
109+
if [ '${{matrix.abi}}' ]; then
110+
FILE_NAME=${{matrix.target}}-${{matrix.abi}}-${{matrix.build-type}}.tar.gz
111+
else
112+
FILE_NAME=${{matrix.target}}-${{matrix.build-type}}.tar.gz
113+
fi
114+
echo "FILE_NAME=${FILE_NAME}" >> $GITHUB_ENV
115+
116+
mkdir thirdparty
117+
cd thirdparty
118+
119+
# Download from the tag's release
120+
echo "Downloading thirdparty from tag: ${TAG_NAME}"
121+
122+
gh release download ${TAG_NAME} --repo GeniusVentures/thirdparty -p "${FILE_NAME}"
123+
tar -zxf "${FILE_NAME}" ${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}}/boost
124+
shell: bash
125+
126+
- name: Configure CMake for Android
127+
if: ${{ matrix.target == 'Android'}}
128+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}
129+
run: cmake -B ${{env.BUILD_DIRECTORY}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_C_STANDARD=17 -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty/${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}} -DANDROID_ABI=${{matrix.abi}} -DCMAKE_ANDROID_NDK=${ANDROID_NDK_HOME}
130+
131+
- name: Configure CMake for iOS
132+
if: ${{ matrix.target == 'iOS'}}
133+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}
134+
run: cmake -B ${{env.BUILD_DIRECTORY}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_C_STANDARD=17 -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty/${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}} -DPLATFORM=OS64
135+
136+
- name: Configure CMake for Mac
137+
if: ${{ matrix.target == 'OSX'}}
138+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}
139+
run: cmake -B ${{env.BUILD_DIRECTORY}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_C_STANDARD=17 -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty/${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}} -DPLATFORM=MAC_UNIVERSAL
140+
141+
- name: Configure CMake for Linux
142+
if: ${{ matrix.target == 'Linux' }}
143+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}
144+
run: cmake -B ${{env.BUILD_DIRECTORY}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_C_STANDARD=17 -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty/${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}} -DABI_SUBFOLDER_NAME='/${{matrix.abi}}'
145+
146+
- name: Configure CMake for Windows
147+
if: ${{ matrix.target == 'Windows' }}
148+
working-directory: ${{github.workspace}}\zkLLVM
149+
run: |
150+
cd ${{env.SOURCE_DIRECTORY}}
151+
cmake -B ${{env.BUILD_DIRECTORY}} -DCMAKE_BUILD_TYPE=${{matrix.build-type}} -DCMAKE_C_STANDARD=17 -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}\thirdparty/${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}} -G "Visual Studio 17 2022" -A x64
152+
153+
- name: Build
154+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}
155+
run: cmake --build ${{env.BUILD_DIRECTORY}} --config ${{matrix.build-type}} -j
156+
157+
- name: Install
158+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}
159+
run: cmake --install ${{env.BUILD_DIRECTORY}}
160+
161+
- name: Create or check release
162+
shell: bash
163+
run: |
164+
TAG_NAME='${{ github.event.inputs.tag }}'
165+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
166+
167+
echo "Checking if GitHub release exists for tag: $TAG_NAME"
168+
169+
set +e
170+
gh release view $TAG_NAME
171+
releaseFound=$?
172+
set -e
173+
174+
if [[ $releaseFound -ne 0 ]]; then
175+
echo "Release not found, creating for tag: $TAG_NAME"
176+
177+
# Create a single release for the tag
178+
gh release create $TAG_NAME \
179+
-n "Build artifacts for tag ${TAG_NAME}" \
180+
-t "${TAG_NAME} build artifacts"
181+
else
182+
echo "Release already exists for tag: $TAG_NAME"
183+
fi
184+
185+
- name: Compress build artifacts
186+
working-directory: ${{github.workspace}}/zkLLVM/${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}}
187+
shell: bash
188+
run: |
189+
tar -czvf ${FILE_NAME} \
190+
--exclude='zkLLVM/src' \
191+
--exclude='zkLLVM/tmp' \
192+
--transform 's|^|${{env.SOURCE_DIRECTORY}}/${{env.BUILD_DIRECTORY}}/|S' \
193+
zkLLVM
194+
195+
mv ${FILE_NAME} "${{github.workspace}}/zkLLVM/${FILE_NAME}"
196+
197+
- name: Release file
198+
working-directory: ${{github.workspace}}/zkLLVM
199+
shell: bash
200+
run: |
201+
echo -e "Uploading ${FILE_NAME} to release ${TAG_NAME}"
202+
gh release upload --clobber ${TAG_NAME} ${FILE_NAME}

0 commit comments

Comments
 (0)