Skip to content

Commit e8cc03b

Browse files
committed
Publish Linux ARM binaries
1 parent 9518320 commit e8cc03b

File tree

3 files changed

+55
-20
lines changed

3 files changed

+55
-20
lines changed

.github/workflows/cd.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ jobs:
2222
steps:
2323
- name: Determine if pre-release
2424
id: prerelease_check
25+
# it checks for PEP 440 compatible prerelease tags
2526
run: |
26-
export IS_PRERELEASE=$([[ ${{ github.ref }} =~ [^0-9]$ ]] && echo true || echo false)
27+
export IS_PRERELEASE=$([[ ${{ github.ref }} =~ [abrcdev]+[0-9]+$ ]] && echo true || echo false)
2728
echo "prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
2829
export PUBLISH_DOCKER=$([[ $IS_PRERELEASE == 'false' && "${{ secrets.DOCKERHUB_USERNAME }}" != '' ]] && echo true || echo false)
2930
echo "publish_docker=$PUBLISH_DOCKER" >> $GITHUB_OUTPUT
@@ -39,17 +40,17 @@ jobs:
3940
- name: Build the distribution
4041
id: build
4142
run: nox -vs build
42-
- name: Read the Changelog
43-
id: read-changelog
44-
uses: mindsers/changelog-reader-action@v2
45-
with:
46-
version: ${{ steps.build.outputs.version }}
43+
# - name: Read the Changelog
44+
# id: read-changelog
45+
# uses: mindsers/changelog-reader-action@v2
46+
# with:
47+
# version: ${{ steps.build.outputs.version }}
4748
- name: Create GitHub release and upload the distribution
4849
id: create-release
4950
uses: softprops/action-gh-release@v2
5051
with:
5152
name: ${{ steps.build.outputs.version }}
52-
body: ${{ steps.read-changelog.outputs.changes }}
53+
body: test
5354
draft: false
5455
prerelease: ${{ steps.prerelease_check.outputs.prerelease }}
5556
files: ${{ steps.build.outputs.asset_path }}
@@ -61,19 +62,23 @@ jobs:
6162
password: ${{ secrets.B2_PYPI_PASSWORD }}
6263
deploy-linux-bundle:
6364
needs: deploy
64-
runs-on: ubuntu-latest
65-
container:
66-
image: "python:3.12" # can not use ${{ env.PYTHON_DEFAULT_VERSION }} here
67-
env:
68-
DEBIAN_FRONTEND: noninteractive
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
os: [ "ubuntu-22.04", "ubuntu-22.04-arm" ]
69+
runs-on: ${{ matrix.os }}
6970
steps:
7071
- uses: actions/checkout@v4
7172
with:
7273
fetch-depth: 0
74+
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
75+
uses: deadsnakes/[email protected] # staticx doesn't work with python installed by setup-python action
76+
with:
77+
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
7378
- name: Install dependencies
7479
run: |
75-
apt-get -y update
76-
apt-get -y install patchelf
80+
sudo apt-get -y update
81+
sudo apt-get -y install patchelf scons
7782
python -m pip install --upgrade nox pdm
7883
git config --global --add safe.directory '*'
7984
- name: Bundle the distribution

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
env:
172172
B2_TEST_APPLICATION_KEY: ${{ secrets.B2_TEST_APPLICATION_KEY }}
173173
B2_TEST_APPLICATION_KEY_ID: ${{ secrets.B2_TEST_APPLICATION_KEY_ID }}
174-
WORKFLOW_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} runs-on: ${{ matrix.os }}
174+
WORKFLOW_ID: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
175175
runs-on: ${{ matrix.os }}
176176
strategy:
177177
fail-fast: false
@@ -191,6 +191,11 @@ jobs:
191191
sudo apt-get -y install patchelf scons
192192
python -m pip install --upgrade nox pdm
193193
git config --global --add safe.directory '*'
194+
- name: Setup tmate session
195+
if: matrix.os == 'ubuntu-22.04-arm'
196+
uses: mxschmitt/action-tmate@v3
197+
with:
198+
limit-access-to-actor: true
194199
- name: Bundle the distribution
195200
id: bundle
196201
shell: bash

