Skip to content

Commit dd1d0f3

Browse files
Merge pull request #95 from yanghang8612/add_building_scripts
Add github actions scripts for building binaries
2 parents b018bcd + dea0590 commit dd1d0f3

File tree

5 files changed

+260
-0
lines changed

5 files changed

+260
-0
lines changed

.github/workflows/build.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
ROOTDIR="$(dirname "$0")/../.."
5+
# shellcheck source=scripts/common.sh
6+
source "${ROOTDIR}/scripts/common.sh"
7+
8+
prerelease_source="${1:-ga}"
9+
10+
cd "${ROOTDIR}"
11+
12+
# shellcheck disable=SC2166
13+
if [ -n "$FORCE_RELEASE" -o "$(git tag --points-at HEAD 2>/dev/null)" == tv* ]
14+
then
15+
echo -n >prerelease.txt
16+
else
17+
# Use last commit date rather than build date to avoid ending up with builds for
18+
# different platforms having different version strings (and therefore producing different bytecode)
19+
# if the CI is triggered just before midnight.
20+
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" >prerelease.txt
21+
fi
22+
23+
mkdir -p build
24+
cd build
25+
26+
# shellcheck disable=SC2086
27+
cmake .. -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" $CMAKE_OPTIONS -G "Unix Makefiles"
28+
29+
make

.github/workflows/build.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Build binaries on multi platform
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
- "release_*"
7+
8+
jobs:
9+
b_windows:
10+
runs-on: [ self-hosted, Windows ]
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v5
15+
16+
- name: Cache dependencies
17+
id: cache-deps
18+
uses: actions/cache@v4
19+
with:
20+
path: .\deps
21+
key: dependencies-win-${{ runner.arch }}-${{ hashFiles('scripts/install_deps.ps1') }}
22+
restore-keys: dependencies-win-${{ runner.arch }}-
23+
24+
- name: Installing dependencies
25+
if: steps.cache-deps.outputs.cache-hit != 'true'
26+
shell: powershell
27+
run: .\scripts\install_deps.ps1
28+
29+
- name: Run build script
30+
shell: bash
31+
run: powershell.exe .github/workflows/build_win.ps1
32+
33+
- name: Upload artifact
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: solc-windows
37+
path: build\solc\Release\solc.exe
38+
compression-level: 0
39+
40+
b_macos:
41+
runs-on: [ self-hosted, macOS ]
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v5
46+
47+
- name: Run build script
48+
run: .github/workflows/build.sh
49+
50+
- name: Upload artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: solc-macos
54+
path: build/solc/solc
55+
compression-level: 0
56+
57+
b_linux:
58+
runs-on: [ self-hosted, Linux, for-linux ]
59+
60+
env:
61+
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -DUSE_Z3_DLOPEN=ON -DUSE_CVC4=OFF -DSOLC_STATIC_STDLIBS=ON
62+
MAKEFLAGS: -j 10
63+
CPUs: 10
64+
65+
container:
66+
image: solbuildpackpusher/solidity-buildpack-deps@sha256:84a1fb8771236e8d9aa5c615a425b8929e56a6e4f150a60078c8d74a1ceaa6c2
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v5
71+
72+
- name: Fix git safe directory
73+
run: git config --global --add safe.directory '*'
74+
75+
- name: Run build script
76+
run: .github/workflows/build.sh
77+
78+
- name: Upload artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: solc-linux
82+
path: build/solc/solc
83+
compression-level: 0
84+
85+
b_ems:
86+
runs-on: [ self-hosted, Linux, for-ems ]
87+
88+
env:
89+
MAKEFLAGS: -j 10
90+
CPUs: 5
91+
92+
container:
93+
image: solbuildpackpusher/solidity-buildpack-deps@sha256:c57f2bfb8c15d70fe290629358dd1c73dc126e3760f443b54764797556b887d4
94+
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v5
98+
99+
- name: Fix git safe directory
100+
run: git config --global --add safe.directory '*'
101+
102+
- name: Run build script
103+
run: .github/workflows/build_ems.sh
104+
105+
- name: Upload artifact
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: solc-ems
109+
path: upload/soljson.js
110+
compression-level: 0
111+
112+
upload-to-s3:
113+
needs: [ b_windows, b_macos, b_linux, b_ems ]
114+
runs-on: [ self-hosted, Linux ]
115+
steps:
116+
- name: Download all artifacts
117+
uses: actions/download-artifact@v4
118+
with:
119+
path: artifacts
120+
121+
- name: List all artifacts
122+
run: |
123+
ls -R artifacts/
124+
125+
- name: Gather and rename binaries from dependent jobs
126+
run: |
127+
mkdir github/
128+
cp artifacts/solc-linux/solc github/solc-static-linux
129+
cp artifacts/solc-macos/solc github/solc-macos
130+
cp artifacts/solc-windows/solc.exe github/solc-windows.exe
131+
cp artifacts/solc-ems/soljson.js github/soljson.js
132+
133+
cd github
134+
tar --create --file ../github-binaries.tar *
135+
136+
- name: Rename binaries to solc-bin naming convention
137+
run: |
138+
full_version=$(
139+
github/solc-static-linux --version |
140+
sed -En 's/^Version: ([0-9.]+.*\+commit\.[0-9a-f]+(\.mod)?).*$/\1/p'
141+
)
142+
143+
mkdir -p solc-bin/{linux-amd64,macosx-amd64,windows-amd64,bin}
144+
145+
mv github/solc-static-linux "solc-bin/linux-amd64/solc-linux-amd64-v${full_version}"
146+
mv github/solc-macos "solc-bin/macosx-amd64/solc-macosx-amd64-v${full_version}"
147+
mv github/solc-windows.exe "solc-bin/windows-amd64/solc-windows-amd64-v${full_version}.exe"
148+
mv github/soljson.js "solc-bin/bin/soljson-v${full_version}.js"
149+
150+
cd solc-bin/
151+
tar --create --file ../solc-bin-binaries.tar *
152+
153+
- name: Upload to S3
154+
env:
155+
S3_BUCKET_PROD: ${{ secrets.S3_BUCKET_PROD }}
156+
S3_BUCKET_TEST: ${{ secrets.S3_BUCKET_TEST }}
157+
run: |
158+
case "${GITHUB_REF_NAME}" in
159+
develop) bucket="${S3_BUCKET_PROD}" ;;
160+
release_*) bucket="${S3_BUCKET_TEST}" ;;
161+
esac
162+
163+
aws s3 cp github-binaries.tar "s3://${bucket}/${{ github.sha }}/" --only-show-errors
164+
aws s3 cp solc-bin-binaries.tar "s3://${bucket}/${{ github.sha }}/" --only-show-errors

