Skip to content

Commit 187a794

Browse files
authored
Merge pull request #119 from wolfv/prefix-upload
feat: prefix upload
2 parents 0e75b96 + e76ffee commit 187a794

1 file changed

Lines changed: 73 additions & 49 deletions

File tree

vinca/generate_gha.py

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -266,28 +266,40 @@ def build_unix_pipeline(
266266
batch_keys.append(batch_key)
267267

268268
pretty_stage_name = get_stage_name(batch)
269-
azure_template["jobs"][batch_key] = {
269+
270+
build_env = {
271+
"ANACONDA_API_TOKEN": "${{ secrets.ANACONDA_API_TOKEN }}",
272+
"CURRENT_RECIPES": f"{' '.join([pkg for pkg in batch])}",
273+
"BUILD_TARGET": target,
274+
}
275+
276+
steps = [
277+
{
278+
"name": "Checkout code",
279+
"uses": "actions/checkout@v6",
280+
},
281+
{
282+
"name": f"Build {' '.join([pkg for pkg in batch])}",
283+
"env": build_env,
284+
"run": script,
285+
},
286+
]
287+
288+
job = {
270289
"name": pretty_stage_name,
271290
"runs-on": runs_on,
272291
"strategy": {"fail-fast": False},
273292
"needs": prev_batch_keys,
274-
"steps": [
275-
{
276-
"name": "Checkout code",
277-
"uses": "actions/checkout@v6",
278-
},
279-
{
280-
"name": f"Build {' '.join([pkg for pkg in batch])}",
281-
"env": {
282-
"ANACONDA_API_TOKEN": "${{ secrets.ANACONDA_API_TOKEN }}",
283-
"CURRENT_RECIPES": f"{' '.join([pkg for pkg in batch])}",
284-
"BUILD_TARGET": target, # use for cross-compilation
285-
},
286-
"run": script,
287-
},
288-
],
293+
"steps": steps,
294+
}
295+
296+
job["permissions"] = {
297+
"id-token": "write",
298+
"attestations": "write",
289299
}
290300

301+
azure_template["jobs"][batch_key] = job
302+
291303
prev_batch_keys = batch_keys
292304

293305
if len(azure_template.get("jobs", [])) == 0:
@@ -365,7 +377,43 @@ def build_win_pipeline(stages, trigger_branch, outfile="win.yml", azure_template
365377
batch_keys.append(batch_key)
366378

367379
pretty_stage_name = get_stage_name(batch)
368-
azure_template["jobs"][batch_key] = {
380+
381+
build_env = {
382+
"ANACONDA_API_TOKEN": "${{ secrets.ANACONDA_API_TOKEN }}",
383+
"CURRENT_RECIPES": f"{' '.join([pkg for pkg in batch])}",
384+
"PYTHONUNBUFFERED": 1,
385+
}
386+
387+
steps = [
388+
{"name": "Checkout code", "uses": "actions/checkout@v6"},
389+
{
390+
"name": "Setup pixi",
391+
"uses": "prefix-dev/setup-pixi@v0.9.4",
392+
"with": {
393+
"pixi-version": "v0.63.2",
394+
"cache": "true",
395+
},
396+
},
397+
{
398+
"uses": "egor-tensin/cleanup-path@v5",
399+
"with": {
400+
"dirs": "C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin"
401+
},
402+
},
403+
{
404+
"shell": "cmd",
405+
"run": azure_win_preconfig_script,
406+
"name": "conda-forge build setup",
407+
},
408+
{
409+
"shell": "cmd",
410+
"run": script,
411+
"env": build_env,
412+
"name": f"Build {' '.join([pkg for pkg in batch])}",
413+
},
414+
]
415+
416+
job = {
369417
"name": pretty_stage_name,
370418
"runs-on": vm_imagename,
371419
"strategy": {"fail-fast": False},
@@ -374,40 +422,16 @@ def build_win_pipeline(stages, trigger_branch, outfile="win.yml", azure_template
374422
"CONDA_BLD_PATH": "C:\\\\bld\\\\",
375423
"VINCA_CUSTOM_CMAKE_BUILD_DIR": "C:\\\\x\\\\",
376424
},
377-
"steps": [
378-
{"name": "Checkout code", "uses": "actions/checkout@v6"},
379-
{
380-
"name": "Setup pixi",
381-
"uses": "prefix-dev/setup-pixi@v0.9.4",
382-
"with": {
383-
"pixi-version": "v0.63.2",
384-
"cache": "true",
385-
},
386-
},
387-
{
388-
"uses": "egor-tensin/cleanup-path@v5",
389-
"with": {
390-
"dirs": "C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\mingw64\\bin"
391-
},
392-
},
393-
{
394-
"shell": "cmd",
395-
"run": azure_win_preconfig_script,
396-
"name": "conda-forge build setup",
397-
},
398-
{
399-
"shell": "cmd",
400-
"run": script,
401-
"env": {
402-
"ANACONDA_API_TOKEN": "${{ secrets.ANACONDA_API_TOKEN }}",
403-
"CURRENT_RECIPES": f"{' '.join([pkg for pkg in batch])}",
404-
"PYTHONUNBUFFERED": 1,
405-
},
406-
"name": f"Build {' '.join([pkg for pkg in batch])}",
407-
},
408-
],
425+
"steps": steps,
409426
}
410427

428+
job["permissions"] = {
429+
"id-token": "write",
430+
"attestations": "write",
431+
}
432+
433+
azure_template["jobs"][batch_key] = job
434+
411435
prev_batch_keys = batch_keys
412436

413437
if len(azure_template.get("jobs", [])) == 0:

0 commit comments

Comments
 (0)