Skip to content

Commit

Permalink
Improve docs and shell (#7)
Browse files Browse the repository at this point in the history
* try remove extra bash -c

* try to separte ldflags prefix and ldflags

* adjust comments and parameter order

* remove useless param

* improve docs
  • Loading branch information
wangyoucao577 authored Mar 21, 2020
1 parent 222c25e commit f57233f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -47,8 +48,8 @@ jobs:
| project_path | **Optional** | Where to run `go build`. <br>Use `.` by default. |
| binary_name | **Optional** | Specify another binary name if do not want to use repository basename. <br>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

Expand Down Expand Up @@ -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)

1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ runs:
- ${{ inputs.ldflags }}
- ${{ inputs.project_path }}
- ${{ inputs.binary_name }}
- ${{ inputs.compression }}
- ${{ inputs.pre_command }}
branding:
icon: 'package'
Expand Down
11 changes: 6 additions & 5 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f57233f

Please sign in to comment.