Skip to content

Commit c83a974

Browse files
Pin upstream speedtest-cli tags
1 parent c7f70d8 commit c83a974

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

.github/workflows/docker.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,42 @@ jobs:
2626
packages: write
2727

2828
steps:
29-
- uses: actions/checkout@v6
29+
- if: github.event_name == 'release'
30+
uses: actions/checkout@v6
31+
with:
32+
ref: ${{ github.event.release.tag_name }}
33+
- if: github.event_name != 'release'
34+
uses: actions/checkout@v6
35+
- name: Resolve upstream ref
36+
id: version
37+
shell: bash
38+
run: |
39+
set -euo pipefail
40+
41+
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
42+
raw_tag='${{ github.event.release.tag_name }}'
43+
44+
if [[ ! "${raw_tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(_[0-9]+)?$ ]]; then
45+
echo "::error::Invalid release tag '${raw_tag}'. Expected vX.Y.Z or vX.Y.Z_N."
46+
exit 1
47+
fi
48+
49+
upstream_ref="${raw_tag%%_*}"
50+
else
51+
upstream_ref="master"
52+
fi
53+
54+
echo "upstream_ref=${upstream_ref}" >> "${GITHUB_OUTPUT}"
55+
- name: Verify upstream tag exists
56+
if: github.event_name == 'release'
57+
shell: bash
58+
run: |
59+
set -euo pipefail
60+
61+
if ! git ls-remote --exit-code --tags https://github.com/librespeed/speedtest-cli.git "refs/tags/${{ steps.version.outputs.upstream_ref }}" > /dev/null; then
62+
echo "::error::Upstream tag '${{ steps.version.outputs.upstream_ref }}' not found."
63+
exit 1
64+
fi
3065
- uses: docker/setup-qemu-action@v4
3166
- uses: docker/setup-buildx-action@v4
3267
- uses: docker/login-action@v4
@@ -45,6 +80,8 @@ jobs:
4580
with:
4681
context: .
4782
platforms: linux/amd64,linux/arm64,linux/arm/v7
83+
build-args: |
84+
UPSTREAM_REF=${{ steps.version.outputs.upstream_ref }}
4885
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4986
cache-to: type=inline
5087
push: ${{ ((github.event_name == 'push' || github.event_name == 'workflow_run') && github.ref == 'refs/heads/master') || github.event_name == 'release' }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
FROM alpine:3.23.4 AS build
2+
ARG UPSTREAM_REF=master
23
RUN apk add --no-cache \
34
bash \
45
git \
56
go \
67
build-base \
78
gcc
8-
RUN git clone https://github.com/librespeed/speedtest-cli librespeed-cli
9+
RUN git clone --depth 1 --branch "${UPSTREAM_REF}" https://github.com/librespeed/speedtest-cli librespeed-cli
910
RUN cd librespeed-cli && \
1011
./build.sh && \
1112
mv out/librespeed-cli-$(go env GOOS)-$(go env GOARCH) /usr/local/bin/librespeed-cli
1213

1314
FROM alpine:3.23.4 AS runtime
1415
COPY --from=build /usr/local/bin/librespeed-cli /usr/local/bin/librespeed-cli
1516
CMD ["/usr/local/bin/librespeed-cli"]
16-

0 commit comments

Comments
 (0)