Skip to content

Commit

Permalink
Merge pull request dsaltares#23 from maciejp/add-release-name-and-body
Browse files Browse the repository at this point in the history
include release name and body in the output
  • Loading branch information
dsaltares authored May 6, 2021
2 parents d1fe58a + 31b874f commit 11df5f6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 20 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Demo

on:
pull_request:
branches:
- master

jobs:
demo:
name: Demo
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create a subdirectory
run: |
mkdir subdir
- name: Get the latest release
id: get_release
uses: ./
with:
repo: "dsaltares/godot-wild-jam-18"
version: "tags/v0.1.18"
file: "plague-linux.zip"
target: "subdir/plague-linux.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Display the details
run: |
echo ${{ steps.get_release.outputs.version }}
echo ${{ steps.get_release.outputs.name }}
echo ${{ steps.get_release.outputs.body }}
ls -l subdir/plague-linux.zip
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
# Fetch GH Release Asset

This action downloads an asset from a Github release. Private repos are supported.
This action downloads an asset from a GitHub release and provides some release details as output. Private repos are supported.

## Inputs

### `repo`
### `token`

The `org/repo`. Defaults to the current repo.
**Required** The GitHub token. Typically this will be `${{ secrets.GITHUB_TOKEN }}`

### `version`
### `file`

The release version to fetch from. Default `"latest"`. If not `"latest"`, this has to be in the form `tags/<tag_name>` or `<release_id>`.
**Required** The name of the file to be downloaded.

### `file`
### `repo`

**Required** The name of the file in the release.
The `org/repo` containing the release. Defaults to the current repo.

### `target`
### `version`

Optional target file path. Only supports paths to subdirectories of the Github Actions workspace directory
The release version to fetch from in the form `tags/<tag_name>` or `<release_id>`. Defaults to `latest`.

### `token`
### `target`

Optional Personal Access Token to access repository. You need to either specify this or use the ``secrets.GITHUB_TOKEN`` environment variable.
Target file path. Only supports paths to subdirectories of the GitHub Actions workspace directory

## Outputs

### `version`

The version number of the release tag. Can be used to deploy for example to itch.io

### `name`

[Also called a title of a release](https://docs.github.com/en/github/administering-a-repository/managing-releases-in-a-repository). Defaults to the same value as `version` if not specified when creating a release.

### `body`

The body (description) of a release.

## Example usage

```yaml
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "dsaltares/godot-wild-jam-18"
version: "latest"
version: "tags/v0.1.18"
file: "plague-linux.zip"
target: "subdir/plague-linux.zip"
token: ${{ secrets.YOUR_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
```
## Support
Expand Down
17 changes: 10 additions & 7 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ description: 'Downloads an asset from a Github release'

inputs:
repo:
description: 'org/repo to download from'
description: 'The `org/repo` containing the release.'
required: false
default: ''
version:
description: 'version of the release to download from'
description: 'The release version to fetch from in the form `tags/<tag_name>` or `<release_id>`.'
required: false
default: 'latest'
file:
description: 'name of the file in the release to download'
description: 'The name of the file to be downloaded.'
required: true
target:
description: 'name of the target file path'
description: 'Target file path.'
required: false
token:
description: 'optional Personal Access Token to access external repository'
required: false
default: ''
description: 'The GitHub token. Typically this will be secrets.GITHUB_TOKEN'
required: true

runs:
using: 'docker'
Expand All @@ -34,6 +33,10 @@ runs:
outputs:
version:
description: 'The version of the release or tag'
name:
description: 'The name of the release'
body:
description: 'The body of the release'

branding:
icon: 'download-cloud'
Expand Down
4 changes: 4 additions & 0 deletions fetch_github_asset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ fi

ASSET_ID=$(echo $RELEASE_DATA | jq -r ".assets | map(select(.name == \"${INPUT_FILE}\"))[0].id")
TAG_VERSION=$(echo $RELEASE_DATA | jq -r ".tag_name" | sed -e "s/^v//" | sed -e "s/^v.//")
RELEASE_NAME=$(echo $RELEASE_DATA | jq -r ".name")
RELEASE_BODY=$(echo $RELEASE_DATA | jq -r ".body")

if [[ -z "$ASSET_ID" ]]; then
echo "Could not find asset id"
Expand All @@ -60,3 +62,5 @@ curl \
-o ${TARGET}

echo "::set-output name=version::$TAG_VERSION"
echo "::set-output name=name::$RELEASE_NAME"
echo "::set-output name=body::$RELEASE_BODY"

0 comments on commit 11df5f6

Please sign in to comment.