Skip to content

Commit

Permalink
Feature/release name (#77)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
malud authored Feb 22, 2022
1 parent 4798462 commit 157df1c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`. <br>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. |
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,6 +103,7 @@ runs:
- ${{ inputs.md5sum }}
- ${{ inputs.sha256sum }}
- ${{ inputs.release_tag }}
- ${{ inputs.release_name }}
- ${{ inputs.overwrite }}
- ${{ inputs.asset_name }}
- ${{ inputs.retry }}
Expand Down
13 changes: 9 additions & 4 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 157df1c

Please sign in to comment.