noxfile.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def _detect_python_nox_id() -> str:
6868
DOCKER_TEMPLATE = pathlib.Path('docker/Dockerfile.template')
6969

7070
SYSTEM = platform.system().lower()
71+
MACHINE = platform.machine().lower()
7172

7273
WINDOWS_TIMESTAMP_SERVER = 'http://timestamp.digicert.com'
7374
WINDOWS_SIGNTOOL_PATH = 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe'
@@ -84,13 +85,19 @@ def _detect_python_nox_id() -> str:
8485

8586

8687
def pdm_install(
87-
session: nox.Session, *groups: str, dev: bool = True, editable: bool = False
88+
session: nox.Session,
89+
*groups: str,
90+
dev: bool = True,
91+
editable: bool = False,
92+
no_isolated: bool = False,
8893
) -> None:
8994
args = []
9095
if not dev:
9196
args.append('--prod')
9297
if not editable:
9398
args.append('--no-editable')
99+
if no_isolated:
100+
args.extend(['--no-isolated', '--no-self'])
94101
for group in groups:
95102
args.extend(['--group', group])
96103
session.run('pdm', 'install', *args, external=True)
@@ -139,6 +146,18 @@ def get_versions() -> list[str]:
139146
]
140147

141148

149+
def is_x86_64_architecture():
150+
"""
151+
Determines if the machine's architecture is x86-based.
152+
153+
This function checks the current machine's architecture and returns
154+
whether it belongs to the x86 64-bit family (including x86_64 or amd64).
155+
"""
156+
if MACHINE in ('x86_64', 'amd64'):
157+
return True
158+
return False
159+
160+
142161
@nox.session(name='format', python=PYTHON_DEFAULT_VERSION)
143162
def format_(session):
144163
"""Lint the code and apply fixes in-place whenever possible."""
@@ -298,20 +317,22 @@ def build(session):
298317

299318
@nox.session(python=PYTHON_DEFAULT_VERSION)
300319
def dump_license(session: nox.Session):
301-
pdm_install(session, 'license', editable=True)
320+
pdm_install(session, 'license', editable=True, dev=False)
302321
session.run('b2', 'license', '--dump', '--with-packages')
303322

304323

305324
@nox.session(python=PYTHON_DEFAULT_VERSION)
306325
def bundle(session: nox.Session):
307326
"""Bundle the distribution."""
308327

328+
# We need no isolated mode to be able to compile staticx, particularly on ARM machines.
329+
pdm_install(session, 'bundle', 'full', no_isolated=True)
330+
309331
# We're running dump_license in another session because:
310332
# 1. `b2 license --dump` dumps the licence where the module is installed.
311333
# 2. We don't want to install b2 as editable module in the current session
312334
# because that would make `b2 versions` show the versions as editable.
313335
session.run('nox', '-s', 'dump_license', '-fb', 'venv', external=True)
314-
pdm_install(session, 'bundle', 'full')
315336

316337
template_spec = string.Template(pathlib.Path('b2.spec.template').read_text())
317338
versions = get_versions()
@@ -405,11 +426,15 @@ def sign_windows(keypair_alias, cert_fingerprint):
405426
else:
406427
session.error(f'unrecognized platform: {SYSTEM}')
407428

408-
# Append OS name to all the binaries.
429+
# Append OS name and optionally an architecture to all the binaries.
409430
for asset in pathlib.Path('dist').glob('*'):
410431
name = asset.stem
411432
ext = asset.suffix
412-
asset_path = f'dist/{name}-{SYSTEM}{ext}'
433+
if is_x86_64_architecture():
434+
asset_path = f'dist/{name}-{SYSTEM}{ext}'
435+
else:
436+
asset_path = f'dist/{name}-{SYSTEM}-{MACHINE}{ext}'
437+
413438
session.run('mv', '-f', asset, asset_path, external=True)
414439

415440
# Path have to be specified with unix style slashes even for windows,

0 commit comments

Comments
 (0)