Skip to content

Commit f1f3766

Browse files
committed
feat(setup): use gh
Using the main `install` script is actually not very robust when used with great frequency. It often fails on 403s due to, I assume, rate limiting, since there's no auth involved. Installing locally is a bit of an edge-case anyway, and it's so far been mostly used on CI, where we have `gh` available to simplify interacting with releases.
1 parent 1daf66e commit f1f3766

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

Diff for: setup/action.yml

+30-3
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,43 @@ inputs:
2020
tag:
2121
description: "Release tag to install, if empty latest is used"
2222
required: false
23+
github-token:
24+
description: "GitHub token used for gh invocations"
25+
default: "${{ github.token }}"
2326

2427
outputs: {}
2528

2629
runs:
2730
using: composite
2831
steps:
2932
- shell: bash
30-
working-directory: /tmp
3133
run: |
32-
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/restyled-io/restyler/main/install |
33-
sudo sh -s -- -t "$TAG"
34+
gh_release() {
35+
gh --repo restyled-io/restyler release "$@"
36+
}
37+
38+
os=$(uname -s | tr '[:upper:]' '[:lower:]')
39+
arch=$(uname -m)
40+
dir=restyler-$os-$arch
41+
ext=tar.gz
42+
tag=$TAG
43+
44+
if [[ -z "$tag" ]]; then
45+
tag=$(gh_release view --json tagName --jq '.tagName')
46+
fi
47+
48+
printf 'Release artifact %s/%s.%s\n' "$tag" "$dir" "$ext"
49+
50+
gh_release download "$TAG" --pattern "$dir.$ext" --output - |
51+
tar xzf -
52+
53+
for bin in "$dir"/*; do
54+
if [ -x "$bin" ]; then
55+
sudo cp -v "$bin" /usr/local/bin/
56+
fi
57+
done
58+
59+
rm -rf "$dir"
3460
env:
61+
GH_TOKEN: ${{ inputs.github-token }}
3562
TAG: ${{ inputs.tag }}

0 commit comments

Comments
 (0)