Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- instance-size:small
steps:
- name: Setup GitHub CLI
uses: shogo452/setup-gh-cli@main
uses: shogo452/setup-gh-cli@${{ github.ref }}
with:
ARCH: amd64
arm:
Expand All @@ -25,7 +25,7 @@ jobs:
- instance-size:small
steps:
- name: Setup GitHub CLI
uses: shogo452/setup-gh-cli@main
uses: shogo452/setup-gh-cli@${{ github.ref }}
with:
ARCH: arm64
ubuntu:
Expand All @@ -35,7 +35,7 @@ jobs:
- instance-size:small
steps:
- name: Setup GitHub CLI
uses: shogo452/setup-gh-cli@main
uses: shogo452/setup-gh-cli@${{ github.ref }}
with:
ARCH: amd64
linux-lambda:
Expand All @@ -45,7 +45,7 @@ jobs:
- instance-size:1GB
steps:
- name: Setup GitHub CLI
uses: shogo452/setup-gh-cli@main
uses: shogo452/setup-gh-cli@${{ github.ref }}
with:
ARCH: amd64
arm-lambda:
Expand All @@ -55,7 +55,7 @@ jobs:
- instance-size:1GB
steps:
- name: Setup GitHub CLI
uses: shogo452/setup-gh-cli@main
uses: shogo452/setup-gh-cli@${{ github.ref }}
with:
ARCH: arm64
specific-gh-version:
Expand All @@ -65,7 +65,7 @@ jobs:
- instance-size:small
steps:
- name: Setup GitHub CLI
uses: shogo452/setup-gh-cli@main
uses: shogo452/setup-gh-cli@${{ github.ref }}
with:
ARCH: amd64
GH_VERSION: 2.62.0
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Please refer to the [release page](https://github.com/shogo452/setup-gh-cli/rele
- uses: shogo452/setup-gh-cli@v1.0.7
with:
# Github CLI version
# Default 2.63.2
# Default: Latest Version
GH_VERSION: ''

# Archtecture
# Options are 'arm64' and 'amd64'.
# Default amd64
# Default: amd64
ARCH: ''
```

Expand Down
24 changes: 19 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ branding:

inputs:
GH_VERSION:
description: 'GitHub CLI version'
required: true
default: 2.63.2
description: 'GitHub CLI version (optional, latest version will be used if not specified)'
required: false
default: ''
ARCH:
description: 'Architecture'
required: true
default: amd64

runs:
using: composite
steps:
Expand All @@ -25,6 +24,22 @@ runs:
GH_VERSION: ${{ inputs.GH_VERSION }}
ARCH: ${{ inputs.ARCH }}
run: |
# Get the version number
if [ -z "$GH_VERSION" ]; then
echo "No version specified, fetching latest release version..."
LATEST_VERSION=$(curl -s "https://api.github.com/repos/cli/cli/releases" | \
grep -Po '"tag_name": "v\K[0-9]+\.[0-9]+\.[0-9]+(?=")' | \
grep -vE "(rc|alpha|beta|preview)" | \
head -n1)

if [ -z "$LATEST_VERSION" ]; then
echo "Failed to fetch latest stable version"
exit 1
fi
GH_VERSION=$LATEST_VERSION
echo "Latest stable version: $GH_VERSION"
fi

# Validate version number
if ! [[ $GH_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version number: $GH_VERSION"
Expand All @@ -41,7 +56,6 @@ runs:
# Download and extract gh
DOWNLOAD_URL="https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${ARCH}.tar.gz"
EXTRACT_DIR="gh_${GH_VERSION}_linux_${ARCH}"

wget "$DOWNLOAD_URL" -P /tmp
tar -xzf "/tmp/gh_${GH_VERSION}_linux_${ARCH}.tar.gz" -C /tmp
mkdir -p /tmp/gh-cli
Expand Down