From ddf8bced8afc8d0c5b468ba75ed07efb37c7a324 Mon Sep 17 00:00:00 2001 From: Jay Zhang Date: Fri, 15 Jul 2022 20:58:07 +0800 Subject: [PATCH] Fix: compress asserts off not work (#89) * fix: compress assets off not work * fix: wrong asset name * docs: update readme for compress_assets * chore: add go 1.18 testing --- .github/workflows/autotest.yml | 32 ++++++++++++++++++++++++++++---- README.md | 1 + action.yml | 1 - release.sh | 4 +++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index e9c1da9..d0ee374 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -42,7 +42,7 @@ jobs: # with: # time: '300s' - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set BUILD_TIME env run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV} - name: Run go-release-action on test code @@ -75,7 +75,7 @@ jobs: goos: [linux] goarch: [amd64] # "" means default - goversion: ["", "1.13", "1.14", "1.15", "1.16", "1.17", "https://golang.org/dl/go1.16.1.linux-amd64.tar.gz"] + goversion: ["", "1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "https://golang.org/dl/go1.16.1.linux-amd64.tar.gz"] steps: # - name: Wait release docker build for release branches # if: contains(github.ref, 'release') @@ -83,7 +83,7 @@ jobs: # with: # time: '300s' - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set GO_VERSION_TAG env run: echo GO_VERSION_TAG=$(basename ${{ matrix.goversion }}) >> ${GITHUB_ENV} - name: Run go-release-action on test code @@ -112,7 +112,7 @@ jobs: goarch: [amd64, arm64] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run go-release-action on test code uses: ./ with: @@ -129,3 +129,27 @@ jobs: overwrite: true release_tag: v0.1-test-assets asset_name: testmain-via-makefile-${{ matrix.goos }}-${{ matrix.goarch }} + + compress-assets-off-test: + name: Compress assets off Test + runs-on: ubuntu-latest + strategy: + matrix: + goos: [linux, windows, darwin] + goarch: [amd64] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Run go-release-action on test code + uses: ./ + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + project_path: ./test/ + binary_name: testmain + pre_command: go mod init localtest + build_flags: -v + overwrite: true + release_tag: v0.1-test-assets + compress_assets: false \ No newline at end of file diff --git a/README.md b/README.md index 381bea5..4742301 100644 --- a/README.md +++ b/README.md @@ -73,6 +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. | ### Advanced Example diff --git a/action.yml b/action.yml index ad1b55d..768ba56 100644 --- a/action.yml +++ b/action.yml @@ -87,7 +87,6 @@ inputs: description: 'Extra command that will be executed for teardown work' required: false default: '' - compress_assets: description: 'Compress assets before uploading' required: false diff --git a/release.sh b/release.sh index 2dbae21..767ac32 100755 --- a/release.sh +++ b/release.sh @@ -118,8 +118,10 @@ if [ ${INPUT_COMPRESS_ASSETS^^} == 'TRUE' ]; then ( shopt -s dotglob; tar cvfz ${RELEASE_ASSET_FILE} * ) fi else - RELEASE_ASSET_FILE=${RELEASE_ASSET_NAME} + 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} fi MD5_SUM=$(md5sum ${RELEASE_ASSET_FILE} | cut -d ' ' -f 1) SHA256_SUM=$(sha256sum ${RELEASE_ASSET_FILE} | cut -d ' ' -f 1)