Skip to content

Commit

Permalink
Update buildscript
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Apr 5, 2021
1 parent 707fb64 commit 5e0c0a4
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 141 deletions.
131 changes: 112 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,28 @@ jobs:
with:
fetch-depth: 1

- name: Build
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
run: OS_NAME="osx" ./make.sh ghactions build
- name: Build
run: |
./make.sh buildMac
./build/tests/base.darwin
mkdir -p deploy/
tar -C build/lib/ -czf deploy/libs-mac.tar.gz .
tar -C build/tests/ -czf deploy/tests-mac.tar.gz .
- name: Upload libs
uses: actions/upload-artifact@v2
with:
name: libs-mac
path: deploy/libs-mac.tar.gz

- name: Upload tests
uses: actions/upload-artifact@v2
with:
name: tests-mac
path: deploy/tests-mac.tar.gz

BuildLinux:
name: Build vhacd for linux
BuildLinuxWindows:
name: Build vhacd for linux and Windows
runs-on: ubuntu-latest
container:
image: riccardoblb/buildenvs:javacross
Expand All @@ -40,17 +52,79 @@ jobs:
- name: Prepare
run: apt-get install -y g++-multilib

- name: Build
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
run: OS_NAME="linux" ./make.sh ghactions build
- name: Build
run: |
./make.sh buildLinux32
./make.sh buildLinux64
./make.sh buildWindows32
./make.sh buildWindows64
./build/tests/base.linux.x86-64
mkdir -p deploy/
tar -C build/lib/ -czf deploy/libs-winLinux.tar.gz .
tar -C build/tests/ -czf deploy/tests-winLinux.tar.gz .
- name: Upload libs
uses: actions/upload-artifact@v2
with:
name: libs-winLinux
path: deploy/libs-winLinux.tar.gz

- name: Upload tests
uses: actions/upload-artifact@v2
with:
name: tests-winLinux
path: deploy/tests-winLinux.tar.gz

Release:
name: Build release
needs: [BuildLinuxWindows,BuildMac]
runs-on: ubuntu-latest

steps:
- name: Clone the repo
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Prepare java
uses: actions/setup-java@v1
with:
java-version: '8' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64

- name: Download linux and windows libs
uses: actions/download-artifact@v2
with:
name: libs-winLinux
path: deploy/

- name: Download mac libs
uses: actions/download-artifact@v2
with:
name: libs-mac
path: deploy/

- name: Build java binds
run: |
mkdir -p build/lib/
tar -xzf deploy/libs-winLinux.tar.gz -C build/lib/
tar -xzf deploy/libs-mac.tar.gz -C build/lib/
./make.sh buildJavaBindings
`which java` -cp ./build/tests/base.jar Main
- name: Upload release
uses: actions/upload-artifact@v2
with:
name: release
path: build/release

Deploy:
name: Deploy vhacd
needs: [BuildLinux,BuildMac]
name: Deploy
needs: [Release]
runs-on: ubuntu-latest

steps:
Expand All @@ -59,9 +133,28 @@ jobs:
with:
fetch-depth: 1

- name: Download release
uses: actions/download-artifact@v2
with:
name: release
path: build/release

