Skip to content

Commit 493d9db

Browse files
authored
Merge branch 'master' into dima/371-racy-deps
2 parents 4ebcbaa + 2f1ec40 commit 493d9db

File tree

7 files changed

+83
-46
lines changed

7 files changed

+83
-46
lines changed

.github/workflows/ci.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: ci
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
go-version:
12+
- 1.17.x
13+
- 1.16.x
14+
- 1.15.x
15+
- 1.14.x
16+
- 1.13.x
17+
- 1.12.x
18+
- 1.11.x
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Go ${{ matrix.go-version }}
22+
uses: actions/setup-go@v2
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Test
27+
run: |
28+
go vet ./...
29+
go test -tags CI -race ./...
30+
env:
31+
GOPATH: /home/runner/go

.goreleaser.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ build:
2626
goarm: 6
2727
env:
2828
- CGO_ENABLED=0
29-
archive:
29+
archives:
30+
-
3031
name_template: "{{.Binary}}_{{.Version}}_{{.Os}}-{{.Arch}}"
3132
replacements:
3233
amd64: 64bit

.travis.yml

-29
This file was deleted.

magefile.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//+build mage
1+
//go:build mage
2+
// +build mage
23

34
// This is the build script for Mage. The install target is all you really need.
45
// The release target is for generating official releases and is really only
@@ -9,6 +10,7 @@ import (
910
"errors"
1011
"fmt"
1112
"os"
13+
"os/exec"
1214
"path/filepath"
1315
"regexp"
1416
"runtime"
@@ -69,6 +71,9 @@ var releaseTag = regexp.MustCompile(`^v1\.[0-9]+\.[0-9]+$`)
6971

7072
// Generates a new release. Expects a version tag in v1.x.x format.
7173
func Release(tag string) (err error) {
74+
if _, err := exec.LookPath("goreleaser"); err != nil {
75+
return fmt.Errorf("can't find goreleaser: %w", err)
76+
}
7277
if !releaseTag.MatchString(tag) {
7378
return errors.New("TAG environment variable must be in semver v1.x.x format, but was " + tag)
7479
}
@@ -81,8 +86,8 @@ func Release(tag string) (err error) {
8186
}
8287
defer func() {
8388
if err != nil {
84-
sh.RunV("git", "tag", "--delete", "$TAG")
85-
sh.RunV("git", "push", "--delete", "origin", "$TAG")
89+
sh.RunV("git", "tag", "--delete", tag)
90+
sh.RunV("git", "push", "--delete", "origin", tag)
8691
}
8792
}()
8893
return sh.RunV("goreleaser")

sh/cmd.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ func run(env map[string]string, stdout, stderr io.Writer, cmd string, args ...st
132132
c.Stderr = stderr
133133
c.Stdout = stdout
134134
c.Stdin = os.Stdin
135-
log.Println("exec:", cmd, strings.Join(args, " "))
135+
136+
var quoted []string
137+
for i := range args {
138+
quoted = append(quoted, fmt.Sprintf("%q", args[i]));
139+
}
140+
log.Println("exec:", cmd, strings.Join(quoted, " "))
136141
err = c.Run()
137142
return CmdRan(err), ExitStatus(err), err
138143
}
139-
140144
// CmdRan examines the error to determine if it was generated as a result of a
141145
// command running via os/exec.Command. If the error is nil, or the command ran
142146
// (even if it exited with a non-zero exit code), CmdRan reports true. If the

site/content/index.md

+34-9
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ title = "Mage"
77
Mage is a make/rake-like build tool using Go. You write plain-old go functions,
88
and Mage automatically uses them as Makefile-like runnable targets.
99

10-
1110
## Installation
1211

12+
### From GitHub source (any OS)
13+
1314
Mage has no dependencies outside the Go standard library, and builds with Go 1.7
14-
and above (possibly even lower versions, but they're not regularly tested).
15+
and above (possibly even lower versions, but they're not regularly tested).
1516

16-
**Using Go Modules (Recommended)**
17+
#### Using Go Modules (Recommended)
1718

1819
```plain
1920
git clone https://github.com/magefile/mage
2021
cd mage
2122
go run bootstrap.go
2223
```
2324

24-
**Using GOPATH**
25+
#### Using GOPATH
2526

2627
```plain
2728
go get -u -d github.com/magefile/mage
@@ -33,14 +34,38 @@ This will download the code into your GOPATH, and then run the bootstrap script
3334
to build mage with version infomation embedded in it. A normal `go get`
3435
(without -d) will build the binary correctly, but no version info will be
3536
embedded. If you've done this, no worries, just go to
36-
$GOPATH/src/github.com/magefile/mage and run `mage install` or `go run
37+
`$GOPATH/src/github.com/magefile/mage` and run `mage install` or `go run
3738
bootstrap.go` and a new binary will be created with the correct version
3839
information.
3940

4041
The mage binary will be created in your $GOPATH/bin directory.
4142

43+
### From GitHub releases (any OS)
44+
4245
You may also install a binary release from our
43-
[releases](https://github.com/magefile/mage/releases) page.
46+
[releases](https://github.com/magefile/mage/releases) page.
47+
48+
### With Homebrew (MacOS)
49+
50+
`brew install mage`
51+
52+
See [mage homebrew formula](https://formulae.brew.sh/formula/mage).
53+
54+
### With Scoop (Windows)
55+
56+
`scoop install mage`
57+
58+
See [scoop](https://scoop.sh/).
59+
60+
### Using asdf
61+
62+
The [asdf version manager](https://asdf-vm.com/) is a tool for installing release binaries from Github. With asdf installed, the [asdf plugin for mage](https://github.com/mathew-fleisch/asdf-mage) can be used to install any released version of mage.
63+
64+
```shell
65+
asdf plugin add mage
66+
asdf install mage latest
67+
asdf global mage latest
68+
```
4469

4570
## Example Magefile
4671

@@ -72,14 +97,14 @@ Run the above `Build` target by simply running `mage build` in the same director
7297

7398
Join the `#mage` channel on [gophers slack](https://gophers.slack.com/messages/general/) for discussion of usage, development, etc.
7499

75-
76100
## Plugins
77101

78102
There are no plugins. You don't need plugins. It's just Go code. You can
79103
import whatever libraries you want. Every library in the go ecosystem is a mage
80104
plugin. Every tool you use with Go can be used with Magefiles.
81105

82106
## Usage
107+
83108
```plain
84109
mage [options] [target]
85110
@@ -101,7 +126,7 @@ Options:
101126
-f force recreation of compiled magefile
102127
-goarch sets the GOARCH for the binary created by -compile (default: current arch)
103128
-gocmd <string>
104-
use the given go binary to compile the output (default: "go")
129+
use the given go binary to compile the output (default: "go")
105130
-goos sets the GOOS for the binary created by -compile (default: current OS)
106131
-h show description of a target
107132
-keep keep intermediate mage files around after running
@@ -110,7 +135,7 @@ Options:
110135
-v show verbose output when running mage targets
111136
-w <string>
112137
working directory where magefiles will run (default -d value)
113-
```
138+
```
114139

115140
## Why?
116141

site/content/zeroInstall/_index.en.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Now you can `go run mage.go <target>` and it'll work just as if you ran
2121
package main
2222

2323
import (
24-
"os"
25-
"github.com/magefile/mage/mage"
24+
"os"
25+
"github.com/magefile/mage/mage"
2626
)
2727

2828
func main() { os.Exit(mage.Main()) }

0 commit comments

Comments
 (0)