Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .github/workflows/release-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,30 @@ jobs:
name: Package Nuget
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
submodules: "true"
- name: Download workflow artifact
uses: dawidd6/[email protected]
with:
workflow: "build-libs.yml"
path: ./libs
- uses: actions/checkout@master
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: trinsic-id/[email protected]
id: setversion
with:
githubToken: ${{ secrets.API_GITHUB_TOKEN }}
overrideVersion: ${{ github.event.inputs.packageVersion }}
- name: release-downloader
uses: robinraju/[email protected]
with:
repository: trinsic-id/okapi
latest: true
token: ${{ secrets.API_GITHUB_TOKEN }}
fileName: "libs.zip"

- name: Create Nuget package
run: |
python ../../../devops/build_sdks.py --package-version=${{ steps.setversion.outputs.packageVersion }} --language=dotnet
dotnet workload install ios
dotnet workload install maccatalyst
dotnet restore
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/release-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ jobs:
with:
java-version: '15'
distribution: 'adopt'
- name: Download workflow artifact
uses: dawidd6/[email protected]
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
workflow: "build-libs.yml"
path: ./libs
branch: main
python-version: 3.9
- uses: trinsic-id/[email protected]
id: setversion
with:
githubToken: ${{ secrets.API_GITHUB_TOKEN }}
overrideVersion: ${{ github.event.inputs.packageVersion }}
- name: release-downloader
uses: robinraju/[email protected]
with:
repository: trinsic-id/okapi
latest: true
token: ${{ secrets.API_GITHUB_TOKEN }}
fileName: "libs.zip"
- name: Publish package
run: |
python ../devops/build_sdks.py --package-version=${{ steps.setversion.outputs.packageVersion }} --language=java
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/release-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.9
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: trinsic-id/[email protected]
id: setversion
with:
githubToken: ${{ secrets.API_GITHUB_TOKEN }}
overrideVersion: ${{ github.event.inputs.packageVersion }}
- name: release-downloader
uses: robinraju/[email protected]
with:
repository: trinsic-id/okapi
latest: true
token: ${{ secrets.API_GITHUB_TOKEN }}
fileName: "libs.zip"
- name: Build, Test, Pack
run: |
python -m pip install -r requirements.txt
python -m pip install build
python ../devops/build_sdks.py --package-version=${{ github.event.inputs.packageVersion }} --language=python
python ../devops/build_sdks.py --package-version=${{ steps.setversion.outputs.packageVersion }} --language=python
python -m build --sdist --wheel --outdir dist/ .
shell: pwsh
working-directory: python
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/release-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,27 @@ jobs:
uses: ruby/[email protected]
with:
ruby-version: 2.7
- name: Download workflow artifact
uses: dawidd6/[email protected]
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
workflow: "build-libs.yml"
path: ./libs
branch: main
python-version: 3.9
- uses: trinsic-id/[email protected]
id: setversion
with:
githubToken: ${{ secrets.API_GITHUB_TOKEN }}
overrideVersion: ${{ github.event.inputs.packageVersion }}
- name: release-downloader
uses: robinraju/[email protected]
with:
repository: trinsic-id/okapi
latest: true
token: ${{ secrets.API_GITHUB_TOKEN }}
fileName: "libs.zip"
- name: Build and run tests
run: |
gem install bundler
bundle install
python ../devops/build_sdks.py --package-version=${{ github.event.inputs.packageVersion }} --language=ruby
python ../devops/build_sdks.py --package-version=${{ steps.setversion.outputs.packageVersion }} --language=ruby

mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
Expand Down
24 changes: 20 additions & 4 deletions .github/workflows/release-swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,33 @@ jobs:
- name: Checkout
uses: actions/[email protected]

- name: Download workflow artifact
uses: dawidd6/[email protected]
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
workflow: "build-libs.yml"
path: ./libs
python-version: 3.9
- uses: trinsic-id/[email protected]
id: setversion
with:
githubToken: ${{ secrets.API_GITHUB_TOKEN }}
overrideVersion: ${{ github.event.inputs.packageVersion }}
- name: release-downloader
uses: robinraju/[email protected]
with:
repository: trinsic-id/okapi
latest: true
token: ${{ secrets.API_GITHUB_TOKEN }}
fileName: "libs.zip"

- uses: trinsic-id/[email protected]
id: setversion
with:
githubToken: ${{ secrets.API_GITHUB_TOKEN }}
overrideVersion: ${{ github.event.inputs.packageVersion }}
- run: |
python ./devops/build_sdks.py --package-version=${{ steps.setversion.outputs.packageVersion }} --language=none
working-directory: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Framework
run: |
Expand Down
110 changes: 62 additions & 48 deletions devops/build_sdks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import os
import platform
import shutil
from os.path import join, abspath, dirname, isdir, split
import subprocess
from os.path import join, abspath, dirname, isdir, split, exists
from typing import Dict
from zipfile import ZipFile

