Skip to content

Commit

Permalink
feat: add script to build trampolines
Browse files Browse the repository at this point in the history
- easier to run locally
- cleans up CI workflow quite a bit
  • Loading branch information
Hofer-Julian committed Dec 20, 2024
1 parent b795765 commit 1eb43cb
Show file tree
Hide file tree
Showing 17 changed files with 5,229 additions and 40 deletions.
52 changes: 12 additions & 40 deletions .github/workflows/trampoline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,32 +66,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/setup-pixi@v0.8.1
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 +90,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 +108,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 "actions@github.com"
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

0 comments on commit 1eb43cb

Please sign in to comment.