Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update ci to support Mac and Linux #10

Merged
merged 1 commit into from
Aug 10, 2024
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
13 changes: 9 additions & 4 deletions .github/workflows/mr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ on: [ pull_request ]

jobs:
python-check:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ 'windows-2019' ]
target:
- os: 'ubuntu-22.04'
triple: 'x86_64-unknown-linux-musl-gnu'
- os: 'macos-12'
triple: 'x86_64-apple-darwin'
- os: 'windows-2022'
triple: 'x86_64-pc-windows-msvc'
python-version: ["3.10"]
fail-fast: false
runs-on: ${{ matrix.target.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -26,5 +32,4 @@ jobs:
nox -s lint
- name: test build
run: |
nox -s build-exe
build\x86_64-pc-windows-msvc\release\install\rez.exe env --help
nox -s build-exe -- --test
10 changes: 8 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ on:

jobs:
deploy:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ 'windows-2019' ]
target:
- os: 'ubuntu-22.04'
triple: 'x86_64-unknown-linux-musl-gnu'
- os: 'macos-12'
triple: 'x86_64-apple-darwin'
- os: 'windows-2022'
triple: 'x86_64-pc-windows-msvc'
python-version: ["3.10"]
fail-fast: false
runs-on: ${{ matrix.target.os }}
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
Expand Down
47 changes: 30 additions & 17 deletions nox_actions/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import os
import shutil
import subprocess
import zipfile

# Import third-party modules
Expand All @@ -15,24 +16,36 @@ def build_exe(session: nox.Session) -> None:
parser = argparse.ArgumentParser(prog="nox -s build-exe --release")
parser.add_argument("--release", action="store_true")
parser.add_argument("--version", default="0.5.0", help="Version to use for the zip file")
parser.add_argument("--test", action="store_true")
args = parser.parse_args(session.posargs)
build_root = THIS_ROOT / "build" / "x86_64-pc-windows-msvc" / "release" / "install"
build_root = THIS_ROOT / "build"
binary_name = "portable_rez.exe" if os.name == "nt" else "portable_rez"
rez_binary_name = "rez.exe" if os.name == "nt" else "rez"
session.install("pyoxidizer")
session.run("pyoxidizer", "build", "install", "--path", THIS_ROOT, "--release")
rez_exe = build_root / "portable_rez.exe"
rez_exe.rename(build_root / "rez.exe")
for platform_name in os.listdir(build_root):
platform_dir = build_root / platform_name / "release" / "install"
print(os.listdir(platform_dir))
print(f"build {platform_name}")
print(f"rename {binary_name} to {rez_binary_name}")
rez_exe = platform_dir / binary_name
rez_exe.rename(platform_dir / rez_binary_name)

if args.release:
temp_dir = os.path.join(THIS_ROOT, ".zip")
shutil.rmtree(temp_dir, ignore_errors=True)
version = str(args.version)
print(f"make zip to current version: {version}")
os.makedirs(temp_dir, exist_ok=True)
zip_file = os.path.join(temp_dir, f"{PACKAGE_NAME}-{version}.zip")
with zipfile.ZipFile(zip_file, "w") as zip_obj:
for root, _, files in os.walk(build_root):
for file in files:
zip_obj.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(build_root, ".")))
print("Saving to {zipfile}".format(zipfile=zip_file))
if args.test:
print("run tests")
subprocess.check_call(["rez", "--help"], cwd=platform_dir)

if args.release:
temp_dir = os.path.join(THIS_ROOT, ".zip")
shutil.rmtree(temp_dir, ignore_errors=True)
version = str(args.version)
print(f"make zip to current version: {version}")
os.makedirs(temp_dir, exist_ok=True)
zip_file = os.path.join(temp_dir, f"{PACKAGE_NAME}-{version}-{platform_name}.zip")
with zipfile.ZipFile(zip_file, "w") as zip_obj:
for root, _, files in os.walk(platform_dir):
for file in files:
zip_obj.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(platform_dir, ".")))
print("Saving to {zipfile}".format(zipfile=zip_file))