Skip to content

Commit 88be646

Browse files
committed
fix(ci): use gh with token for xlings download (fix API rate limit)
curl without auth token hits GitHub API rate limits on CI runners. Restore gh-based download with github.token passed as input to the setup-toolchain action.
1 parent 1d7f67e commit 88be646

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

.github/actions/setup-toolchain/action.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
11
name: Setup C++23 Toolchain
22
description: Install xlings and project dependencies declared in .xlings.json
33

4+
inputs:
5+
token:
6+
description: 'GitHub token for downloading xlings releases'
7+
required: true
8+
49
runs:
510
using: composite
611
steps:
712
- name: Install xlings (linux)
813
if: runner.os == 'Linux'
914
shell: bash
1015
run: |
11-
LATEST_VERSION=$(curl -s https://api.github.com/repos/d2learn/xlings/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
16+
LATEST_VERSION=$(gh release view --repo d2learn/xlings --json tagName -q '.tagName')
1217
VERSION_NUM=${LATEST_VERSION#v}
1318
TARBALL="xlings-${VERSION_NUM}-linux-x86_64.tar.gz"
14-
curl -sL "https://github.com/d2learn/xlings/releases/download/${LATEST_VERSION}/${TARBALL}" -o "/tmp/${TARBALL}"
19+
gh release download "$LATEST_VERSION" --repo d2learn/xlings --pattern "$TARBALL" --dir /tmp
1520
mkdir -p "$HOME/.xlings"
16-
tar -xzf "/tmp/${TARBALL}" -C "$HOME/.xlings" --strip-components=1
21+
tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1
1722
"$HOME/.xlings/bin/xlings" self install
23+
env:
24+
GH_TOKEN: ${{ inputs.token }}
1825

1926
- name: Install xlings (macos)
2027
if: runner.os == 'macOS'
2128
shell: bash
2229
run: |
23-
LATEST_VERSION=$(curl -s https://api.github.com/repos/d2learn/xlings/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
30+
LATEST_VERSION=$(gh release view --repo d2learn/xlings --json tagName -q '.tagName')
2431
VERSION_NUM=${LATEST_VERSION#v}
2532
ARCH=$(uname -m)
2633
TARBALL="xlings-${VERSION_NUM}-macosx-${ARCH}.tar.gz"
27-
curl -sL "https://github.com/d2learn/xlings/releases/download/${LATEST_VERSION}/${TARBALL}" -o "/tmp/${TARBALL}"
34+
gh release download "$LATEST_VERSION" --repo d2learn/xlings --pattern "$TARBALL" --dir /tmp
2835
mkdir -p "$HOME/.xlings"
29-
tar -xzf "/tmp/${TARBALL}" -C "$HOME/.xlings" --strip-components=1
36+
tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1
3037
xattr -dr com.apple.quarantine "$HOME/.xlings" 2>/dev/null || true
3138
"$HOME/.xlings/bin/xlings" self install
39+
env:
40+
GH_TOKEN: ${{ inputs.token }}
3241

3342
- name: Install xlings (windows)
3443
if: runner.os == 'Windows'

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ jobs:
8585
steps:
8686
- uses: actions/checkout@v4
8787
- uses: ./.github/actions/setup-toolchain
88+
with:
89+
token: ${{ github.token }}
8890

8991
- name: Configure (linux)
9092
if: runner.os == 'Linux'

0 commit comments

Comments
 (0)