Skip to content
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

feat: add script to build trampolines #2752

Merged
merged 7 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 14 additions & 45 deletions .github/workflows/trampoline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Update Trampoline Binary
on:
push:
paths:
- "crates/pixi_trampoline/**"
- "trampoline/**"
- ".github/workflows/trampoline.yaml"
- "src/global/trampoline.rs"
workflow_dispatch:
pull_request:
paths:
- "crates/pixi_trampoline/**"
- "trampoline/**"
- ".github/workflows/trampoline.yaml"
- "src/global/trampoline.rs"

Expand All @@ -20,9 +20,6 @@ permissions:
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: crates/pixi_trampoline
strategy:
fail-fast: true
matrix:
Expand Down Expand Up @@ -66,32 +63,22 @@ jobs:
with:
target: ${{ matrix.target }}

- name: Build trampoline binary
run: cargo build --release --target ${{ matrix.target }}

- name: Move trampoline binary on windows
if: startsWith(matrix.name, 'Windows')
run: |
mkdir -p trampolines-binaries
mv target/${{ matrix.target }}/release/pixi_trampoline.exe trampolines-binaries/pixi-trampoline-${{ matrix.target }}.exe
- name: Set up pixi
uses: prefix-dev/[email protected]
with:
environments: trampoline

- name: Move trampoline binary on unix
if: startsWith(matrix.name, 'Windows') == false
run: |
mkdir -p trampolines-binaries
mv target/${{ matrix.target }}/release/pixi_trampoline trampolines-binaries/pixi-trampoline-${{ matrix.target }}
- name: Build trampoline binary
run: pixi run build-trampoline --target ${{ matrix.target }}

- name: Upload binary artifact
- name: Upload binary artifact (Windows)
uses: actions/upload-artifact@v4
with:
name: trampoline-${{ matrix.target }}
path: crates/pixi_trampoline/trampolines-binaries/
path: trampoline/binaries/pixi-trampoline-${{ matrix.target }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}.zstd

aggregate:
runs-on: ubuntu-latest
defaults:
run:
working-directory: crates/pixi_trampoline
needs: build # This ensures the aggregation job runs after the build jobs
steps:
- name: Checkout code
Expand All @@ -100,34 +87,16 @@ jobs:
- name: Download all binaries
uses: actions/download-artifact@v4
with:
path: crates/pixi_trampoline/trampolines-binaries/
path: trampoline/binaries/

- name: List downloaded files
run: ls -R trampolines-binaries/

- name: Move trampolines
run: |
mkdir -p trampolines
# Iterate through all files in trampolines directory and its subdirectories
find trampolines-binaries -type f -name 'pixi-trampoline-*' -exec mv -f {} trampolines/ \;
# now iterate through all files in trampolines directory and compress them using zstd
# and remove the original file
# by using -f we allow overwriting the file
for file in trampolines/*; do
# Skip files that are already compressed (end with .zst)
if [[ "$file" == *.zst ]]; then
continue
fi
zstd "$file" -f
rm "$file"
done
ls -R trampolines/
run: ls -R trampoline/binaries/

- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: trampolines
path: crates/pixi_trampoline/trampolines/
path: trampoline/binaries/

- name: Commit and push updated binaries
# Don't run on forks
Expand All @@ -136,7 +105,7 @@ jobs:
# Set the repository to push to the repository the workflow is running on
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add trampolines/
git add trampoline/binaries/
git commit -m "[CI]: Update trampoline binaries for all targets"
# Push changes to the branch that triggered the workflow
BRANCH=${GITHUB_REF#refs/heads/}
Expand Down
Loading
Loading