Skip to content

Commit bcbf315

Browse files
authored
ci: split building, aggregating and uploading in separate jobs (#171)
* ci: split building, aggregating and uploading in separate jobs This should also make it easier for external repositories to depend on these artifacts * Use sha * Use target platform for name * Update generate-version-matrix * Another reorder * Rename jobs * Update artifact name * Update matrix script * Aggregate per target * Temporary simplification to test things * Checkout repo * Revert "Temporary simplification to test things" This reverts commit 5dab5fc. * Don't run on pull requests
1 parent b6fb3c7 commit bcbf315

File tree

4 files changed

+56
-34
lines changed

4 files changed

+56
-34
lines changed

.github/workflows/rattler-build.yml renamed to .github/workflows/build-upload.yml

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ on:
88
- "pixi-build-rust-v[0-9]+.[0-9]+.[0-9]+"
99
# Build all backends on main branch
1010
branches: [main]
11-
pull_request:
1211
workflow_dispatch:
1312

1413

15-
name: "Build and publish backends"
14+
name: "Conda Packages"
1615

1716
concurrency:
1817
group: ${{ github.workflow }}-${{ github.ref_name }}
@@ -23,36 +22,31 @@ permissions:
2322
contents: read
2423

2524
jobs:
26-
generate-version:
25+
generate-matrix:
2726
runs-on: ubuntu-latest
2827
outputs:
29-
version_matrix: ${{ steps.set_version.outputs.version_matrix }}
28+
matrix: ${{ steps.set_version.outputs.matrix }}
3029
steps:
3130
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
32-
- uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1
3331
- uses: prefix-dev/setup-pixi@19eac09b398e3d0c747adc7921926a6d802df4da # v0.8.8
34-
with:
35-
environments: release
3632
- name: Extract versions
3733
id: set_version
3834
run: |
3935
# extract names and versions from cargo metadata
4036
# and generate a matrix entries for the build job
41-
MATRIX_JSON=$(pixi run python scripts/generate_version_matrix.py)
37+
MATRIX_JSON=$(pixi run generate-matrix)
4238
4339
echo "Generated matrix: $MATRIX_JSON"
44-
echo "version_matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
40+
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
4541
46-
rattler-build:
47-
needs: generate-version
42+
build:
43+
needs: generate-matrix
4844
env:
4945
REPO_NAME: "prefix-dev/pixi-build-backends"
5046
strategy:
5147
matrix:
52-
bins: ${{ fromJSON(needs.generate-version.outputs.version_matrix) }}
53-
48+
bins: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
5449
fail-fast: false
55-
5650
runs-on: ${{ matrix.bins.os }}
5751
steps:
5852
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -71,24 +65,54 @@ jobs:
7165
- name: Build ${{ matrix.bins.bin }}
7266
shell: bash
7367
env:
74-
TARGET_PLATFORM: ${{ matrix.bins.target }}
7568
RATTLER_BUILD_ENABLE_GITHUB_INTEGRATION: "true"
7669
RATTLER_BUILD_COLOR: "always"
7770
run: |
78-
pixi run build-recipe-ci $RUNNER_TEMP recipe/${{ matrix.bins.bin }}.yaml ${{ env.TARGET_PLATFORM }}
79-
- name: Upload OSX or Linux packages
71+
pixi run build-recipe-ci $RUNNER_TEMP recipe/${{ matrix.bins.bin }}.yaml ${{ matrix.bins.target }}
72+
- name: Upload build artifacts
73+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
74+
with:
75+
name: conda-packages-${{ matrix.bins.bin }}-${{ matrix.bins.target }}
76+
path: ${{ runner.temp }}/**/*.conda
77+
78+
aggregate:
79+
needs: build
80+
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
target: [linux-64, linux-aarch64, linux-ppc64le, win-64, osx-64, osx-arm64]
84+
steps:
85+
- name: Download conda package artifacts for ${{ matrix.target }}
86+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
87+
with:
88+
pattern: conda-packages-*-${{ matrix.target }}
89+
path: conda-artifacts-${{ matrix.target }}
90+
merge-multiple: true
91+
- name: Upload aggregated conda packages for ${{ matrix.target }}
92+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
93+
with:
94+
name: conda-packages-${{ matrix.target }}
95+
path: conda-artifacts-${{ matrix.target }}/**/*.conda
96+
97+
upload:
98+
needs: aggregate
99+
runs-on: ubuntu-latest
100+
if: ${{ startsWith(github.ref, 'refs/tags') && github.repository == 'prefix-dev/pixi-build-backends' }}
101+
steps:
102+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
103+
- name: Download all conda packages
104+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
105+
with:
106+
pattern: conda-packages-*
107+
path: conda-packages
108+
merge-multiple: true
109+
- uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
110+
with:
111+
environments: build
112+
- name: Upload packages
80113
shell: bash
81-
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.bins.os != 'windows-latest' && github.repository == env.REPO_NAME }}
82114
run: |
83-
for file in "$RUNNER_TEMP"/**/*.conda; do
115+
for file in conda-packages/*.conda; do
84116
echo "Uploading ${file}"
85117
pixi run -e build rattler-build upload prefix -c pixi-build-backends "$file"
86118
done
87-
- name: Upload Windows packages
88-
shell: pwsh
89-
if: ${{ startsWith(github.ref, 'refs/tags') && matrix.bins.os == 'windows-latest' && github.repository == env.REPO_NAME }}
90-
run: |
91-
Get-ChildItem -Path $env:RUNNER_TEMP -Filter *.conda -Recurse | ForEach-Object {
92-
Write-Host "Uploading $($_.FullName)"
93-
pixi run -e build rattler-build upload prefix -c pixi-build-backends "$($_.FullName)"
94-
}
File renamed without changes.

pixi.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ build-release = "cargo build --release"
1414
nextest = "cargo nextest run --workspace --all-targets"
1515
doctest = "cargo test --doc"
1616
test = [{ task = "nextest" }, { task = "doctest" }]
17+
generate-matrix = "python scripts/generate-matrix.py"
1718

1819

1920
install-pixi-build-python = { cmd = "cargo install --path crates/pixi-build-python --locked --force" }
@@ -27,6 +28,7 @@ install-pixi-backends = { depends-on = [
2728
"install-pixi-build-rust",
2829
] }
2930

31+
3032
[dependencies]
3133
rust = ">=1.86.0,<1.87"
3234
python = ">=3.12.4,<4"
@@ -37,6 +39,7 @@ libzlib = ">=1.3.1,<2"
3739
liblzma = ">=5.8.1,<6"
3840
cargo-nextest = ">=0.9.96,<0.10"
3941

42+
4043
[target.linux-64.dependencies]
4144
clang = ">=18.1.8,<19.0"
4245
mold = ">=2.33.0,<3.0"
@@ -66,8 +69,6 @@ depends-on = [
6669
]
6770
args = ["recipe", "target_platform"]
6871

69-
[feature.release.dependencies]
70-
python = ">=3.12.4,<4"
7172

7273
[feature.schema.tasks]
7374
generate-schema = "python schema/model.py > schema/schema.json"
@@ -98,4 +99,3 @@ default = { solve-group = "default" }
9899
lint = { features = ["lint"], solve-group = "default" }
99100
schema = { features = ["schema"], no-default-feature = true }
100101
build = { features = ["build"], no-default-feature = true }
101-
release = { features = ["release"], no-default-feature = false }

scripts/generate_version_matrix.py renamed to scripts/generate-matrix.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,9 @@ def generate_matrix():
8585
matrix.append(
8686
{
8787
"bin": package["name"],
88-
"version": package["version"],
89-
"env_name": package["name"].replace("-", "_").upper()
90-
+ "_VERSION",
91-
"crate_name": package["name"],
9288
"target": target["target"],
89+
"version": package["version"],
90+
"env_name": f"{package["name"].replace("-", "_").upper()}_VERSION",
9391
"os": target["os"],
9492
}
9593
)

0 commit comments

Comments
 (0)