.github/workflows/build_ems.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
set -ev
3+
4+
ROOTDIR="$(dirname "$0")/../.."
5+
# shellcheck source=scripts/common.sh
6+
source "${ROOTDIR}/scripts/common.sh"
7+
8+
prerelease_source="${1:-ga}"
9+
10+
cd "${ROOTDIR}"
11+
12+
# shellcheck disable=SC2166
13+
if [[ -n "$FORCE_RELEASE" || "$(git tag --points-at HEAD 2>/dev/null)" == tv* ]]
14+
then
15+
echo -n >prerelease.txt
16+
else
17+
# Use last commit date rather than build date to avoid ending up with builds for
18+
# different platforms having different version strings (and therefore producing different bytecode)
19+
# if the CI is triggered just before midnight.
20+
TZ=UTC git show --quiet --date="format-local:%Y.%-m.%-d" --format="${prerelease_source}.%cd" >prerelease.txt
21+
fi
22+
23+
# Disable warnings for unqualified `move()` calls, introduced and enabled by
24+
# default in clang-16 which is what the emscripten docker image uses.
25+
# Additionally, disable the warning for unknown warnings here, as this script is
26+
# also used with earlier clang versions.
27+
# TODO: This can be removed if and when all usages of `move()` in our codebase use the `std::` qualifier.
28+
CMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call"
29+
30+
mkdir -p build
31+
cd build
32+
emcmake cmake \
33+
-DCMAKE_BUILD_TYPE=Release \
34+
-DBoost_USE_STATIC_LIBS=1 \
35+
-DBoost_USE_STATIC_RUNTIME=1 \
36+
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \
37+
-DTESTS=0 \
38+
..
39+
make soljson
40+
41+
cd ..
42+
mkdir -p upload
43+
scripts/ci/pack_soljson.sh "build/libsolc/soljson.js" "build/libsolc/soljson.wasm" upload/soljson.js
44+
cp upload/soljson.js ./
45+
46+
OUTPUT_SIZE=$(ls -la soljson.js)
47+
48+
echo "Emscripten output size: $OUTPUT_SIZE"

.github/workflows/build_win.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
cd "$PSScriptRoot\..\.."
4+
5+
New-Item prerelease.txt -type file
6+
Write-Host "Building release version."
7+
mkdir build
8+
cd build
9+
$boost_dir=(Resolve-Path $PSScriptRoot\..\..\deps\boost\lib\cmake\Boost-*)
10+
..\deps\cmake\bin\cmake -G "Visual Studio 17 2022" -DBoost_DIR="$boost_dir\" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_INSTALL_PREFIX="$PSScriptRoot\..\..\upload" -DUSE_Z3=OFF ..
11+
if ( -not $? ) { throw "CMake configure failed." }
12+
msbuild solidity.sln /p:Configuration=Release /m:10 /v:minimal
13+
if ( -not $? ) { throw "Build failed." }
14+
..\deps\cmake\bin\cmake --build . -j 10 --target install --config Release
15+
if ( -not $? ) { throw "Install target failed." }

.github/workflows/welcome-external-pr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
types:
66
- opened
77

8+
permissions:
9+
pull-requests: write
10+
contents: read
11+
812
env:
913
DRY_RUN: false
1014

0 commit comments

Comments
 (0)