From 157df1cb3b2234aa38ab419e0775598e469cc669 Mon Sep 17 00:00:00 2001 From: Marcel Ludwig Date: Tue, 22 Feb 2022 12:25:11 +0100 Subject: [PATCH] Feature/release name (#77) * Add releasename option from asset-uploader binary * Prepare upcoming release tag for assets-uploader * update description * Fix github-ref tag fallback in combination with a release-name * Fixup: allow empty args --- Dockerfile | 6 +++--- README.md | 1 + action.yml | 5 +++++ release.sh | 13 +++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7380d0d..565c9fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,15 +11,15 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteract ca-certificates \ && rm -rf /var/lib/apt/lists/* -# install latest upx 3.96 by wget instead of `apt install upx-ucl`(only 3.95) +# install latest upx 3.96 by wget instead of `apt install upx-ucl`(only 3.95) RUN wget --no-check-certificate --progress=dot:mega https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz && \ tar -Jxf upx-3.96-amd64_linux.tar.xz && \ mv upx-3.96-amd64_linux /usr/local/ && \ ln -s /usr/local/upx-3.96-amd64_linux/upx /usr/local/bin/upx && \ - upx --version + upx --version # github-assets-uploader to provide robust github assets upload -RUN wget --no-check-certificate --progress=dot:mega https://github.com/wangyoucao577/assets-uploader/releases/download/v0.8.0/github-assets-uploader-v0.8.0-linux-amd64.tar.gz -O github-assets-uploader.tar.gz && \ +RUN wget --no-check-certificate --progress=dot:mega https://github.com/wangyoucao577/assets-uploader/releases/download/v0.9.0/github-assets-uploader-v0.9.0-linux-amd64.tar.gz -O github-assets-uploader.tar.gz && \ tar -zxf github-assets-uploader.tar.gz && \ mv github-assets-uploader /usr/sbin/ && \ rm -f github-assets-uploader.tar.gz && \ diff --git a/README.md b/README.md index 211ffb2..403c55f 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ jobs: | md5sum | **Optional** | Publish `.md5` along with artifacts, `TRUE` by default. | | sha256sum | **Optional** | Publish `.sha256` along with artifacts, `FALSE` by default. | | release_tag | **Optional** | Target release tag to publish your binaries to. It's dedicated to publish binaries on every `push` into one specified release page since there's no target in this case. DON'T set it if you trigger the action by `release: [created]` event as most people do.| +| release_name | **Optional** | Alternative to `release_tag` for release target specification and binary push. The newest release by given `release_name` will be picked from all releases. Useful for e.g. untagged(draft) ones.| | overwrite | **Optional** | Overwrite asset if it's already exist. `FALSE` by default. | | asset_name | **Optional** | Customize asset name if do not want to use the default format `${BINARY_NAME}-${RELEASE_TAG}-${GOOS}-${GOARCH}`.
Make sure set it correctly, especially for matrix usage that you have to append `-${{ matrix.goos }}-${{ matrix.goarch }}`. A valid example could be `asset_name: binary-name-${{ matrix.goos }}-${{ matrix.goarch }}`. | | retry | **Optional** | How many times retrying if upload fails. `3` by default. | diff --git a/action.yml b/action.yml index 75da2c1..b382d58 100644 --- a/action.yml +++ b/action.yml @@ -63,6 +63,10 @@ inputs: description: 'Upload binaries to specified release page that indicated by Git tag.' required: false default: '' + release_name: + description: 'Upload binaries to specified release page that indicated by release name.' + required: false + default: '' overwrite: description: "Overwrite asset if it's already exist." required: false @@ -99,6 +103,7 @@ runs: - ${{ inputs.md5sum }} - ${{ inputs.sha256sum }} - ${{ inputs.release_tag }} + - ${{ inputs.release_name }} - ${{ inputs.overwrite }} - ${{ inputs.asset_name }} - ${{ inputs.retry }} diff --git a/release.sh b/release.sh index e7f306b..e14ed51 100755 --- a/release.sh +++ b/release.sh @@ -7,8 +7,13 @@ if [ x${INPUT_BINARY_NAME} != x ]; then fi RELEASE_TAG=$(basename ${GITHUB_REF}) if [ ! -z "${INPUT_RELEASE_TAG}" ]; then - RELEASE_TAG=${INPUT_RELEASE_TAG} + RELEASE_TAG=${INPUT_RELEASE_TAG} +elif [ ! -z "${INPUT_RELEASE_NAME}" ]; then # prevent upload-asset by tag due to github-ref default if a name is given + RELEASE_TAG="" fi + +RELEASE_NAME=${INPUT_RELEASE_NAME} + RELEASE_ASSET_NAME=${BINARY_NAME}-${RELEASE_TAG}-${INPUT_GOOS}-${INPUT_GOARCH} if [ ! -z "${INPUT_ASSET_NAME}" ]; then RELEASE_ASSET_NAME=${INPUT_ASSET_NAME} @@ -102,19 +107,19 @@ if [ ${INPUT_OVERWRITE^^} == 'TRUE' ]; then fi # update binary and checksum -github-assets-uploader -logtostderr -f ${RELEASE_ASSET_FILE} -mediatype ${MEDIA_TYPE} ${GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS} -repo ${GITHUB_REPOSITORY} -token ${INPUT_GITHUB_TOKEN} -tag ${RELEASE_TAG} -retry ${INPUT_RETRY} +github-assets-uploader -logtostderr -f ${RELEASE_ASSET_FILE} -mediatype ${MEDIA_TYPE} ${GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS} -repo ${GITHUB_REPOSITORY} -token ${INPUT_GITHUB_TOKEN} -tag=${RELEASE_TAG} -releasename=${RELEASE_NAME} -retry ${INPUT_RETRY} if [ ${INPUT_MD5SUM^^} == 'TRUE' ]; then MD5_EXT='.md5' MD5_MEDIA_TYPE='text/plain' echo ${MD5_SUM} >${RELEASE_ASSET_FILE}${MD5_EXT} -github-assets-uploader -logtostderr -f ${RELEASE_ASSET_FILE}${MD5_EXT} -mediatype ${MD5_MEDIA_TYPE} ${GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS} -repo ${GITHUB_REPOSITORY} -token ${INPUT_GITHUB_TOKEN} -tag ${RELEASE_TAG} -retry ${INPUT_RETRY} +github-assets-uploader -logtostderr -f ${RELEASE_ASSET_FILE}${MD5_EXT} -mediatype ${MD5_MEDIA_TYPE} ${GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS} -repo ${GITHUB_REPOSITORY} -token ${INPUT_GITHUB_TOKEN} -tag=${RELEASE_TAG} -releasename=${RELEASE_NAME} -retry ${INPUT_RETRY} fi if [ ${INPUT_SHA256SUM^^} == 'TRUE' ]; then SHA256_EXT='.sha256' SHA256_MEDIA_TYPE='text/plain' echo ${SHA256_SUM} >${RELEASE_ASSET_FILE}${SHA256_EXT} -github-assets-uploader -logtostderr -f ${RELEASE_ASSET_FILE}${SHA256_EXT} -mediatype ${SHA256_MEDIA_TYPE} ${GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS} -repo ${GITHUB_REPOSITORY} -token ${INPUT_GITHUB_TOKEN} -tag ${RELEASE_TAG} -retry ${INPUT_RETRY} +github-assets-uploader -logtostderr -f ${RELEASE_ASSET_FILE}${SHA256_EXT} -mediatype ${SHA256_MEDIA_TYPE} ${GITHUB_ASSETS_UPLOADR_EXTRA_OPTIONS} -repo ${GITHUB_REPOSITORY} -token ${INPUT_GITHUB_TOKEN} -tag=${RELEASE_TAG} -releasename=${RELEASE_NAME} -retry ${INPUT_RETRY} fi # execute post-command if exist, e.g. upload to AWS s3 or aliyun OSS