Skip to content

Commit

Permalink
Merge pull request #45 from FlameOfIgnis/dev-ata
Browse files Browse the repository at this point in the history
Modify build actions for better maintainability and better management
  • Loading branch information
ignis-sec authored May 17, 2021
2 parents 3ce219c + d04bc5a commit f1accbd
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 569 deletions.
18 changes: 18 additions & 0 deletions .github/action_helpers/actions_linux_python_libs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# work inside include folder
cd /opt/hostedtoolcache/Python/$1*/x64/include;

echo "Working with python$1"

# Create symlink without "m" in name
[[ -f "python$1" ]] || sudo ln -s python$1m python$1;

# copy libraries and includes to global paths
sudo cp -r /opt/hostedtoolcache/Python/$1*/x64/lib/* /usr/local/lib/;
sudo cp -r /opt/hostedtoolcache/Python/$1*/x64/include/py* /usr/include/;
sudo ln -s /usr/include/$1m /usr/include/$1;

# Create symlink without "m" in name
[[ -f "/usr/local/lib/libpython$1.so.1.0" ]] || sudo ln -s /usr/local/lib/libpython$1m.so.1.0 /usr/local/lib/libpython$1.so.1.0;
[[ -f "/usr/local/lib/libpython$1.so" ]] || sudo ln -s /usr/local/lib/libpython$1m.so /usr/local/lib/libpython$1.so;
8 changes: 8 additions & 0 deletions .github/action_helpers/actions_linux_setup_boost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz -O /home/runner/boost_1_76_0.tar.gz -q;
cd /home/runner/;
tar -xf /home/runner/boost_1_76_0.tar.gz;
cd /home/runner/boost_1_76_0/;
./bootstrap.sh --with-python=$(which python$1) --with-python-version=$1;
sudo ./b2 --with-python --with-program_options stage;
4 changes: 4 additions & 0 deletions .github/action_helpers/actions_linux_setup_libboost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sudo cp -r /home/runner/boost_1_76_0/stage/lib/* /usr/local/lib;
sudo cp -r /home/runner/boost_1_76_0/boost /usr/include/boost;
17 changes: 17 additions & 0 deletions .github/action_helpers/actions_windows_libboost.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

param (
[string]$pythonver = "3.8"
)

$a = $pythonver.substring(0,1)
$b = $pythonver.substring(2,1)
echo "$a$b"

echo $env:RUNNER_WORKSPACE
mkdir $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\lib
dir $env:GITHUB_ACTION_WIN_PROJECT\boost;
cp $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\x64\Release\lib\boost_program_options.dll $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\lib\boost_program_options-vc142-mt-x64-1_76.dll;
cp $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\x64\Release\lib\boost_program_options.lib $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\lib\boost_program_options-vc142-mt-x64-1_76.lib;

cp $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\x64\Release\lib\boost_python$a$b.dll $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\lib\libboost_python$a$b-vc142-mt-x64-1_76.dll;
cp $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\x64\Release\lib\boost_python$a$b.lib $env:GITHUB_ACTION_WIN_PROJECT\boost\stage\lib\libboost_python$a$b-vc142-mt-x64-1_76.lib;
14 changes: 14 additions & 0 deletions .github/action_helpers/actions_windows_libpython.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

param (
[string]$pythonver = "3.8"
)

which python;
mkdir D:\a\python$pythonver;

Copy-Item -Path $env:pythonLocation\libs -Destination "D:\a\python$pythonver" -Recurse;
Copy-Item -Path $env:pythonLocation\include -Destination "D:\a\python$pythonver" -Recurse;
dir D:\a\python$pythonver;
echo $env:pythonLocation;
dir $env:pythonLocation\include;
Remove-Item -Recurse -Force %GITHUB_ACTION_WIN_PROJECT%\boost\stage -ErrorAction Ignore;
77 changes: 77 additions & 0 deletions .github/action_helpers/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/ur/bin/python3

# This is a build script for the github workflows. You can use it for building the project too.
import argparse
import os

parser = argparse.ArgumentParser()
parser.add_argument("step", help="Step to build")
parser.add_argument("-p", "--pyversion", help="Python version to use")

args = parser.parse_args()

def decide_action_type(ref,trigger):
print(f"ref: {ref}, trigger: {trigger}")
if(ref == "refs/heads/main" and trigger == "push"):
return "minor"

elif(ref == "refs/heads/dev" and trigger == "push"):
return "patch"
elif(ref == "refs/heads/dev" and trigger == "pull_request"):
return "dev"


def set_action_outputs(**kwargs):
for key in kwargs:
val = kwargs[key]
print(f"Setting output for:{key}.")
print(f"Value: {val}")
print(f"::set-output name={key}::{val}")


if __name__ == "__main__":
print(os.environ)
ref = os.environ["GITHUB_REF"]
trigger = os.environ["GITHUB_EVENT_NAME"]
a_type = decide_action_type(ref, trigger)
print(f"Workflow configuration set to {a_type}.")


if(args.step == "version_bump"):
if(a_type == "minor"):
set_action_outputs(bump="minor", branch="main", prerelease="false", draft="false")

elif(a_type == "patch"):
set_action_outputs(bump="patch", branch="<junk>", prerelease="true", draft="false")

elif(a_type == "dev"):
set_action_outputs(bump="patch", branch="<junk>", prerelease="false", draft="true")
else:
set_action_outputs(bump="patch", branch="<junk>", prerelease="false", draft="true")

if(args.step == "version_matrix"):

if(a_type == "minor"):
lm = "[3.6, 3.7, 3.8, 3.9]"
wm = "[3.8, 3.9]"

elif(a_type == "patch"):
lm = "[3.8]"
wm = "[3.8]"

else:
lm = "[3.8]"
wm = "[3.8]"

set_action_outputs(linux_matrix=lm, windows_matrix=wm)

if(args.step == "linux_python_libs"):
os.system(f".github/action_helpers/actions_linux_python_libs.sh {args.pyversion}")

if(args.step == "linux_setup_boost"):
os.system(f".github/action_helpers/actions_linux_setup_boost.sh {args.pyversion}")

if(args.step == "linux_setup_libboost"):
os.system(f".github/action_helpers/actions_linux_setup_libboost.sh {args.pyversion}")


Loading

0 comments on commit f1accbd

Please sign in to comment.