forked from rust-lang/rustup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux-builds-template.yaml
More file actions
191 lines (190 loc) · 8.46 KB
/
Copy pathlinux-builds-template.yaml
File metadata and controls
191 lines (190 loc) · 8.46 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
jobs: # skip-master skip-pr skip-stable
# This is ci/actions-templates/linux-builds-template.yaml
# Do not edit this file in .github/workflows
build-linux-pr: # job-name skip-master skip-stable
build-linux-master: # job-name skip-pr skip-stable
build-linux-stable: # job-name skip-master skip-pr
runs-on: ubuntu-latest
if: ${{ contains('["pull_request", "merge_group"]', github.event_name) }} # skip-master skip-stable
if: ${{ (github.event_name == 'push' && github.ref_name == 'master') || github.event_name == 'schedule' }} # skip-pr skip-stable
if: ${{ github.event_name == 'push' && github.ref_name == 'stable' }} # skip-pr skip-master
permissions:
id-token: write
contents: read
strategy:
fail-fast: false
matrix:
mode:
- dev
- release
target:
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-linux-android
- aarch64-unknown-linux-gnu # skip-pr
- aarch64-unknown-linux-musl # skip-pr skip-master
- powerpc64-unknown-linux-gnu # skip-pr
- x86_64-unknown-linux-musl # skip-pr
- i686-unknown-linux-gnu # skip-pr skip-master
- arm-unknown-linux-gnueabi # skip-pr skip-master
- arm-unknown-linux-gnueabihf # skip-pr skip-master
- x86_64-unknown-freebsd # skip-pr skip-master
- x86_64-unknown-netbsd # skip-pr skip-master
- x86_64-unknown-illumos # skip-pr skip-master
- powerpc-unknown-linux-gnu # skip-pr skip-master
- powerpc64le-unknown-linux-gnu # skip-pr skip-master
- s390x-unknown-linux-gnu # skip-pr skip-master
- arm-linux-androideabi # skip-pr skip-master
- armv7-linux-androideabi # skip-pr skip-master
- x86_64-linux-android # skip-pr skip-master
- riscv64gc-unknown-linux-gnu # skip-pr skip-master
- loongarch64-unknown-linux-gnu # skip-pr skip-master
- loongarch64-unknown-linux-musl # skip-pr skip-master skip-stable
include:
- target: x86_64-unknown-linux-gnu
run_tests: YES
#snap_arch: amd64
- target: i686-unknown-linux-gnu # skip-pr skip-master
#snap_arch: i386 # skip-pr skip-master
- target: aarch64-unknown-linux-gnu # skip-pr
#snap_arch: arm64 # skip-pr
- target: armv7-unknown-linux-gnueabihf
#snap_arch: armhf
- target: powerpc64le-unknown-linux-gnu # skip-pr skip-master
#snap_arch: ppc64el # skip-pr skip-master
- target: s390x-unknown-linux-gnu # skip-pr skip-master
#snap_arch: s390x # skip-pr skip-master
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
# v2 defaults to a shallow checkout, but we need at least to the previous tag
fetch-depth: 0
- name: Acquire tags for the repo
run: |
git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
- name: Display the current git status
run: |
git status
git describe
- name: Prep cargo dirs
run: |
mkdir -p ~/.cargo/{registry,git}
- name: Set environment variables appropriately for the build
run: |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
- name: Skip tests
if: matrix.run_tests == '' || matrix.mode == 'release'
run: |
echo "SKIP_TESTS=yes" >> $GITHUB_ENV
- name: Cache cargo registry and git trees
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Get rustc commit hash
id: cargo-target-cache
run: |
echo "{rust_hash}={$(rustc -Vv | grep commit-hash | awk '{print $2}')}" >> $GITHUB_OUTPUT
shell: bash
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ github.base_ref }}-${{ github.head_ref }}-${{ matrix.target }}-${{ matrix.mode }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ github.base_ref }}-${{ matrix.target }}-${{ matrix.mode }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rustup using ./rustup-init.sh
run: |
sh ./rustup-init.sh --default-toolchain=none --profile=minimal -y
- name: Ensure Stable is up to date
run: |
if rustc +stable -vV >/dev/null 2>/dev/null; then
rustup toolchain uninstall stable
fi
rustup toolchain install --profile=minimal stable
- name: Ensure we have our goal target installed
run: |
rustup target install "$TARGET"
- name: Determine which docker we need to run in
run: |
case "$TARGET" in
*-linux-android*) DOCKER=android ;; # Android uses a local docker image
*) DOCKER="$TARGET" ;;
esac
echo "DOCKER=$DOCKER" >> $GITHUB_ENV
- name: Fetch the base docker images from rust-lang/rust
run: bash ci/fetch-rust-docker.bash "${TARGET}"
- name: Maybe build a docker from there
run: |
if [ -f "ci/docker/$DOCKER/Dockerfile" ]; then
docker build -t "$DOCKER" -f "ci/docker/${DOCKER}/Dockerfile" .
fi
- name: Run the build within the docker image
env:
BUILD_PROFILE: ${{ matrix.mode }}
run: |
mkdir -p "${PWD}/target"
chown -R "$(id -u)":"$(id -g)" "${PWD}/target"
docker run \
--entrypoint sh \
--env BUILD_PROFILE="${BUILD_PROFILE}" \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--env LIBZ_SYS_STATIC=1 \
--env SKIP_TESTS="${SKIP_TESTS}" \
--env TARGET="${TARGET}" \
--init \
--rm \
--tty \
--user "$(id -u)":"$(id -g)" \
--volume "$(rustc --print sysroot)":/rustc-sysroot:ro \
--volume "${HOME}/.cargo:/cargo" \
--volume "${PWD}":/checkout:ro \
--volume "${PWD}"/target:/checkout/target \
--workdir /checkout \
"${DOCKER}" \
-c 'PATH="${PATH}":/rustc-sysroot/bin bash ci/run.bash'
- name: Upload the built artifact
uses: actions/upload-artifact@v4
if: matrix.mode == 'release'
with:
name: rustup-init-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/rustup-init
retention-days: 7
- name: Ensure that awscli is installed
if: github.event_name == 'push' && github.ref == 'refs/heads/stable' && matrix.mode == 'release'
run: |
which aws
aws --version
- name: Prepare the dist
if: github.event_name == 'push' && github.ref == 'refs/heads/stable' && matrix.mode == 'release'
run: |
bash ci/prepare-deploy.bash
- name: Deploy build to dev-static dist tree for release team
if: github.event_name == 'push' && github.ref == 'refs/heads/stable' && matrix.mode == 'release'
run: |
aws s3 cp --recursive deploy/ s3://dev-static-rust-lang-org/rustup/
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-1
- name: Configure AWS credentials
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.mode == 'release'
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::890664054962:role/ci--rust-lang--rustup
aws-region: us-east-1
- name: Deploy build to rustup-builds bucket for release team
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.mode == 'release'
run: |
aws --debug s3 cp --recursive deploy/ s3://rustup-builds/${{ github.sha }}
env:
AWS_DEFAULT_REGION: us-east-1
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache