Skip to content

Commit d5316f1

Browse files
authored
feat: add gomips support (#173)
1 parent ec68290 commit d5316f1

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ jobs:
6161
| goos | **Mandatory** | `GOOS` is the running program's operating system target: one of `darwin`, `freebsd`, `linux`, and so on. |
6262
| goarch | **Mandatory** | `GOARCH` is the running program's architecture target: one of `386`, `amd64`, `arm`, `arm64`, `s390x`, `loong64` and so on. |
6363
| goamd64 | **Optional** | `GOAMD64` is the running programs amd64 microarchitecture level, which is available since `go1.18`. It should only be used when `GOARCH` is `amd64`: one of `v1`, `v2`, `v3`, `v4`. |
64-
| goarm | **Optional** | `GOARM` is the running programs arm microarchitecture level, which is available since `go1.1`. It should only be used when `GOARCH` is `arm`: one of `5`, `6`, `7`, |
64+
| goarm | **Optional** | `GOARM` is the running programs arm microarchitecture level, which is available since `go1.1`. It should only be used when `GOARCH` is `arm`: one of `5`, `6`, `7`. |
65+
| gomips | **Optional** | `GOMIPS` is the running programs arm microarchitecture level, which is available since `go1.13`. It should only be used when `GOARCH` is one of `mips`, `mipsle`, `mips64`, `mips64le`: one of `hardfloat`, `softfloat`. |
6566
| goversion | **Optional** | The `Go` compiler version. `latest`([check it here](https://go.dev/VERSION?m=text)) by default, optional `1.13`, `1.14`, `1.15`, `1.16`, `1.17`, `1.18`, `1.19`. You can also define a specific minor release, such as `1.19.5`. <br>Alternatively takes a download URL or a path to go.mod instead of version string. Make sure your URL references the `linux-amd64` package. You can find the URL on [Go - Downloads](https://go.dev/dl/).<br>e.g., `https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz`. |
6667
| project_path | **Optional** | Where to run `go build`. <br>Use `.` by default. <br>If enable `multi_binaries: true`, you can use `project_path: ./cmd/...` or `project_path: ./cmd/app1 ./cmd/app2` to build multiple binaries and include them in one package. |
6768
| binary_name | **Optional** | Specify another binary name if do not want to use repository basename. <br>Use your repository's basename if not set. |

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
description: 'GOARM is the running programs arm microarchitecture level: ARMv5,ARMv6,ARMv7'
2424
required: false
2525
default: ''
26+
gomips:
27+
description: 'GOMIPS is the running programs mips microarchitecture level: hardfloat,softfloat'
28+
required: false
29+
default: ''
2630
goversion:
2731
description: 'The `Go` compiler version.'
2832
required: false
@@ -121,6 +125,7 @@ runs:
121125
- ${{ inputs.goarch }}
122126
- ${{ inputs.goamd64 }}
123127
- ${{ inputs.goarm }}
128+
- ${{ inputs.gomips }}
124129
- ${{ inputs.goversion }}
125130
- ${{ inputs.build_flags}}
126131
- ${{ inputs.ldflags }}

release.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ fi
2626
if [ ! -z "${INPUT_GOARM}" ] && [[ "${INPUT_GOARCH}" == 'arm' ]]; then
2727
RELEASE_ASSET_NAME=${BINARY_NAME}-${RELEASE_TAG}-${INPUT_GOOS}-${INPUT_GOARCH}v${INPUT_GOARM}
2828
fi
29+
if [ ! -z "${INPUT_GOMIPS}" ] && [[ "${INPUT_GOARCH}" -eq 'mips' || "${INPUT_GOARCH}" -eq 'mipsle' || "${INPUT_GOARCH}" -eq 'mips64' || "${INPUT_GOARCH}" -eq 'mips64le' ]]; then
30+
RELEASE_ASSET_NAME=${BINARY_NAME}-${RELEASE_TAG}-${INPUT_GOOS}-${INPUT_GOARCH}-${INPUT_GOMIPS}
31+
fi
2932
if [ ! -z "${INPUT_ASSET_NAME}" ]; then
3033
RELEASE_ASSET_NAME=${INPUT_ASSET_NAME}
3134
fi
@@ -95,6 +98,22 @@ else
9598
fi
9699
fi
97100

101+
# fulfill GOMIPS option
102+
if [ ! -z "${INPUT_GOMIPS}" ]; then
103+
if [[ "${INPUT_GOARCH}" =~ mips ]]; then
104+
GOMIPS_FLAG="${INPUT_GOMIPS}"
105+
else
106+
echo "GOMIPS should only be use with mips arch." >>/dev/stderr
107+
GOMIPS_FLAG=""
108+
fi
109+
else
110+
if [[ "${INPUT_GOARCH}" =~ mips ]]; then
111+
GOMIPS_FLAG=""
112+
else
113+
GOMIPS_FLAG=""
114+
fi
115+
fi
116+
98117

99118
# build
100119
BUILD_ARTIFACTS_FOLDER=build-artifacts-$(date +%s)
@@ -104,20 +123,20 @@ if [ ${INPUT_MULTI_BINARIES^^} == 'TRUE' ]; then
104123

105124
# leverage golang feature to support multiple binaries
106125
# for example, 'go build -o xxx ./cmd/...' or 'go build -o xxx ./cmd/app1 ./cmd/app2' to generate multiple binaries'
107-
GOAMD64=${GOAMD64_FLAG} GOARM=${GOARM_FLAG} GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} ${INPUT_BUILD_COMMAND} ${INPUT_BUILD_FLAGS} -o ${BUILD_ARTIFACTS_FOLDER} ${INPUT_PROJECT_PATH}
126+
GOAMD64=${GOAMD64_FLAG} GOARM=${GOARM_FLAG} GOMIPS=${GOMIPS_FLAG} GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} ${INPUT_BUILD_COMMAND} ${INPUT_BUILD_FLAGS} -o ${BUILD_ARTIFACTS_FOLDER} ${INPUT_PROJECT_PATH}
108127
else
109128
RELEASE_ASSET_DIR=${INPUT_PROJECT_PATH}/${BUILD_ARTIFACTS_FOLDER}
110129
mkdir -p ${RELEASE_ASSET_DIR}
111130
cd ${INPUT_PROJECT_PATH}
112131
if [[ "${INPUT_BUILD_COMMAND}" =~ ^make.* ]]; then
113132
# start with make, assumes using make to build golang binaries, execute it directly
114-
GOAMD64=${GOAMD64_FLAG} GOARM=${GOARM_FLAG} GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} eval ${INPUT_BUILD_COMMAND}
133+
GOAMD64=${GOAMD64_FLAG} GOARM=${GOARM_FLAG} GOMIPS=${GOMIPS_FLAG} GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} eval ${INPUT_BUILD_COMMAND}
115134
if [ -f "${BINARY_NAME}${EXT}" ]; then
116135
# assumes the binary will be generated in current dir, copy it for later processes
117136
cp ${BINARY_NAME}${EXT} ${BUILD_ARTIFACTS_FOLDER}/
118137
fi
119138
else
120-
GOAMD64=${GOAMD64_FLAG} GOARM=${GOARM_FLAG} GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} ${INPUT_BUILD_COMMAND} -o ${BUILD_ARTIFACTS_FOLDER}/${BINARY_NAME}${EXT} ${INPUT_BUILD_FLAGS} ${LDFLAGS_PREFIX} "${INPUT_LDFLAGS}"
139+
GOAMD64=${GOAMD64_FLAG} GOARM=${GOARM_FLAG} GOMIPS=${GOMIPS_FLAG} GOOS=${INPUT_GOOS} GOARCH=${INPUT_GOARCH} ${INPUT_BUILD_COMMAND} -o ${BUILD_ARTIFACTS_FOLDER}/${BINARY_NAME}${EXT} ${INPUT_BUILD_FLAGS} ${LDFLAGS_PREFIX} "${INPUT_LDFLAGS}"
121140
fi
122141
fi
123142

0 commit comments

Comments
 (0)