-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (133 loc) · 4.71 KB
/
Copy pathbuild.yml
File metadata and controls
147 lines (133 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build
on:
push:
tags:
- 'v[0-9]*.[0-9]*.[0-9]*'
workflow_dispatch:
inputs:
force:
description: 'Force rebuild even if a successful build already exists for this SHA'
type: boolean
default: false
jobs:
check:
name: Check for existing build
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: read
outputs:
skip: ${{ steps.decide.outputs.skip }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Check if build is needed
id: decide
env:
GH_TOKEN: ${{ github.token }}
run: |
bash scripts/check-build-needed.sh \
"${{ github.sha }}" \
"${{ github.repository }}" \
"${{ inputs.force == true || github.event_name == 'push' }}" \
"Build" \
"*.py" "pyproject.toml" "uv.lock" ".github/workflows/build.yml"
build:
name: ${{ matrix.os.name }}
needs: check
if: needs.check.outputs.skip != 'true'
runs-on: ${{ matrix.os.runner }}
timeout-minutes: 60
permissions:
actions: write
contents: read
strategy:
fail-fast: false
matrix:
os:
- name: Linux (x64)
runner: ubuntu-22.04
artifact: uvscem-linux-x64
bin: uvscem-linux-x64
- name: Linux (arm64)
runner: ubuntu-22.04-arm
artifact: uvscem-linux-arm64
bin: uvscem-linux-arm64
- name: macOS (arm64)
runner: macos-latest
artifact: uvscem-macos-arm64
bin: uvscem-macos-arm64
- name: Windows (x64)
runner: windows-latest
artifact: uvscem-windows-x64
bin: uvscem-windows-x64.exe
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Wait for tests to pass
env:
GH_TOKEN: ${{ github.token }}
run: bash scripts/wait-for-workflow.sh "Test" "${{ github.sha }}" "${{ github.repository }}"
- name: Set up Python 3.10
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
- name: Install runtime dependencies
run: pip install .
- name: Write version constant for Nuitka
id: pkg-version
shell: python
run: |
import importlib.metadata
import os
import re
import uvscem
from pathlib import Path
v = importlib.metadata.version("uvscem")
Path(uvscem.__file__).parent.joinpath("_version.py").write_text(
f'__version__ = "{v}"\n'
)
# Nuitka product-version must be numeric X.Y.Z only — strip PEP 440
# pre/post/dev/local suffixes (e.g. "1.2.3.post1+abc" → "1.2.3").
numeric = re.match(r"^(\d+\.\d+\.\d+)", v)
nuitka_version = numeric.group(1) if numeric else "0.0.0"
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
fh.write(f"version={v}\n")
fh.write(f"nuitka_version={nuitka_version}\n")
- name: Build binary
uses: Nuitka/Nuitka-Action@0d4e22d4b66062a13d120f6948dd90170be04b3a # v1.4
with:
script-name: src/uvscem/__main__.py
output-file: ${{ matrix.os.artifact }}
mode: onefile
include-package: uvscem
product-name: uvscem
product-version: ${{ steps.pkg-version.outputs.nuitka_version }}
# Skip zstd compression — near-instant extraction on first run.
onefile-no-compression: true
# Stable per-version cache dir — extraction is skipped entirely on
# subsequent launches once the payload has been extracted once.
onefile-tempdir-spec: "{CACHE_DIR}/{PRODUCT}/{VERSION}"
- name: Smoke test binary
shell: bash
run: |
bin="build/${{ matrix.os.bin }}"
chmod +x "$bin" 2>/dev/null || true
# --help should succeed
"$bin" --help
# missing config/bundle should fail cleanly (exit 1, no traceback)
! "$bin" install --config-name __no_such_file__.json
! "$bin" export --config-name __no_such_file__.json
! "$bin" import --bundle-path __no_such_bundle__
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ matrix.os.artifact }}
path: build/${{ matrix.os.bin }}
if-no-files-found: error
retention-days: 30