From a06c5d2d52a36402e129eabfdf08807b70b2a567 Mon Sep 17 00:00:00 2001 From: 1efty <18194777+1efty@users.noreply.github.com> Date: Thu, 12 Nov 2020 02:50:36 -0600 Subject: [PATCH] feat: add new sha256sum option (#23) --- README.md | 2 ++ action.yml | 5 +++++ release.sh | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 18a9a98..d8de30f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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.
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 diff --git a/action.yml b/action.yml index 6286bbe..cc2ad05 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -68,6 +72,7 @@ runs: - ${{ inputs.build_command }} - ${{ inputs.extra_files }} - ${{ inputs.md5sum }} + - ${{ inputs.sha256sum }} branding: icon: 'package' diff --git a/release.sh b/release.sh index e988589..55bbb9e 100755 --- a/release.sh +++ b/release.sh @@ -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 \ @@ -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