Skip to content

Commit

Permalink
Use auto, zip, or off values to compress assets
Browse files Browse the repository at this point in the history
  • Loading branch information
mjmayer committed Sep 20, 2022
1 parent de6f3eb commit e072596
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -73,7 +73,7 @@ jobs:
| 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. |
| post_command | **Optional** | Extra command that will be executed for teardown work. e.g. you can use it to upload artifacts to AWS s3 or aliyun OSS |
| compress_assets | **Optional** | Upload execuable binaries rather than `.tar.gz` or `.zip` package. |
| compress_assets | **Optional** | `auto` default will produce a `zip` file for Windows and `tar.gz` for others. `zip` will force the use of of `zip`. `OFF` will disable packaging of assets. |

### Advanced Example

Expand Down
10 changes: 7 additions & 3 deletions release.sh
Expand Up @@ -104,24 +104,28 @@ fi
cd ${BUILD_ARTIFACTS_FOLDER}
ls -lha

if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; then
# INPUT_COMPRESS_ASSETS=='TRUE' is used for backwards compatability. `AUTO`, `ZIP`, `OFF` are the recommended values
if [ ${INPUT_COMPRESS_ASSETS^^} == "TRUE" ] || [ ${INPUT_COMPRESS_ASSETS^^} == "AUTO" ] || [ ${INPUT_COMPRESS_ASSETS^^} == "ZIP" ]; then
# compress and package binary, then calculate checksum
RELEASE_ASSET_EXT='.tar.gz'
MEDIA_TYPE='application/gzip'
RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT}
if [ ${INPUT_GOOS} == 'windows' ]; then
if [ ${INPUT_GOOS} == 'windows' ] || [ ${INPUT_COMPRESS_ASSETS^^} == "ZIP" ]; then
RELEASE_ASSET_EXT='.zip'
MEDIA_TYPE='application/zip'
RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT}
( shopt -s dotglob; zip -vr ${RELEASE_ASSET_FILE} * )
else
( shopt -s dotglob; tar cvfz ${RELEASE_ASSET_FILE} * )
fi
else
elif [ ${INPUT_COMPRESS_ASSETS^^} == "OFF" ]; then
RELEASE_ASSET_EXT=${EXT}
MEDIA_TYPE="application/octet-stream"
RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT}
cp ${BINARY_NAME}${EXT} ${RELEASE_ASSET_FILE}
else
echo "Invalid value for INPUT_COMPRESS_ASSETS: ${INPUT_COMPRESS_ASSETS} . Acceptable values are AUTO,ZIP, or OFF."
exit 1
fi
MD5_SUM=$(md5sum ${RELEASE_ASSET_FILE} | cut -d ' ' -f 1)
SHA256_SUM=$(sha256sum ${RELEASE_ASSET_FILE} | cut -d ' ' -f 1)
Expand Down

0 comments on commit e072596

Please sign in to comment.