-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
175 lines (161 loc) · 6.39 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Install Tool From GitHub Release
description: Installs a tool from a GitHub repository release.
branding:
icon: cloud
color: gray-dark
inputs:
github_token:
description: GitHub token to use for authentication.
required: true
owner:
description: GitHub repository owner.
required: true
repository:
description: GitHub repository.
required: true
name:
description: Name of the tool being installed, if not set this will default to the repository. This can be used in the filename format as {name}
required: false
tag_prefix:
description: Version tag prefix.
required: false
default: v
arch_amd64:
description: Architecture string for AMD64. This can be used in the filename format as {arch}.
required: false
default: amd64
arch_arm64:
description: Architecture string for ARM64. This can be used in the filename format as {arch}.
required: false
default: arm64
os_linux:
description: OS name when the platform is Linux. This can be used in the filename format as {os}.
required: false
default: linux
os_macos:
description: OS name when the platform is macOS. This can be used in the filename format as {os}.
required: false
default: macos
os_windows:
description: OS name when the platform is Windows. This can be used in the filename format as {os}.
required: false
default: windows
extract:
description: If the download needs extracting.
required: false
default: "true"
subdirectory:
description: Subdirectory within the archive to find the executable(s).
required: false
extract_mode_linux:
description: Extraction mode when the runner platform is Linux; one of tar.gz, zip, 7z, or xar. This can be used in the filename format as {ext}.
required: false
default: tar.gz
extract_mode_macos:
description: Extraction mode when the platform is macOS; one of tar.gz, zip, 7z, or xar. This can be used in the filename format as {ext}.
required: false
default: tar.gz
extract_mode_windows:
description: Extraction mode when the platform is Windows; one of tar.gz, zip, 7z, or xar. This can be used in the filename format as {ext}.
required: false
default: zip
filename_format:
description: Filename format to use if platform specific format hasn't been provided.
required: false
default: "{name}_{version}_{os}_{arch}.{ext}"
filename_format_linux:
description: Filename format to use when the platform is Linux.
required: false
filename_format_macos:
description: Filename format to use when the platform is macOS.
required: false
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
alias:
description: Alias a tool after it is installed; <target>=<alias>.
required: false
check_command:
description: Command to test if the tool was installed correctly.
required: false
version:
description: Version of the GitHub release to lookup; latest is supported.
required: false
default: latest
runs:
using: composite
steps:
- name: Lookup version
id: version
uses: action-stars/github-release-lookup@c86fa936d2dea43eac094b7d3e4ed486a93d1484 # v0.1.0
with:
github_token: ${{ inputs.github_token }}
owner: ${{ inputs.owner }}
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}"
fi
- name: Install tool
uses: pbrisbin/setup-tool-action@be5d9eddf0fdad34d3d35fa8729d70c4a1493ac7 # v2.2.1
with:
github-token: ${{ inputs.github_token }}
name: ${{ inputs.name || inputs.repository }}
no-extract: ${{ !fromJSON(inputs.extract) }}
arch-x64: ${{ inputs.arch_amd64 }}
os-linux: ${{ inputs.os_linux }}
os-darwin: ${{ inputs.os_macos }}
os-win32: ${{ inputs.os_windows }}
ext-linux: ${{ inputs.extract_mode_linux }}
ext-darwin: ${{ inputs.extract_mode_macos }}
ext-win32: ${{ inputs.extract_mode_windows }}
subdir: ${{ inputs.subdirectory }}
url-linux: ${{ inputs.filename_format_linux && steps.platform_urls.outputs.linux_url }}
url-darwin: ${{ inputs.filename_format_macos && steps.platform_urls.outputs.macos_url }}
url-win32: ${{ inputs.filename_format_windows && steps.platform_urls.outputs.windows_url }}
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: Alias
if: inputs.alias
shell: bash
run: |
set -euo pipefail
input="${{ inputs.alias }}"
target="${input%=*}"
alias="${input#*=}"
target_path="$(which "${target}")"
alias_path="$(dirname "${target_path}")/${alias}"
ln -s "${target_path}" "${alias_path}"
- name: Check
if: inputs.check_command
shell: bash
run: ${{ inputs.check_command }}