Skip to content

Commit 9f0fe12

Browse files
committed
fix(ci): verify yq checksum and DRY up install into shared script
The workflow was downloading yq from GitHub releases without any integrity check (a supply-chain risk, however small, on CI runners). We now download the upstream checksums file alongside the binary and verify the SHA256 before installing. While we're at it, the identical 8-line install block was copy-pasted across all three jobs. Extracted into .github/scripts/install-yq.sh so there's exactly one place to update the version or change the verification logic.
1 parent b1edcde commit 9f0fe12

2 files changed

Lines changed: 28 additions & 24 deletions

File tree

.github/scripts/install-yq.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Installs yq (mikefarah/yq) into ~/.local/bin with SHA256 verification.
4+
# Intended for CI runners (Linux amd64).
5+
6+
set -euo pipefail
7+
8+
YQ_VERSION="${YQ_VERSION:-v4.52.4}"
9+
INSTALL_DIR="$HOME/.local/bin"
10+
BASE_URL="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}"
11+
12+
mkdir -p "$INSTALL_DIR"
13+
14+
wget -qO "$INSTALL_DIR/yq_linux_amd64" "${BASE_URL}/yq_linux_amd64"
15+
wget -qO "$INSTALL_DIR/checksums" "${BASE_URL}/checksums"
16+
17+
(
18+
cd "$INSTALL_DIR"
19+
grep 'yq_linux_amd64$' checksums | sha256sum -c -
20+
mv yq_linux_amd64 yq
21+
rm -f checksums
22+
chmod +x yq
23+
)
24+
25+
echo "$INSTALL_DIR" >> "${GITHUB_PATH:-/dev/null}"

.github/workflows/test.yml

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,7 @@ jobs:
2323
submodules: recursive
2424

2525
- name: Install yq
26-
run: |
27-
set -euo pipefail
28-
YQ_VERSION="v4.52.4"
29-
mkdir -p "$HOME/.local/bin"
30-
wget -qO "$HOME/.local/bin/yq" \
31-
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
32-
chmod +x "$HOME/.local/bin/yq"
33-
echo "$HOME/.local/bin" >> $GITHUB_PATH
26+
run: .github/scripts/install-yq.sh
3427

3528
- name: 'Read nightly channel from rust-toolchain.toml'
3629
id: toolchain-meta
@@ -88,14 +81,7 @@ jobs:
8881
submodules: recursive
8982

9083
- name: Install yq
91-
run: |
92-
set -euo pipefail
93-
YQ_VERSION="v4.52.4"
94-
mkdir -p "$HOME/.local/bin"
95-
wget -qO "$HOME/.local/bin/yq" \
96-
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
97-
chmod +x "$HOME/.local/bin/yq"
98-
echo "$HOME/.local/bin" >> $GITHUB_PATH
84+
run: .github/scripts/install-yq.sh
9985

10086
- name: 'Read nightly channel from rust-toolchain.toml'
10187
id: toolchain-meta
@@ -142,14 +128,7 @@ jobs:
142128
submodules: recursive
143129

144130
- name: Install yq
145-
run: |
146-
set -euo pipefail
147-
YQ_VERSION="v4.52.4"
148-
mkdir -p "$HOME/.local/bin"
149-
wget -qO "$HOME/.local/bin/yq" \
150-
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
151-
chmod +x "$HOME/.local/bin/yq"
152-
echo "$HOME/.local/bin" >> $GITHUB_PATH
131+
run: .github/scripts/install-yq.sh
153132

154133
- name: 'Read nightly channel from rust-toolchain.toml'
155134
id: toolchain-meta

0 commit comments

Comments
 (0)