Skip to content

Commit

Permalink
feat: Added rename support (#6)
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
  • Loading branch information
stevehipwell committed May 10, 2024
1 parent ac48fbd commit ef2ec92
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

## [UNRELEASED]

### Added

- Added support for renaming tool binaries. ([#6](https://github.com/action-stars/install-tool-from-github-release/pull/6)) _@stevehipwell_

## [v0.2.2] - 2024-01-31

### Changed
Expand Down
25 changes: 22 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ inputs:
filename_format_windows:
description: Filename format to use when the platform is Windows.
required: false
rename:
description: Rename a tool after it is installed; <before>=<after>.
required: false
check_command:
description: Command to test if the tool was installed correctly.
required: false
Expand All @@ -91,22 +94,23 @@ runs:
repository: ${{ inputs.repository }}
tag_prefix: ${{ inputs.tag_prefix }}
version: ${{ inputs.version }}

- name: Derive platform URLs
id: platform_urls
shell: bash
run: |
set -euo pipefail
if [[ -n "${{ inputs.filename_format_linux }}" ]]
then
echo "linux_url=https://github.com/${{ inputs.owner }}/${{ inputs.repository }}/releases/download/${{ inputs.tag_prefix }}{version}/${{ inputs.filename_format_linux }}" >> "${GITHUB_OUTPUT}"
fi
if [[ -n "${{ inputs.filename_format_macos }}" ]]
then
echo "macos_url=https://github.com/${{ inputs.owner }}/${{ inputs.repository }}/releases/download/${{ inputs.tag_prefix }}{version}/${{ inputs.filename_format_macos }}" >> "${GITHUB_OUTPUT}"
fi
if [[ -n "${{ inputs.filename_format_windows }}" ]]
then
echo "windows_url=https://github.com/${{ inputs.owner }}/${{ inputs.repository }}/releases/download/${{ inputs.tag_prefix }}{version}/${{ inputs.filename_format_windows }}" >> "${GITHUB_OUTPUT}"
Expand All @@ -132,6 +136,21 @@ runs:
url: https://github.com/${{ inputs.owner }}/${{ inputs.repository }}/releases/download/${{ inputs.tag_prefix }}{version}/${{ inputs.filename_format }}
version: ${{ steps.version.outputs.version }}

- name: Rename
if: inputs.rename
shell: bash
run: |
set -euo pipefail
input="${{ inputs.rename }}"
before="${input%=*}"
after="${input#*=}"
before_path="$(which "${before}")"
after_path="$(dirname "${before_path}")/${after}"
mv -f "${before_path}" "${after_path}"
- name: Check
if: inputs.check_command
shell: bash
Expand Down

0 comments on commit ef2ec92

Please sign in to comment.