Skip to content

Commit

Permalink
Fix: compress asserts off not work (#89)
Browse files Browse the repository at this point in the history
* fix: compress assets off not work

* fix: wrong asset name

* docs: update readme for compress_assets

* chore: add go 1.18 testing
  • Loading branch information
wangyoucao577 authored Jul 15, 2022
1 parent fab68fa commit ddf8bce
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/autotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,15 +75,15 @@ 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')
# uses: jakejarvis/wait-action@master
# 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
Expand Down Expand Up @@ -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:
Expand All @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`. <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. |

### Advanced Example

Expand Down
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ddf8bce

Please sign in to comment.