Skip to content
Snippets Groups Projects
Commit 8e83c1ad authored by Timothee Besset's avatar Timothee Besset
Browse files

CI: add deploy stage

parent e9b3a07a
Branches
Tags
No related merge requests found
......@@ -3,15 +3,32 @@ variables:
stages:
- build
- deploy
build-linux:
stage: build
tags:
- linux
script: ./setup/gitlab-linux.py
artifacts:
paths:
- artifacts/
build-windows:
stage: build
tags:
- windows
script: ./setup/gitlab-windows.py
artifacts:
paths:
- artifacts/
deploy:
stage: deploy
when: manual
needs:
- build-linux
- build-windows
tags:
- linux
script: ./setup/gitlab-deploy.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import os
import stat
import subprocess
import glob
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
STEAMOS_DEVKIT_CI_UPLOAD_HOST=os.environ.get('STEAMOS_DEVKIT_CI_UPLOAD_HOST')
STEAMOS_DEVKIT_CI_UPLOAD_PATH=os.environ.get('STEAMOS_DEVKIT_CI_UPLOAD_PATH')
STEAMOS_DEVKIT_CI_UPLOAD_SSH_PRIVATE_KEY_FILE=os.environ.get('STEAMOS_DEVKIT_CI_UPLOAD_SSH_PRIVATE_KEY_FILE')
STEAMOS_DEVKIT_CI_UPLOAD_USER=os.environ.get('STEAMOS_DEVKIT_CI_UPLOAD_USER')
if __name__ == '__main__':
os.chmod(STEAMOS_DEVKIT_CI_UPLOAD_SSH_PRIVATE_KEY_FILE, stat.S_IREAD)
version_tag = subprocess.check_output(['git', 'describe'], cwd=ROOT_DIR, universal_newlines=True).strip()
print(f'Deploy version: {version_tag}')
src_dir = os.path.join(ROOT_DIR, 'artifacts')
dst_dir = os.path.join(STEAMOS_DEVKIT_CI_UPLOAD_PATH, version_tag)
latest_dir = os.path.join(STEAMOS_DEVKIT_CI_UPLOAD_PATH, 'latest')
cmd = f'rsync -rv -e "ssh -o StrictHostKeyChecking=no -i {STEAMOS_DEVKIT_CI_UPLOAD_SSH_PRIVATE_KEY_FILE}" {src_dir}/ {STEAMOS_DEVKIT_CI_UPLOAD_USER}@{STEAMOS_DEVKIT_CI_UPLOAD_HOST}:{dst_dir}'
print(cmd)
subprocess.check_call(cmd, shell=True)
cmd = f'ssh -o StrictHostKeyChecking=no -i {STEAMOS_DEVKIT_CI_UPLOAD_SSH_PRIVATE_KEY_FILE} {STEAMOS_DEVKIT_CI_UPLOAD_USER}@{STEAMOS_DEVKIT_CI_UPLOAD_HOST} /bin/bash -c "cd {STEAMOS_DEVKIT_CI_UPLOAD_PATH} ; rm -f latest ; ln -s {version_tag} latest"'
print(cmd)
subprocess.check_call(cmd, shell=True)
......@@ -6,8 +6,10 @@ import os
import subprocess
import tempfile
import shutil
import glob
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
ARTIFACTS_DIR = os.path.join(ROOT_DIR, 'artifacts')
assert sys.platform == 'linux'
assert sys.prefix == sys.base_prefix # executed at build VM OS level
......@@ -19,6 +21,7 @@ def call(cmd, cwd):
print(f'END CMD: {cmd}')
if __name__ == '__main__':
os.makedirs(ARTIFACTS_DIR, exist_ok=True)
for python_minor in (9, 10):
build_dir = os.path.abspath(os.path.join(ROOT_DIR, f'../steamos-devkit-py3{python_minor}'))
interpreter = f'python3.{python_minor}'
......@@ -38,4 +41,10 @@ if __name__ == '__main__':
pipenv_cmd = f'{interpreter} -m pipenv run'
call(f'{pipenv_cmd} pip install pyimgui-wheels/imgui-2.0.0-cp3{python_minor}-cp3{python_minor}-linux_x86_64.whl', build_dir)
call(f'{pipenv_cmd} {interpreter} ./setup/package-linux.py', build_dir)
g = glob.glob(f'{build_dir}/devkit-gui*.pyz')
if len(g) != 1:
raise Exception('No .pyz build artifact produced? Aborting')
artifact = g[0]
print(f'copy {artifact} -> {ARTIFACTS_DIR}')
shutil.copyfile(artifact, os.path.join(ARTIFACTS_DIR, os.path.basename(artifact)))
......@@ -7,6 +7,7 @@ import subprocess
import shutil
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
PACKAGE_FILE = 'devkit-gui-win64.zip'
assert sys.platform == 'win32'
assert sys.prefix == sys.base_prefix # executed at build VM OS level
......@@ -24,4 +25,9 @@ if __name__ == '__main__':
call(f'{pip} install --upgrade setuptools')
call(f'{pip} install -r requirements.txt')
call(rf'{pip} install .\pyimgui-wheels\imgui-2.0.0-cp310-cp310-win_amd64.whl')
call(rf'{interpreter} .\setup\package-windows.py')
\ No newline at end of file
call(rf'{interpreter} .\setup\package-windows.py')
if not os.path.exists(PACKAGE_FILE):
raise Exception(f'{PACKAGE_FILE} not found')
os.makedirs('artifacts', exist_ok=True)
# copy to an artifacts/ file, consistent with the linux build
shutil.copyfile(PACKAGE_FILE, os.path.join('artifacts', PACKAGE_FILE))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment