diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ea5e334..cd86d5b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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 diff --git a/README.md b/README.md index b520f97..f5bc1e7 100644 --- a/README.md +++ b/README.md @@ -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: '' ``` diff --git a/action.yml b/action.yml index 33d4025..fad23fd 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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" @@ -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