try:
import requests
Expand All @@ -22,9 +23,13 @@ def parse_version_tag():
raise NotImplementedError


def get_os_arch_path(extract_dir, windows_path):
def get_libs_dir() -> str:
return abspath(join(dirname(__file__), '..', 'libs'))


def get_os_arch_path(windows_path):
copy_from = ''
libs_dir = join(extract_dir, 'libs')
libs_dir = get_libs_dir()
os_name = platform.system().lower()
processor_name = platform.machine().lower()
if os_name == 'windows':
Expand All @@ -41,28 +46,28 @@ def get_os_arch_path(extract_dir, windows_path):
return copy_from



def set_env_var(name, value):
env_file = os.getenv('GITHUB_ENV')
if env_file is None:
return
with open(env_file, "a") as file:
file.write(f"{name}={value}")


def copy_okapi_libs(copy_to: str, windows_path='windows'):
okapi_dir = abspath(join(dirname(__file__), '..'))
copy_from = get_os_arch_path(okapi_dir, windows_path)
copy_from = get_os_arch_path(windows_path)
logging.info(f"Copying okapi libs from: {copy_from}\nto: {copy_to}")

for copy_file in glob.glob(join(copy_from, '*.*')):
shutil.copy2(copy_file, copy_to)
try:
shutil.copy2(join(okapi_dir, 'libs', 'C_header', 'okapi.h'), copy_to)
shutil.copy2(join(get_libs_dir(), 'C_header', 'okapi.h'), copy_to)
except FileNotFoundError:
pass


def deep_copy_okapi_libs(copy_to: str):
copy_from = abspath(join(dirname(__file__), '..','libs'))
copy_from = abspath(join(dirname(__file__), '..', 'libs'))
logging.info(f"Copying okapi libs from: {copy_from}\nto: {copy_to}")
shutil.rmtree(copy_to, ignore_errors=True)
shutil.copytree(copy_from, copy_to)
Expand All @@ -85,7 +90,6 @@ def clean_dir(language_dir: str) -> None:
os.mkdir(language_dir)



def update_line(file_name: str, replace_lines: Dict[str, str]) -> None:
with open(file_name, 'r') as fid:
file_lines = fid.readlines()
Expand Down Expand Up @@ -120,31 +124,34 @@ def get_sdk_dir() -> str:
def build_python(args) -> None:
# Update version in setup.cfg
python_dir = get_language_dir('python')
update_line(join(python_dir, 'setup.cfg'),
{'version = ': f'version = {get_package_versions(args)}'})
update_line(join(python_dir, 'setup.cfg'), {'version = ': f'version = {get_package_versions(args)}'})
# TODO - Support ARM
copy_okapi_file(abspath(join(dirname(__file__), '..','libs','windows','okapi.dll')),abspath(join(python_dir,'libs','windows')))
copy_okapi_file(abspath(join(dirname(__file__), '..','libs','macos','libokapi.dylib')), abspath(join(python_dir,'libs','macos')))
copy_okapi_file(abspath(join(dirname(__file__), '..','libs','linux','libokapi.so')), abspath(join(python_dir,'libs','linux')))
copy_okapi_file(abspath(join(dirname(__file__), '..', 'libs', 'windows', 'okapi.dll')),
abspath(join(python_dir, 'libs', 'windows')))
copy_okapi_file(abspath(join(dirname(__file__), '..', 'libs', 'macos', 'libokapi.dylib')),
abspath(join(python_dir, 'libs', 'macos')))
copy_okapi_file(abspath(join(dirname(__file__), '..', 'libs', 'linux', 'libokapi.so')),
abspath(join(python_dir, 'libs', 'linux')))


def build_java(args) -> None:
# Update version in setup.cfg
java_dir = get_language_dir('java')
update_line(join(java_dir, 'build.gradle'),
{'def jarVersion': f'def jarVersion = "{get_package_versions(args)}"'})
update_line(join(java_dir, 'build.gradle'), {'def jarVersion': f'def jarVersion = "{get_package_versions(args)}"'})
copy_okapi_libs(abspath(join(java_dir, '..', 'libs')))


