Skip to content

Commit 4a03985

Browse files
committed
Release Downloader
An action to download and optionally extract binaries from GitHub releases.
0 parents  commit 4a03985

File tree

5 files changed

+443
-0
lines changed

5 files changed

+443
-0
lines changed

.github/workflows/test.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Test
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
name: Test
8+
permissions:
9+
contents: read
10+
11+
strategy:
12+
matrix:
13+
os:
14+
- ubuntu-latest
15+
- windows-latest
16+
- macos-latest
17+
fail-fast: false
18+
19+
runs-on: ${{ matrix.os }}
20+
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@v4
24+
with:
25+
path: action
26+
27+
- name: crane
28+
id: crane
29+
uses: ./action
30+
with:
31+
repository: google/go-containerregistry
32+
destination: bin/extra/crane
33+
file-re: ^crane
34+
os: Darwin
35+
36+
- name: gh
37+
id: gh
38+
uses: ./action
39+
with:
40+
repository: cli/cli
41+
destination: bin/gh
42+
file-re: bin/
43+
version: v2.64.0
44+
os: windows
45+
trace: 1
46+
47+
- name: jd
48+
id: jd
49+
uses: ./action
50+
with:
51+
repository: josephburnett/jd
52+
destination: bin/extra/jd
53+
file-re: bin/
54+
arch: arm64
55+
version: v1.9.0
56+
trace: 1
57+
58+
- name: jq
59+
id: jq
60+
uses: ./action
61+
with:
62+
repository: jqlang/jq
63+
destination: bin/extra/jq
64+
65+
- name: debug
66+
shell: bash
67+
env:
68+
gh_url: ${{ steps.gh.outputs.url }}
69+
gh_path: ${{ steps.gh.outputs.path }}
70+
jd_url: ${{ steps.jd.outputs.url }}
71+
jd_path: ${{ steps.jd.outputs.path }}
72+
crane_url: ${{ steps.crane.outputs.url }}
73+
crane_path: ${{ steps.crane.outputs.path }}
74+
jq_url: ${{ steps.jq.outputs.url }}
75+
jq_path: ${{ steps.jq.outputs.path }}
76+
run: |
77+
: Review
78+
check_item() {
79+
echo "## $1"
80+
echo
81+
echo '```yaml'
82+
echo "url: $2"
83+
echo "path: $3"
84+
echo '```'
85+
echo
86+
echo '### Version'
87+
echo '```sh'
88+
"$3" $4 2>&1 || file "$3"
89+
echo '```'
90+
echo
91+
}
92+
(
93+
check_item crane "$crane_url" "$crane_path" version
94+
check_item gh "$gh_url" "$gh_path" version
95+
check_item jd "$jd_url" "$jd_path" --version
96+
check_item jq "$jq_url" "$jq_path" --version
97+
echo '## Files'
98+
echo '```sh'
99+
find bin
100+
echo '```'
101+
echo
102+
) | tee -a "$GITHUB_STEP_SUMMARY"

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Josh Soref
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[![Test](https://github.com/check-spelling/gh-program-downloader/actions/workflows/test.yml/badge.svg)](https://github.com/check-spelling/gh-program-downloader/actions/workflows/test.yml)
2+
3+
# release-downloader
4+
5+
Action to download and optionally extract binaries from GitHub releases.
6+
7+
## Usage
8+
9+
```yaml
10+
- uses: check-spelling/gh-program-downloader@main
11+
with:
12+
# Repository name. For example cli/cli
13+
# Default: ${{ github.repository }}
14+
repository: ''
15+
16+
# Path to place file(s)
17+
# Default: ${{ github.workspace }}
18+
destination: ''
19+
20+
# Pattern to select file from within the archive
21+
# If omitted, the entire archive is extracted
22+
# Default: none
23+
file-re: ''
24+
25+
# Release version
26+
# Default: latest
27+
version: ''
28+
29+
# OS to use to filter artifacts
30+
# Default: current OS
31+
os: ''
32+
33+
# OS pattern to filter artifacts
34+
# Default: pattern based on ${{ inputs.os }}
35+
os-pattern: ''
36+
37+
# Architecture to use to filter artifacts
38+
# Default: current Architecture
39+
arch: ''
40+
41+
# Architecture pattern to filter artifacts
42+
# Default: pattern based on ${{ inputs.arch }}
43+
arch-pattern: ''
44+
45+
# Personal access token (PAT) used to fetch the repository.
46+
# Default: ${{ github.token }}
47+
token: ''
48+
49+
# Trace action. Set to a value to trace action
50+
# Default: ''
51+
trace:
52+
```
53+
54+
## Outputs
55+
56+
### path
57+
58+
The location of the extracted item(s).
59+
60+
### url
61+
62+
The url of the downloaded artifact.
63+
64+
## Recommended permissions
65+
66+
### None
67+
68+
This action doesn't need access to your repository to perform its action, so if
69+
your workflow is self contained and itself doesn't need anything from the repository,
70+
you could probably use:
71+
72+
```yaml
73+
permisions: {}
74+
```
75+
76+
#### Accessing a release from a different repository that isn't public
77+
78+
If you're retrieving an artifact from a repository other than the current repository and that other repository isn't public, you'll need a token:
79+
80+
```yaml
81+
with:
82+
token: ${{ secrets.TOKEN_FOR_THAT_REPOSITORY }}
83+
```
84+
85+
### Read for your own non public repository
86+
87+
If you're retrieving an artifact from your repository and the repository itself is not public and you aren't providing a `token`, you'd need:
88+
89+
```yaml
90+
permissions:
91+
contents: read
92+
```
93+
94+
Obviously, if your workflow is nontrivial, you may need more permissions for other steps.
95+
96+
# License
97+
98+
The scripts and documentation in this project are released under the [MIT License](LICENSE.txt)

action.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'gh program downloader'
2+
description: 'Download a release'
3+
inputs:
4+
repository:
5+
description: Repository containing release
6+
required: false
7+
default: ${{ github.repository }}
8+
destination:
9+
description: Destination
10+
required: false
11+
default: ${{ github.workspace }}
12+
version:
13+
description: Version to retrieve (defaults to latest)
14+
required: false
15+
default: ''
16+
os:
17+
description: OS to favor (defaults to current)
18+
required: false
19+
default: ''
20+
os-pattern:
21+
description: OS pattern to filter (defaults to calculating based on os)
22+
required: false
23+
default: ''
24+
arch:
25+
description: Architecture to favor (defaults to current)
26+
required: false
27+
default: ''
28+
arch-pattern:
29+
description: Architecture pattern to filter (defaults to calculating based on arch)
30+
required: false
31+
default: ''
32+
file-re:
33+
description: File pattern (in case os/arch aren't enough to select)
34+
required: false
35+
default: ''
36+
token:
37+
description: GitHub Token
38+
required: false
39+
default: ${{ github.token }}
40+
trace:
41+
description: Trace action
42+
required: false
43+
default: ''
44+
outputs:
45+
url:
46+
description: Downloaded artifact URL
47+
value: ${{ steps.action.outputs.url }}
48+
path:
49+
description: Path to file on disk
50+
value: ${{ steps.action.outputs.path }}
51+
runs:
52+
using: "composite"
53+
steps:
54+
- name: Run downloader
55+
id: action
56+
continue-on-error: false
57+
shell: bash
58+
run: |
59+
: Run downloader
60+
$GITHUB_ACTION_PATH/gh-program-downloader
61+
env:
62+
GH_TOKEN: ${{ inputs.token }}
63+
repo: ${{ inputs.repository }}
64+
destination: ${{ inputs.destination }}
65+
version: ${{ inputs.version }}
66+
os: ${{ inputs.os }}
67+
os_re: ${{ inputs.os-pattern }}
68+
arch: ${{ inputs.arch }}
69+
arch_re: ${{ inputs.arch-pattern }}
70+
file_re: ${{ inputs.file-re }}
71+
trace: ${{ inputs.trace }}

0 commit comments

Comments
 (0)