From f57233f5e37538f234ae0e0d85f75e084e3dfb25 Mon Sep 17 00:00:00 2001 From: Jay Zhang Date: Sat, 21 Mar 2020 17:44:27 +0800 Subject: [PATCH] Improve docs and shell (#7) * try remove extra bash -c * try to separte ldflags prefix and ldflags * adjust comments and parameter order * remove useless param * improve docs --- README.md | 8 ++++++-- action.yml | 1 - release.sh | 11 ++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dd244c5..e200650 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Automatically publish `Go` binaries to Github Release Assets through Github Acti - Publish `.zip` instead of `.tar.gz` for `windows`. - No `musl` library dependency issue on `linux`. - Support extra command that will be executed before `go build`. You may want to use it to solve dependency if you're NOT using [Go Modules](https://github.com/golang/go/wiki/Modules). +- Rich parameters support for `go build`(e.g. `-ldflags`, etc.). ## Usage @@ -47,8 +48,8 @@ jobs: | project_path | **Optional** | Where to run `go build`.
Use `.` by default. | | binary_name | **Optional** | Specify another binary name if do not want to use repository basename.
Use your repository's basename if not set. | | pre_command | **Optional** | Extra command that will be executed before `go build`. You may want to use it to solve dependency if you're NOT using [Go Modules](https://github.com/golang/go/wiki/Modules). | -| build_flags | **Optional** | Additional arguments to pass the go build command. | -| ldflags | **Optional** | Values to provide to the -ldflags argument. | +| build_flags | **Optional** | Additional arguments to pass the `go build` command. | +| ldflags | **Optional** | Values to provide to the `-ldflags` argument. | ### Advanced Example @@ -85,3 +86,6 @@ jobs: binary_name: "test-binary" ``` +### More Examples +- [wangyoucao577/vt2geojson - Release Go Binaries](https://github.com/wangyoucao577/vt2geojson/blob/master/.github/workflows/release.yml) + diff --git a/action.yml b/action.yml index 9921385..15b21ae 100644 --- a/action.yml +++ b/action.yml @@ -51,7 +51,6 @@ runs: - ${{ inputs.ldflags }} - ${{ inputs.project_path }} - ${{ inputs.binary_name }} - - ${{ inputs.compression }} - ${{ inputs.pre_command }} branding: icon: 'package' diff --git a/release.sh b/release.sh index c5bd955..257b094 100755 --- a/release.sh +++ b/release.sh @@ -17,20 +17,21 @@ if [ ! -z "${INPUT_PRE_COMMAND}" ]; then ${INPUT_PRE_COMMAND} fi -# build binary +# binary suffix cd ${INPUT_PROJECT_PATH} EXT='' if [ ${INPUT_GOOS} == 'windows' ]; then EXT='.exe' fi -GO_LDFLAGS='' +# prefix for ldflags +LDFLAGS_PREFIX='' if [ ! -z "${INPUT_LDFLAGS}" ]; then - GO_LDFLAGS="-ldflags \"${INPUT_LDFLAGS}\"" + LDFLAGS_PREFIX="-ldflags" fi - -bash -c "GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} go build ${INPUT_BUILD_FLAGS} ${GO_LDFLAGS} -o ${BINARY_NAME}${EXT}" +# build +GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} go build -o ${BINARY_NAME}${EXT} ${INPUT_BUILD_FLAGS} ${LDFLAGS_PREFIX} "${INPUT_LDFLAGS}" ls -lh