-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add
protoc
binary generation scripts and GH workflow
- Loading branch information
1 parent
c1ff79e
commit 7b63ea5
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Generate protoc binaries | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'protoc/*.go' | ||
- 'protoc/include/**/*.proto' | ||
- 'scripts/gen-protoc' | ||
- 'scripts/data/gen-protoc/**' | ||
|
||
jobs: | ||
gen-protoc: | ||
name: "Generate protoc binaries" | ||
runs-on: ${{ matrix.runner.runs-on }} | ||
concurrency: gen-protoc-${{ matrix.runner.os }}-${{ matrix.runner.arch }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runner: | ||
- runs-on: ubuntu-latest | ||
os: linux | ||
defaults-shell: bash | ||
arch: amd64 | ||
- runs-on: [ self-hosted, linux, arm64 ] | ||
os: linux | ||
defaults-shell: bash | ||
arch: arm64 | ||
- runs-on: macos-10.15 # building it at the latest version breaks compability for older versions | ||
os: darwin | ||
defaults-shell: /bin/bash -l {0} | ||
arch: amd64 | ||
- runs-on: [ self-hosted, macOS ] | ||
os: darwin | ||
defaults-shell: /usr/bin/arch -arch arm64e /bin/bash -l {0} | ||
arch: arm64 | ||
defaults: | ||
run: | ||
shell: ${{ matrix.runner.defaults-shell }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- run: | | ||
if [[ "${{ matrix.runner.os }}" == "darwin" ]]; then | ||
brew install jq autoconf automake libtool | ||
else | ||
sudo apt install -y jq autoconf automake libtool curl make g++ unzip | ||
fi | ||
- name: Build protoc files | ||
run: ./scripts/gen-protoc | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
title: "feat(protoc): update binaries ${{ matrix.runner.os }}-${{ matrix.runner.arch }}" | ||
commit-message: "feat(protoc): update binaries ${{ matrix.runner.os }}-${{ matrix.runner.arch }}" | ||
body: "" | ||
branch: feat/gen-protoc-${{ matrix.runner.os }}-${{ matrix.runner.arch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v3.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v3.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v3.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v3.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
# Downloads latest protoc source, builds it and puts them in the right place | ||
|
||
set -e | ||
|
||
[[ $(command -v curl) ]] || { echo "'curl' not found!" ; dep_check="false" ;} | ||
[[ $(command -v wget) ]] || { echo "'wget' not found!" ; dep_check="false" ;} | ||
[[ $(command -v unzip) ]] || { echo "'unzip' not found!" ; dep_check="false" ;} | ||
|
||
# Build tools | ||
[[ $(command -v make) ]] || { echo "'make' not found!" ; dep_check="false" ;} | ||
[[ $(command -v automake) ]] || { echo "'automake' not found!" ; dep_check="false" ;} | ||
|
||
[[ ${dep_check} = "false" ]] && { echo "Some dependencie(s) isn't installed yet. Please install that dependencie(s)" ; exit 1 ;} | ||
|
||
gh_protoc_release_url="https://api.github.com/repos/protocolbuffers/protobuf/releases/latest" | ||
setdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" # this line powered by stackoverflow | ||
kernelname="$(uname -s | tr '[:upper:]' '[:lower:]' || { echo 'kernel name can not defined' ; exit 1 ;})" | ||
machinetype=$(uname -m) | ||
case $machinetype in | ||
"x86_64") arch="amd64" | ||
;; | ||
"aarch64") arch="arm64" | ||
;; | ||
"arm64") arch="arm64" | ||
;; | ||
*) echo "$machinetype is not supported"; exit 1; | ||
;; | ||
esac | ||
fname=protoc-$kernelname-$arch | ||
|
||
# Check dir else create save dir | ||
if [[ $(basename "${setdir}") = "scripts" ]] ; then | ||
if [[ $(basename "$(dirname "${setdir}")") != "ignite-files" ]] ; then | ||
echo "Attention: you are running the script out of ignite-files project please run it this script in: https://github.com/ignite/ignite-files" | ||
exit 1 | ||
fi | ||
else | ||
echo "$setdir" | ||
echo "Attention: you are running the script out of ignite-files project please run it this script in: https://github.com/ignite/ignite-files" | ||
exit 1 | ||
fi | ||
|
||
# Check if we have the newest version already | ||
version_file=$(dirname "${setdir}")/scripts/data/gen-protoc/version-"$kernelname"-"$arch" | ||
newest_version="v3.20.0" | ||
download_url="https://github.com/protocolbuffers/protobuf/releases/download/v3.20.0/protobuf-all-3.20.0.tar.gz" | ||
current_version=$(cat "$version_file") | ||
|
||
if [[ "$newest_version" == "$current_version" ]] ; then | ||
echo "Newest version already built, exiting early, all good" | ||
exit 0 | ||
fi | ||
|
||
# Check and Create Temp Directory | ||
tmpdir=$(mktemp -d) | ||
cd "$tmpdir" | ||
|
||
outputdir="$tmpdir/protocout" | ||
mkdir "$outputdir" | ||
mkdir protobuf # Where we will build | ||
|
||
# Fetch releases, go through assets (release artifacts) and find the relevant one | ||
wget -c "$download_url" -O - | tar xzC protobuf --strip-components=1 #skipping first folder | ||
|
||
# Ok, let's build! | ||
# Build instructions taken from: https://github.com/protocolbuffers/protobuf/blob/main/src/README.md | ||
cd protobuf | ||
./configure CXXFLAGS="-DNDEBUG" --prefix="$outputdir" --disable-shared # Static linked libraries so it works on all machines | ||
make clean | ||
make -j$(nproc) | ||
make install | ||
|
||
cp "$outputdir"/bin/protoc "$(dirname "${setdir}")/protoc/${fname}" | ||
|
||
cd "$(dirname "${setdir}")"/protoc && tar -czf "${fname}.tar.gz" ${fname} && rm -f ${fname} | ||
echo "$newest_version" > "$version_file" #Update version file so we don't have to rebuild this | ||
|
||
rm -rf "$tmpdir" |