- name: Deploy to github registry
if: github.event_name == 'release'
run: |
source make.sh
mkdir -p deploy/vhacd/vhacd-native/$VERSION
mv build/release/* deploy/vhacd/vhacd-native/$VERSION
cd deploy/
set -e
files="`find . \( -name "*.jar" -o -name "*.pom" \) -type f -print`"
set -f
for art in $files; do
file="${art:2}"
dest="https://maven.pkg.github.com/$GITHUB_REPOSITORY/$file"
echo "Upload $file to $dest"
curl -X PUT $dest -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --upload-file $file -vvv
done
- name: Deploy
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
run: OS_NAME="linux" ./make.sh ghactions deploy
138 changes: 16 additions & 122 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
set -e
set -o xtrace

VERSION="1.1"
if [ "$VERSION" = "" -a "$GITHUB_REF" != "" ];
then
export VERSION="`if [[ $GITHUB_REF == refs\/tags* ]]; then echo ${GITHUB_REF//refs\/tags\//}; fi`"
if [ "$VERSION" = "" ];
then
branch="${GITHUB_REF//refs\/heads\//}"
export VERSION="$branch-SNAPSHOT"
fi
else
VERSION="1.1"
fi

DEPLOY="false"
mkdir -p build
mkdir -p build/tests
Expand Down Expand Up @@ -346,123 +357,6 @@ function buildMac {
}


function ghactions {
echo "Configure for github actions"
if [[ $GITHUB_REF == refs\/tags* ]];
then
export TRAVIS_TAG="${GITHUB_REF//refs\/tags\//}"
fi
export TRAVIS_COMMIT="${GITHUB_SHA}"
export TRAVIS_OS_NAME="$OS_NAME"

DEPLOY="false"
VERSION=$TRAVIS_COMMIT
if [ "$TRAVIS_TAG" != "" ];
then
echo "Deploy for $TRAVIS_TAG."
VERSION=$TRAVIS_TAG
DEPLOY="true"
fi

echo "Run ghactions $1"
if [ "$1" = "deploy" ];
then
if [ "$DEPLOY" != "true" ];
then
exit 0
fi

rm -Rf deploy
mkdir -p deploy/

out=`curl -u$BINTRAY_USER:$BINTRAY_API_KEY --silent --head --write-out '%{http_code}' -o deploy/tmpl.tar.gz.h https://dl.bintray.com/riccardo/vhacd-natives-files/$VERSION/libs-winLinux-$VERSION.tar.gz`
if [ "$out" != "200" ];
then
echo "[warning] Windows and Linux libs not found. Skip deploy."
exit 0
fi

out=`curl -u$BINTRAY_USER:$BINTRAY_API_KEY --silent --head --write-out '%{http_code}' -o deploy/tmpm.tar.gz.h https://dl.bintray.com/riccardo/vhacd-natives-files/$VERSION/libs-mac-$VERSION.tar.gz`
if [ "$out" != "200" ];
then
echo "[warning] Mac libs not found. Skip deploy."
exit 0
fi

curl -u$BINTRAY_USER:$BINTRAY_API_KEY --silent -o deploy/tmpl.tar.gz https://dl.bintray.com/riccardo/vhacd-natives-files/$VERSION/libs-winLinux-$VERSION.tar.gz

curl -u$BINTRAY_USER:$BINTRAY_API_KEY --silent -o deploy/tmpm.tar.gz https://dl.bintray.com/riccardo/vhacd-natives-files/$VERSION/libs-mac-$VERSION.tar.gz

echo "Deploy!"

rm -Rf buid/tests/
mkdir -p build/tests
mkdir -p build/lib/

tar -xzf deploy/tmpl.tar.gz -C build/lib/
tar -xzf deploy/tmpm.tar.gz -C build/lib/

buildJavaBindings
`which java` -cp ./build/tests/base.jar Main

curl -X PUT -T build/release/vhacd-native-$VERSION.jar -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/v-hacd/v-hacd-java-bindings/$VERSION/vhacd/vhacd-native/$VERSION/"

curl -X PUT -T build/release/vhacd-native-$VERSION.pom -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/v-hacd/v-hacd-java-bindings/$VERSION/vhacd/vhacd-native/$VERSION/"

curl -X PUT -T build/release/vhacd-native-$VERSION-sources.jar -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/v-hacd/v-hacd-java-bindings/$VERSION/vhacd/vhacd-native/$VERSION/"

tar -czf deploy/tests-java-$VERSION.tar.gz build/tests/*
curl -X PUT -T deploy/tests-java-$VERSION.tar.gz -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/vhacd-natives-files/tests/$VERSION/$VERSION/"

else
if [ "$TRAVIS_OS_NAME" = "linux" ];
then
buildLinux32
buildLinux64
buildWindows32
buildWindows64
./build/tests/base.linux.x86-64
if [ "$DEPLOY" = "true" ];
then
mkdir -p deploy/
tar -C build/lib/ -czf deploy/libs-winLinux-$VERSION.tar.gz .
tar -C build/tests/ -czf deploy/tests-winLinux-$VERSION.tar.gz .
curl -X PUT -T deploy/libs-winLinux-$VERSION.tar.gz -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/vhacd-natives-files/libs/$VERSION/$VERSION/"
curl -X PUT -T deploy/tests-winLinux-$VERSION.tar.gz -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/vhacd-natives-files/tests/$VERSION/$VERSION/"
else
buildJavaBindings
`which java` -cp ./build/tests/base.jar Main
fi
fi
if [ "$TRAVIS_OS_NAME" = "osx" ];
then
buildMac
./build/tests/base.darwin
if [ "$DEPLOY" = "true" ];
then
mkdir -p deploy/
tar -C build/lib/ -czf deploy/libs-mac-$VERSION.tar.gz .
tar -C build/tests/ -czf deploy/tests-mac-$VERSION.tar.gz .
curl -X PUT -T deploy/libs-mac-$VERSION.tar.gz -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/vhacd-natives-files/libs/$VERSION/$VERSION/"
curl -X PUT -T deploy/tests-mac-$VERSION.tar.gz -u$BINTRAY_USER:$BINTRAY_API_KEY\
"https://api.bintray.com/content/riccardo/vhacd-natives-files/tests/$VERSION/$VERSION/"
else
buildJavaBindings
`which java` -cp ./build/tests/base.jar Main
fi
fi
fi
}



function buildAll {
buildLinux32
buildLinux64
Expand All @@ -476,8 +370,8 @@ if [ "$1" = "" ];
then
echo "Usage: make.sh target"
echo " - Targets: buildAll,buildWindows32,buildWindows64,buildLinux32,buildLinux64,buildJavaBindings,clean"
exit 0
else
clr_magenta "Run $@..."
$@
clr_magenta "Build complete, results are stored in $PWD/build/"
fi
clr_magenta "Run $@..."
$@
clr_magenta "Build complete, results are stored in $PWD/build/"

0 comments on commit 5e0c0a4

Please sign in to comment.