-
Notifications
You must be signed in to change notification settings - Fork 5
Create & release standalone binaries #705
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7267306
Bump pip in devcontainer
spoorcc ff46eda
Pin upload action
spoorcc 6ab4ec1
Add tooling for building with Nuitka
spoorcc ee3ffc2
Create & release standalone binaries
spoorcc 8fbb692
Unpin deps in build.yaml
spoorcc 9bdd871
Use 3.13 for build
spoorcc 2afe2f6
Hide debug output
spoorcc d3243d2
Split test to clean environment
spoorcc 70325be
Fix build
spoorcc 5c1c7b6
Fix build
spoorcc 3443839
Patchelf is already installed & ccache unneeded for ephermeral agent
spoorcc 048ae65
Optimize binary
spoorcc 1c41986
Fix path in binary test
spoorcc 528ccdf
Fix build with symlink
spoorcc e6318dc
Make sure dfetch can be executed
spoorcc 0af09be
Don't return non-zero exit code if tool not found during environment
spoorcc 7609f0d
Cleanup build script
spoorcc db6a529
Add ccache that caches between builds
spoorcc 8f7024d
Also find projects with comments
spoorcc 32d7c40
There is no example folder
spoorcc 77cac4d
Try configuring ccache
spoorcc a6645b2
Pin more actions
spoorcc a49bde7
Don't fail the build if the exact same test version already exists
spoorcc 22ac492
Add verbose ccache
spoorcc cfaf389
Improve ccache settings
spoorcc 31aa02a
Build binaries on windows & macos
spoorcc ec42d66
Make artifacts unique
spoorcc fff51a0
Add more logging
spoorcc a5f40be
Don't limit jobs an dhopefully speed up jobs
spoorcc c1ba4aa
Test binaries on all OS'es
spoorcc 87b7007
ccache action should work on all platforms
spoorcc 0c4c802
Update changelog
spoorcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| name: Build | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
|
|
||
| build: | ||
| strategy: | ||
| matrix: | ||
| platform: [ubuntu-latest, macos-latest, windows-latest] | ||
| runs-on: ${{ matrix.platform }} | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| steps: | ||
| - name: Harden the runner (Audit all outbound calls) | ||
| uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: ccache | ||
| uses: hendrikmuhs/ccache-action@30ae3502c7f2d3200209bf2f90eccef2357896cf # v1.2 | ||
| with: | ||
| key: ${{ github.job }}-${{ matrix.platform }} | ||
| verbose: 1 | ||
| create-symlink: ${{ matrix.platform != 'windows-latest' }} | ||
|
|
||
| - name: Create binary | ||
| env: | ||
| CCACHE_BASEDIR: ${{ github.workspace }} | ||
| CCACHE_NOHASHDIR: true | ||
| NUITKA_CACHE_DIR_CCACHE: $HOME/.ccache | ||
| NUITKA_CCACHE_BINARY: /usr/bin/ccache | ||
| run: | | ||
| pip install .[build] | ||
| python script/build.py | ||
|
|
||
| - name: Store the distribution packages | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| name: binary-distribution-${{ matrix.platform }} | ||
| path: build/dfetch-* | ||
|
|
||
| test-binary: | ||
| name: test binary | ||
| needs: | ||
| - build | ||
| strategy: | ||
| matrix: | ||
| platform: [ubuntu-latest, macos-latest, windows-latest] | ||
| runs-on: ${{ matrix.platform }} | ||
|
|
||
| steps: | ||
| - name: Download the binary artifact | ||
| uses: actions/download-artifact@4a24838f3d5601fd639834081e118c2995d51e1c # v5 | ||
| with: | ||
| name: binary-distribution-${{ matrix.platform }} | ||
| path: . | ||
|
|
||
| - name: Prepare binary | ||
| if: matrix.platform == 'ubuntu-latest' | ||
| run: | | ||
| binary=$(ls dfetch-*-x86_64) | ||
| ln -sf "$binary" dfetch | ||
| chmod +x dfetch | ||
| ls -la . | ||
| shell: bash | ||
|
|
||
| - name: Prepare binary | ||
| if: matrix.platform == 'macos-latest' | ||
| run: | | ||
| binary=$(ls dfetch-*-osx) | ||
| ln -sf "$binary" dfetch | ||
| chmod +x dfetch | ||
| ls -la . | ||
| shell: bash | ||
|
|
||
| - name: Prepare binary on Windows | ||
| if: matrix.platform == 'windows-latest' | ||
| run: | | ||
| $binary = Get-ChildItem dfetch-*.exe | Select-Object -First 1 | ||
| Copy-Item $binary -Destination dfetch.exe -Force | ||
| Get-ChildItem | ||
| shell: pwsh | ||
|
|
||
| - run: ./dfetch init | ||
| - run: ./dfetch environment | ||
| - run: ./dfetch validate | ||
| - run: ./dfetch check | ||
| - run: ./dfetch update | ||
| - run: ./dfetch update | ||
| - run: ./dfetch report -t sbom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/usr/bin/env python3 | ||
| """This script builds the dfetch executable using Nuitka.""" | ||
| import subprocess # nosec | ||
| import sys | ||
| import tomllib as toml | ||
| from typing import Union | ||
|
|
||
| from dfetch import __version__ | ||
|
|
||
|
|
||
| def parse_option( | ||
| option_name: str, option_value: Union[bool, str, list, dict] | ||
| ) -> list[str]: | ||
| """ | ||
| Convert a config value to Nuitka CLI arguments. | ||
|
|
||
| Handles booleans (--flag), strings (--flag=value), lists (multiple --flag=value), | ||
| and nested dicts (--flag=key1=val1=key2=val2). | ||
|
|
||
| Returns: | ||
| list[str]: Nuitka CLI arguments in the format ['--flag', '--key=value'] | ||
| """ | ||
| args = [] | ||
| cli_key = f"--{option_name.replace('_','-')}" | ||
|
|
||
| if isinstance(option_value, bool): | ||
| if option_value: | ||
| args.append(cli_key) | ||
| elif isinstance(option_value, str): | ||
| args.append(f"{cli_key}={option_value}".replace("{VERSION}", __version__)) | ||
| elif isinstance(option_value, list): | ||
| for v in option_value: | ||
| if isinstance(v, dict): | ||
| parts = [f"{v[k]}" for k in v] | ||
| args.append(f"{cli_key}={'='.join(parts)}") | ||
| else: | ||
| args.append(f"{cli_key}={v}") | ||
| else: | ||
| args.append(f"{cli_key}={option_value}") | ||
|
|
||
| return args | ||
|
|
||
|
|
||
| # Load pyproject.toml | ||
| with open("pyproject.toml", "rb") as pyproject_file: | ||
| pyproject = toml.load(pyproject_file) | ||
| nuitka_opts = pyproject.get("tool", {}).get("nuitka", {}) | ||
|
spoorcc marked this conversation as resolved.
|
||
|
|
||
|
|
||
| if sys.platform.startswith("win"): | ||
| nuitka_opts["output-filename"] = nuitka_opts["output-filename-win"] | ||
| elif sys.platform.startswith("linux"): | ||
| nuitka_opts["output-filename"] = nuitka_opts["output-filename-linux"] | ||
| elif sys.platform.startswith("darwin"): | ||
| nuitka_opts["output-filename"] = nuitka_opts["output-filename-macos"] | ||
|
spoorcc marked this conversation as resolved.
|
||
|
|
||
|
|
||
| nuitka_opts = { | ||
| k: v | ||
| for k, v in nuitka_opts.items() | ||
| if k | ||
| not in {"output-filename-win", "output-filename-linux", "output-filename-macos"} | ||
| } | ||
|
|
||
| command = [sys.executable, "-m", "nuitka"] | ||
| for key, value in nuitka_opts.items(): | ||
| command.extend(parse_option(key, value)) | ||
|
|
||
| command.append("dfetch") | ||
|
|
||
| print(command) | ||
| subprocess.check_call(command) # nosec | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.