-
Notifications
You must be signed in to change notification settings - Fork 185
139 lines (118 loc) · 4.33 KB
/
trampoline.yaml
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
name: Update Trampoline Binary
on:
push:
paths:
- "crates/pixi_trampoline/**"
- ".github/workflows/trampoline.yaml"
- "src/global/trampoline.rs"
workflow_dispatch:
pull_request:
paths:
- "crates/pixi_trampoline/**"
- ".github/workflows/trampoline.yaml"
- "src/global/trampoline.rs"
permissions:
contents: write # Allow write permissions for contents (like pushing to the repo)
pull-requests: write
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: crates/pixi_trampoline
strategy:
fail-fast: true
matrix:
include:
- name: "Linux-x86_64"
target: x86_64-unknown-linux-musl
os: ubuntu-latest
- name: "Linux-aarch64"
target: aarch64-unknown-linux-musl
os: ubuntu-latest
- name: "Linux-powerpc64"
target: powerpc64-unknown-linux-gnu
os: ubuntu-latest
- name: "macOS-x86"
target: x86_64-apple-darwin
os: macos-13
- name: "macOS-arm"
target: aarch64-apple-darwin
os: macos-14
- name: "Windows"
target: x86_64-pc-windows-msvc
os: windows-latest
- name: "Windows-arm"
target: aarch64-pc-windows-msvc
os: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history so we have branch information
- name: Set up Rust
uses: taiki-e/setup-cross-toolchain-action@v1
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: 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: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: trampoline-${{ matrix.target }}
path: crates/pixi_trampoline/trampolines-binaries/
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
uses: actions/checkout@v4
- name: Download all binaries
uses: actions/download-artifact@v4
with:
path: crates/pixi_trampoline/trampolines-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
zstd "$file" -f
rm "$file"
done
ls -R trampolines/
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: trampolines
path: crates/pixi_trampoline/trampolines/
- name: Commit and push updated binaries
# Don't run on forks
if: github.repository == 'prefix-dev/pixi' && startsWith(github.ref, 'reaf/heads')
run: |
# 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 commit -m "[CI]: Update trampoline binaries for all targets"
# Push changes to the branch that triggered the workflow
BRANCH=${GITHUB_REF#refs/heads/}
git push origin HEAD:$BRANCH