Skip to content

Commit

Permalink
feat: add new sha256sum option (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
1efty authored Nov 12, 2020
1 parent 4ed8996 commit a06c5d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Automatically publish `Go` binaries to Github Release Assets through Github Acti
- Support package extra files into artifacts (e.g., `LICENSE`, `README.md`, etc).
- Support customize build command, e.g., use [packr2](https://github.com/gobuffalo/packr/tree/master/v2)(`packr2 build`) instead of `go build`.
- Support optional `.md5` along with artifacts.
- Support optional `.sha256` along with artifacts.

## Usage

Expand Down Expand Up @@ -57,6 +58,7 @@ jobs:
| ldflags | **Optional** | Values to provide to the `-ldflags` argument. |
| extra_files | **Optional** | Extra files that will be packaged into artifacts either. Multiple files separated by space. Note that extra folders can be allowed either since internal `cp -r` already in use. <br>E.g., `extra_files: LICENSE README.md` |
| md5sum | **Optional** | Publish `.md5` along with artifacts, `TRUE` by default. |
| sha256sum | **Optional** | Publish `.sha256` along with artifacts, `FALSE` by default. |


### Advanced Example
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ inputs:
description: 'Publish `.md5` along with artifacts.'
required: false
default: 'TRUE'
sha256sum:
description: 'Publish `.sha256` along with artifacts.'
required: false
default: 'FALSE'

runs:
using: 'docker'
Expand All @@ -68,6 +72,7 @@ runs:
- ${{ inputs.build_command }}
- ${{ inputs.extra_files }}
- ${{ inputs.md5sum }}
- ${{ inputs.sha256sum }}

branding:
icon: 'package'
Expand Down
12 changes: 12 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ else
tar cvfz ${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} *
fi
MD5_SUM=$(md5sum ${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} | cut -d ' ' -f 1)
SHA256_SUM=$(sha256sum ${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} | cut -d ' ' -f 1)

# update binary and checksum
curl \
Expand All @@ -75,3 +76,14 @@ curl \
"${RELEASE_ASSETS_UPLOAD_URL}?name=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT}.md5"
echo $?
fi

if [ ${INPUT_SHA256SUM^^} == 'TRUE' ]; then
curl \
--fail \
--X POST \
--data ${SHA256_SUM} \
-H 'Content-Type: text/plain' \
-H "Authorization: Bearer ${INPUT_GITHUB_TOKEN}" \
"${RELEASE_ASSETS_UPLOAD_URL}?name=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT}.sha256"
echo $?
fi

0 comments on commit a06c5d2

Please sign in to comment.