From 18e80432eedb910720769a5015d46ad970eb010a Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 9 Sep 2022 17:05:30 -0700 Subject: [PATCH 1/5] Add support to produce zip files for all platforms --- README.md | 1 + action.yml | 5 +++++ release.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e39869..b47f686 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ jobs: | 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. | +| zip_assets | **Optional** | Upload executable binaries published in a `.zip` package. `FALSE` by default. | ### Advanced Example diff --git a/action.yml b/action.yml index 768ba56..3c23c90 100644 --- a/action.yml +++ b/action.yml @@ -91,6 +91,10 @@ inputs: description: 'Compress assets before uploading' required: false default: 'TRUE' + zip_assets: + description: 'Produce zip file assets for all platforms' + required: false + default: 'FALSE' runs: using: 'docker' @@ -117,6 +121,7 @@ runs: - ${{ inputs.retry }} - ${{ inputs.post_command }} - ${{ inputs.compress_assets }} + - ${{ inputs.zip_assets }} branding: icon: 'package' diff --git a/release.sh b/release.sh index 767ac32..7110e2d 100755 --- a/release.sh +++ b/release.sh @@ -109,7 +109,7 @@ if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; then 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_ZIP_ASSETS} == 'TRUE' ]; then RELEASE_ASSET_EXT='.zip' MEDIA_TYPE='application/zip' RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} From bdf1d7ed4209c6023c643c1d4937b278f0686f11 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 14 Sep 2022 16:19:04 -0700 Subject: [PATCH 2/5] Use compress_assets_format parameter to control binary packaged format --- README.md | 4 ++-- action.yml | 7 +++---- release.sh | 13 +++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b47f686..4751d91 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,8 @@ jobs: | 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. | | 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. | -| zip_assets | **Optional** | Upload executable binaries published in a `.zip` package. `FALSE` by default. | +| compress_assets | **Optional** | Upload executable binaries rather than `.tar.gz` or `.zip` package. | +| compress_assets_format | **Optional** | Values of `zip` or `gz` will produce executable binaries in the specified format . `""` default. By default linux binaries will be `gz` format and windows binaries will be `zip`| ### Advanced Example diff --git a/action.yml b/action.yml index 3c23c90..a0d2aa1 100644 --- a/action.yml +++ b/action.yml @@ -91,10 +91,10 @@ inputs: description: 'Compress assets before uploading' required: false default: 'TRUE' - zip_assets: - description: 'Produce zip file assets for all platforms' + compress_assets_format: + description: 'Defines compression method for compressed assets' required: false - default: 'FALSE' + default: '' runs: using: 'docker' @@ -121,7 +121,6 @@ runs: - ${{ inputs.retry }} - ${{ inputs.post_command }} - ${{ inputs.compress_assets }} - - ${{ inputs.zip_assets }} branding: icon: 'package' diff --git a/release.sh b/release.sh index 7110e2d..6218d48 100755 --- a/release.sh +++ b/release.sh @@ -106,16 +106,17 @@ ls -lha if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; 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' || ${INPUT_ZIP_ASSETS} == 'TRUE' ]; then + if [ ${INPUT_GOOS} != 'windows' || ${INPUT_COMPRESS_ASSETS_FORMAT} == 'gz' ]; then + RELEASE_ASSET_EXT='.tar.gz' + MEDIA_TYPE='application/gzip' + RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} + ( shopt -s dotglob; tar cvfz ${RELEASE_ASSET_FILE} * ) + fi + if [ ${INPUT_GOOS} == 'windows' || ${INPUT_COMPRESS_ASSETS_FORMAT} == '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 RELEASE_ASSET_EXT=${EXT} From d8240ff5a61f4c27fb7b810eb4637c2238b56875 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 19 Sep 2022 14:55:18 -0700 Subject: [PATCH 3/5] Revert "Use compress_assets_format parameter to control binary packaged format" This reverts commit bdf1d7ed4209c6023c643c1d4937b278f0686f11. --- README.md | 4 ++-- action.yml | 7 ++++--- release.sh | 13 ++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4751d91..b47f686 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,8 @@ jobs: | 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. | | 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 executable binaries rather than `.tar.gz` or `.zip` package. | -| compress_assets_format | **Optional** | Values of `zip` or `gz` will produce executable binaries in the specified format . `""` default. By default linux binaries will be `gz` format and windows binaries will be `zip`| +| compress_assets | **Optional** | Upload execuable binaries rather than `.tar.gz` or `.zip` package. | +| zip_assets | **Optional** | Upload executable binaries published in a `.zip` package. `FALSE` by default. | ### Advanced Example diff --git a/action.yml b/action.yml index a0d2aa1..3c23c90 100644 --- a/action.yml +++ b/action.yml @@ -91,10 +91,10 @@ inputs: description: 'Compress assets before uploading' required: false default: 'TRUE' - compress_assets_format: - description: 'Defines compression method for compressed assets' + zip_assets: + description: 'Produce zip file assets for all platforms' required: false - default: '' + default: 'FALSE' runs: using: 'docker' @@ -121,6 +121,7 @@ runs: - ${{ inputs.retry }} - ${{ inputs.post_command }} - ${{ inputs.compress_assets }} + - ${{ inputs.zip_assets }} branding: icon: 'package' diff --git a/release.sh b/release.sh index 6218d48..7110e2d 100755 --- a/release.sh +++ b/release.sh @@ -106,17 +106,16 @@ ls -lha if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; then # compress and package binary, then calculate checksum - if [ ${INPUT_GOOS} != 'windows' || ${INPUT_COMPRESS_ASSETS_FORMAT} == 'gz' ]; then - RELEASE_ASSET_EXT='.tar.gz' - MEDIA_TYPE='application/gzip' - RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} - ( shopt -s dotglob; tar cvfz ${RELEASE_ASSET_FILE} * ) - fi - if [ ${INPUT_GOOS} == 'windows' || ${INPUT_COMPRESS_ASSETS_FORMAT} == 'zip' ]; then + RELEASE_ASSET_EXT='.tar.gz' + MEDIA_TYPE='application/gzip' + RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} + if [ ${INPUT_GOOS} == 'windows' || ${INPUT_ZIP_ASSETS} == 'TRUE' ]; 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 RELEASE_ASSET_EXT=${EXT} From de6f3eb742495c29b3d12ebec13aad45e5f7fded Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 19 Sep 2022 14:55:41 -0700 Subject: [PATCH 4/5] Revert "Add support to produce zip files for all platforms" This reverts commit 18e80432eedb910720769a5015d46ad970eb010a. --- README.md | 1 - action.yml | 5 ----- release.sh | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index b47f686..4e39869 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,6 @@ jobs: | 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. | -| zip_assets | **Optional** | Upload executable binaries published in a `.zip` package. `FALSE` by default. | ### Advanced Example diff --git a/action.yml b/action.yml index 3c23c90..768ba56 100644 --- a/action.yml +++ b/action.yml @@ -91,10 +91,6 @@ inputs: description: 'Compress assets before uploading' required: false default: 'TRUE' - zip_assets: - description: 'Produce zip file assets for all platforms' - required: false - default: 'FALSE' runs: using: 'docker' @@ -121,7 +117,6 @@ runs: - ${{ inputs.retry }} - ${{ inputs.post_command }} - ${{ inputs.compress_assets }} - - ${{ inputs.zip_assets }} branding: icon: 'package' diff --git a/release.sh b/release.sh index 7110e2d..767ac32 100755 --- a/release.sh +++ b/release.sh @@ -109,7 +109,7 @@ if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; then RELEASE_ASSET_EXT='.tar.gz' MEDIA_TYPE='application/gzip' RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} - if [ ${INPUT_GOOS} == 'windows' || ${INPUT_ZIP_ASSETS} == 'TRUE' ]; then + if [ ${INPUT_GOOS} == 'windows' ]; then RELEASE_ASSET_EXT='.zip' MEDIA_TYPE='application/zip' RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME}${RELEASE_ASSET_EXT} From e07259683d6c84c0e7e1af90737464e803a33798 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 19 Sep 2022 17:03:12 -0700 Subject: [PATCH 5/5] Use auto, zip, or off values to compress assets --- README.md | 2 +- release.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e39869..6a31c5b 100644 --- a/README.md +++ b/README.md @@ -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}`.
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 diff --git a/release.sh b/release.sh index 767ac32..e5e6c1b 100755 --- a/release.sh +++ b/release.sh @@ -104,12 +104,13 @@ 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} @@ -117,11 +118,14 @@ if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; then 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)