diff --git a/README.md b/README.md index b3dad1d..951eb41 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,9 @@ jobs: uses: crazy-max/ghaction-xgo@master with: go_version: ${{ matrix.go_version }} + dest: build + prefix: myapp targets: windows/386,windows/amd64,linux/386,linux/amd64,darwin/386,darwin/amd64 - out: build/myapp v: true x: false ldflags: -s -w @@ -54,7 +55,8 @@ Following inputs can be used as `step.with` keys | Name | Type | Default | Description | |-----------------|---------|----------------------|----------------------------------------------------------------------------------------------------------------------------------| | `go_version` | String | `latest` | Go release to use for cross compilation from those [docker tags](https://hub.docker.com/r/crazymax/xgo/tags/). Example: `1.12.x` | -| `out` | String | `./build/` | Prefix to use for output naming. | +| `dest` | String | `build` | Destination folder to put binaries in. | +| `prefix` | String | | Prefix to use for output naming. Default to package name | | `targets` | String | `*/*` | Comma separated targets to build for. Example: `windows/amd64,linux/386` | | `v` | Bool | `false` | Prints the names of packages as they are compiled | | `x` | Bool | `false` | Prints the build commands as compilation progresses | diff --git a/action.yml b/action.yml index 07e91e2..34761df 100644 --- a/action.yml +++ b/action.yml @@ -10,8 +10,11 @@ inputs: go_version: description: 'Go release to use for cross compilation. Example: 1.12.x' default: 'latest' - out: - description: 'Prefix to use for output naming. Default: ./build/' + dest: + description: 'Destination folder to put binaries in' + default: 'build' + prefix: + description: 'Prefix to use for output naming. Default to package name' targets: description: 'Comma separated targets to build for. Example: windows/amd64,linux/386' default: '*/*' diff --git a/lib/xgo.js b/lib/xgo.js index 3f4549a..588f0e3 100644 --- a/lib/xgo.js +++ b/lib/xgo.js @@ -30,8 +30,9 @@ function run() { const root = path.join(__dirname, '..'); const xgo_version = '0.3.0'; const go_version = core.getInput('go_version'); + const dest = core.getInput('dest'); + const prefix = core.getInput('prefix'); const targets = core.getInput('targets'); - const out = core.getInput('out'); const v = core.getInput('v'); const x = core.getInput('x'); const ldflags = core.getInput('ldflags'); @@ -45,14 +46,14 @@ function run() { if (go_version) { args.push('-go', go_version); } - if (targets) { - args.push('-targets', targets); + if (prefix) { + args.push('-out', prefix); } - if (out) { - args.push('-out', out); + if (dest) { + args.push('-dest', dest); } - else if (repo) { - args.push('-out', path.join('build', path.basename(repo))); + if (targets) { + args.push('-targets', targets); } if (/true/i.test(v)) { args.push('-v'); diff --git a/src/xgo.ts b/src/xgo.ts index eb0df15..b5b4159 100644 --- a/src/xgo.ts +++ b/src/xgo.ts @@ -13,8 +13,9 @@ async function run() { const xgo_version = '0.3.0'; const go_version = core.getInput('go_version'); + const dest = core.getInput('dest'); + const prefix = core.getInput('prefix'); const targets = core.getInput('targets'); - const out = core.getInput('out'); const v = core.getInput('v'); const x = core.getInput('x'); const ldflags = core.getInput('ldflags'); @@ -34,14 +35,15 @@ async function run() { if (go_version) { args.push('-go', go_version); } + if (prefix) { + args.push('-out', prefix); + } + if (dest) { + args.push('-dest', dest); + } if (targets) { args.push('-targets', targets); } - if (out) { - args.push('-out', out); - } else if (repo) { - args.push('-out', path.join('build', path.basename(repo))); - } if (/true/i.test(v)) { args.push('-v'); }