diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 469c241..4eb74d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,8 @@ jobs: # Windows ARM64 runners are not widely available yet - os: windows-latest arch: arm64 + - os: macos-latest + arch: x64 include: # Test specific version - os: ubuntu-latest diff --git a/README.md b/README.md index c544bc3..19102b9 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,6 @@ jobs: | Input | Description | Required | Default | |-------|-------------|----------|---------| | `version` | Aptos CLI version (tag). Use 'latest' to automatically fetch the latest release | No | `latest` | -| `install-dir` | Install directory for Aptos CLI (will install to /bin) | No | `$HOME/.aptoscli` | | `movefmt-username` | GitHub username for movefmt repository | No | `movebit` | | `movefmt-repo` | GitHub repository name for movefmt | No | `movefmt` | | `movefmt-version` | movefmt version to install | No | `1.2.3` | @@ -90,7 +89,7 @@ jobs: ## Outputs This action doesn't produce any outputs, but it: -- Installs the Aptos CLI to `$HOME/.aptos/bin` (Linux/macOS) or `%USERPROFILE%\.aptos\bin` (Windows) +- Installs the Aptos CLI to `$HOME/.aptoscli/bin` (Linux/macOS) or `%USERPROFILE%\.aptoscli\bin` (Windows) - Adds the installation directory to `PATH` for subsequent steps - Verifies the installation by running `aptos --version` @@ -131,9 +130,9 @@ curl -s https://api.github.com/repos/aptos-labs/aptos-core/releases/latest | gre # Download and install manually curl -L "https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v7.5.0/aptos-cli-7.5.0-darwin-x86_64.zip" -o aptos.zip unzip aptos.zip -d aptos -mkdir -p "$HOME/.aptos/bin" -mv aptos/aptos "$HOME/.aptos/bin/" -export PATH="$HOME/.aptos/bin:$PATH" +mkdir -p "$HOME/.aptoscli/bin" +mv aptos/aptos "$HOME/.aptoscli/bin/" +export PATH="$HOME/.aptoscli/bin:$PATH" aptos --version ``` diff --git a/action.yml b/action.yml index 46d55e2..7f314bb 100644 --- a/action.yml +++ b/action.yml @@ -8,10 +8,7 @@ inputs: description: "Aptos CLI version (tag). Use 'latest' to automatically fetch the latest release" required: false default: "latest" - install-dir: - description: "Install directory for Aptos CLI (will install to /bin)" - required: false - default: $HOME/.aptoscli + movefmt-username: description: "GitHub username for movefmt repository" required: false @@ -71,18 +68,15 @@ runs: id: cache-aptos uses: actions/cache@v4 with: - path: ${{ inputs.install-dir }}/bin - key: aptos-cli-${{ steps.get_version.outputs.version }}-${{ runner.os }}-${{ runner.arch }} - restore-keys: | - aptos-cli-${{ steps.get_version.outputs.version }}-${{ runner.os }}- - aptos-cli-${{ steps.get_version.outputs.version }}- - aptos-cli- + path: ~/.aptoscli/bin + key: aptos-cli-${{ runner.os }}-${{ runner.arch }}-${{ steps.get_version.outputs.version }}-${{ inputs.movefmt-version }}-${{ inputs.movefmt-username }}-${{ inputs.movefmt-repo }} - name: Build download URL id: dl if: steps.cache-aptos.outputs.cache-hit != 'true' shell: bash run: | + INSTALL_DIR="$HOME/.aptoscli" # Detect OS and arch for asset naming case "${RUNNER_OS}" in Linux) @@ -123,6 +117,7 @@ runs: asset_name="aptos-cli-${{ steps.get_version.outputs.version }}-${os_name}-${arch_name}.zip" url="https://github.com/aptos-labs/aptos-core/releases/download/aptos-cli-v${{ steps.get_version.outputs.version }}/$asset_name" echo "url=$url" >> $GITHUB_OUTPUT + echo "arch_name=$arch_name" >> $GITHUB_OUTPUT - name: Download ZIP archive if: steps.cache-aptos.outputs.cache-hit != 'true' @@ -143,18 +138,20 @@ runs: if: runner.os != 'Windows' && steps.cache-aptos.outputs.cache-hit != 'true' shell: bash run: | + INSTALL_DIR="$HOME/.aptoscli" unzip aptos.zip -d aptos - mkdir -p "${{ inputs.install-dir }}/bin" - mv aptos/aptos "${{ inputs.install-dir }}/bin/" + mkdir -p "$INSTALL_DIR/bin" + mv aptos/aptos "$INSTALL_DIR/bin/" # Add to PATH for subsequent steps - echo "${{ inputs.install-dir }}/bin" >> $GITHUB_PATH + echo "$INSTALL_DIR/bin" >> $GITHUB_PATH - name: Unpack & install (Windows) if: runner.os == 'Windows' && steps.cache-aptos.outputs.cache-hit != 'true' shell: pwsh run: | + $INSTALL_DIR = "$env:USERPROFILE\.aptoscli" Expand-Archive aptos.zip -DestinationPath aptos - $dest="${{ inputs.install-dir }}\bin" + $dest = "$INSTALL_DIR\bin" New-Item -ItemType Directory -Force -Path $dest | Out-Null Move-Item aptos\aptos.exe $dest # Add to PATH for subsequent steps @@ -164,39 +161,32 @@ runs: if: steps.cache-aptos.outputs.cache-hit == 'true' && runner.os != 'Windows' shell: bash run: | + INSTALL_DIR="$HOME/.aptoscli" echo "Using cached Aptos CLI installation" # Add to PATH for subsequent steps - echo "${{ inputs.install-dir }}/bin" >> $GITHUB_PATH + echo "$INSTALL_DIR/bin" >> $GITHUB_PATH - name: Add to PATH (cache hit - Windows) if: steps.cache-aptos.outputs.cache-hit == 'true' && runner.os == 'Windows' shell: pwsh run: | + $INSTALL_DIR = "$env:USERPROFILE\.aptoscli" Write-Host "Using cached Aptos CLI installation" # Add to PATH for subsequent steps - Add-Content -Path $Env:GITHUB_PATH -Value "${{ inputs.install-dir }}\bin" + Add-Content -Path $Env:GITHUB_PATH -Value "$INSTALL_DIR\bin" - name: Verify installation shell: bash run: | + INSTALL_DIR="$HOME/.aptoscli" echo "Installed Aptos CLI version:" - aptos --version - - - name: Cache movefmt CLI - id: cache-movefmt - uses: actions/cache@v4 - with: - path: ${{ inputs.install-dir }}/bin/movefmt* - key: movefmt-${{ inputs.movefmt-version }}-${{ runner.os }}-${{ runner.arch }} - restore-keys: | - movefmt-${{ inputs.movefmt-version }}-${{ runner.os }}- - movefmt-${{ inputs.movefmt-version }}- - movefmt- + "$INSTALL_DIR/bin/aptos" --version - name: Install movefmt CLI - if: steps.cache-movefmt.outputs.cache-hit != 'true' + if: steps.cache-aptos.outputs.cache-hit != 'true' shell: bash run: | + INSTALL_DIR="$HOME/.aptoscli" # Detect OS and arch for movefmt asset naming case "${RUNNER_OS}" in Linux) @@ -250,8 +240,8 @@ runs: exit 1 fi # Install on Windows - mkdir -p "${{ inputs.install-dir }}/bin" - mv movefmt.exe "${{ inputs.install-dir }}/bin/" + mkdir -p "$INSTALL_DIR/bin" + mv movefmt.exe "$INSTALL_DIR/bin/" else # Require token for download if [ -z "${{ inputs.github-token }}" ]; then @@ -265,7 +255,7 @@ runs: fi # Install on Linux/macOS chmod +x movefmt - mv movefmt "${{ inputs.install-dir }}/bin/" + mv movefmt "$INSTALL_DIR/bin/" fi echo "movefmt installed successfully" @@ -273,5 +263,6 @@ runs: - name: Verify movefmt installation shell: bash run: | + INSTALL_DIR="$HOME/.aptoscli" echo "Installed movefmt version:" - movefmt --version \ No newline at end of file + "$INSTALL_DIR/bin/movefmt" --version \ No newline at end of file