def build_ruby(args) -> None:
# Update version in setup.cfg
ruby_dir = get_language_dir('ruby')
update_line(join(ruby_dir, 'lib', 'version.rb'),
{' VERSION =': f" VERSION = '{get_package_versions(args)}'"})
update_line(join(ruby_dir, 'lib', 'version.rb'), {' VERSION =': f" VERSION = '{get_package_versions(args)}'"})
# TODO - Support Ruby on ARM
copy_okapi_file(abspath(join(dirname(__file__), '..','libs','windows','okapi.dll')),abspath(join(ruby_dir,'libs','windows')))
copy_okapi_file(abspath(join(dirname(__file__), '..','libs','macos','libokapi.dylib')), abspath(join(ruby_dir,'libs','macos')))
copy_okapi_file(abspath(join(dirname(__file__), '..','libs','linux','libokapi.so')), abspath(join(ruby_dir,'libs','linux')))
copy_okapi_file(abspath(join(dirname(__file__), '..', 'libs', 'windows', 'okapi.dll')),
abspath(join(ruby_dir, 'libs', 'windows')))
copy_okapi_file(abspath(join(dirname(__file__), '..', 'libs', 'macos', 'libokapi.dylib')),
abspath(join(ruby_dir, 'libs', 'macos')))
copy_okapi_file(abspath(join(dirname(__file__), '..', 'libs', 'linux', 'libokapi.so')),
abspath(join(ruby_dir, 'libs', 'linux')))


def build_golang(args) -> None:
Expand Down Expand Up @@ -174,11 +181,8 @@ def build_java_docs(args):
# https://github.com/fchastanet/groovydoc-to-markdown
# npm install in the root of sdk
subprocess.Popen(
[
'node', './node_modules/groovydoc-to-markdown/src/doc2md.js',
'./java', 'java', './docs/reference/java'
], cwd=get_sdk_dir()
).wait()
['node', './node_modules/groovydoc-to-markdown/src/doc2md.js', './java', 'java', './docs/reference/java'],
cwd=get_sdk_dir()).wait()


def build_dotnet_docs(args) -> None:
Expand All @@ -188,37 +192,28 @@ def build_dotnet_docs(args) -> None:
output_doc_folder = './docs/reference/dotnet'
clean_dir(abspath(join(get_sdk_dir(), output_doc_folder)))
subprocess.Popen(
[
"defaultdocumentation",
"--AssemblyFilePath", assembly_file,
"--OutputDirectoryPath", output_doc_folder,
"--FileNameMode", "Name",
"--GeneratedPages", "Namespaces",
],
cwd=get_sdk_dir()
).wait()
["defaultdocumentation", "--AssemblyFilePath", assembly_file, "--OutputDirectoryPath", output_doc_folder,
"--FileNameMode", "Name", "--GeneratedPages", "Namespaces", ], cwd=get_sdk_dir()).wait()


def build_go_docs(args):
# https://github.com/posener/goreadme
# go get github.com/posener/goreadme/cmd/goreadme
goreadme_args = ['-recursive', '-functions', '-methods', '-types', '-variabless'] # Yes, that's a duplicated s, it's on purpose.
goreadme_args = ['-recursive', '-functions', '-methods', '-types',
'-variabless'] # Yes, that's a duplicated s, it's on purpose.
doc_path = abspath(join(get_language_dir('docs'), 'reference', 'go'))

def write_doc_file(input_path: str, output_file: str):
logging.info(f"goreadme(input={input_path}, output={output_file})")
print(f"goreadme(input={input_path}, output={output_file})")
with open(join(doc_path, f'{output_file}.md'), 'w') as output:
subprocess.Popen(
['goreadme', *goreadme_args],
cwd=input_path, stdout=output
).wait()
subprocess.Popen(['goreadme', *goreadme_args], cwd=input_path, stdout=output).wait()
# Handle the subdirectories
for sub_folder in glob.glob(join(input_path, '**')):
if isdir(sub_folder):
_, folder_name = split(sub_folder)
write_doc_file(sub_folder, folder_name)

write_doc_file(get_language_dir('go'), 'index')


Expand All @@ -229,24 +224,43 @@ def parse_arguments():
return parser.parse_args()


def extract_libs_zip():
# Look for a libs.zip file to extract
libs_zip = abspath(join(dirname(__file__), '..', 'libs.zip'))
if exists(libs_zip):
print(f'Found released zip binary, extracting...')
with ZipFile(libs_zip) as zip_ref:
zip_ref.extractall(abspath(join(dirname(__file__), '..')))


def continue_on_error(fcn, args) -> None:
try:
fcn(args)
except Exception as e:
print(e)


def main():
# Get command line arguments
args = parse_arguments()
langs_to_build = [lang.lower() for lang in (args.language + ',').split(',')]
build_all = 'all' in langs_to_build

extract_libs_zip()

# Update version information
if build_all or 'python' in langs_to_build:
build_python(args)
continue_on_error(build_python, args)
if build_all or 'java' in langs_to_build:
build_java(args)
continue_on_error(build_java, args)
if build_all or 'ruby' in langs_to_build:
build_ruby(args)
continue_on_error(build_ruby, args)
if build_all or 'golang' in langs_to_build:
build_golang(args)
continue_on_error(build_golang, args)
if build_all or 'docs' in langs_to_build:
build_java_docs(args)
build_go_docs(args)
build_dotnet_docs(args)
continue_on_error(build_java_docs, args)
continue_on_error(build_go_docs, args)
continue_on_error(build_dotnet_docs, args)


if __name__ == "__main__":
Expand Down
Loading