Skip to content

Commit

Permalink
Merge branch 'master' into dima/371-racy-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
natefinch committed Dec 15, 2021
2 parents 4ebcbaa + 2f1ec40 commit 493d9db
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 46 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ci

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version:
- 1.17.x
- 1.16.x
- 1.15.x
- 1.14.x
- 1.13.x
- 1.12.x
- 1.11.x
steps:
- uses: actions/checkout@v2
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Test
run: |
go vet ./...
go test -tags CI -race ./...
env:
GOPATH: /home/runner/go
3 changes: 2 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ build:
goarm: 6
env:
- CGO_ENABLED=0
archive:
archives:
-
name_template: "{{.Binary}}_{{.Version}}_{{.Os}}-{{.Arch}}"
replacements:
amd64: 64bit
Expand Down
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

11 changes: 8 additions & 3 deletions magefile.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build mage
//go:build mage
// +build mage

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

// Generates a new release. Expects a version tag in v1.x.x format.
func Release(tag string) (err error) {
if _, err := exec.LookPath("goreleaser"); err != nil {
return fmt.Errorf("can't find goreleaser: %w", err)
}
if !releaseTag.MatchString(tag) {
return errors.New("TAG environment variable must be in semver v1.x.x format, but was " + tag)
}
Expand All @@ -81,8 +86,8 @@ func Release(tag string) (err error) {
}
defer func() {
if err != nil {
sh.RunV("git", "tag", "--delete", "$TAG")
sh.RunV("git", "push", "--delete", "origin", "$TAG")
sh.RunV("git", "tag", "--delete", tag)
sh.RunV("git", "push", "--delete", "origin", tag)
}
}()
return sh.RunV("goreleaser")
Expand Down
8 changes: 6 additions & 2 deletions sh/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ func run(env map[string]string, stdout, stderr io.Writer, cmd string, args ...st
c.Stderr = stderr
c.Stdout = stdout
c.Stdin = os.Stdin
log.Println("exec:", cmd, strings.Join(args, " "))

var quoted []string
for i := range args {
quoted = append(quoted, fmt.Sprintf("%q", args[i]));
}
log.Println("exec:", cmd, strings.Join(quoted, " "))
err = c.Run()
return CmdRan(err), ExitStatus(err), err
}

// CmdRan examines the error to determine if it was generated as a result of a
// command running via os/exec.Command. If the error is nil, or the command ran
// (even if it exited with a non-zero exit code), CmdRan reports true. If the
Expand Down
43 changes: 34 additions & 9 deletions site/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ title = "Mage"
Mage is a make/rake-like build tool using Go. You write plain-old go functions,
and Mage automatically uses them as Makefile-like runnable targets.


## Installation

### From GitHub source (any OS)

Mage has no dependencies outside the Go standard library, and builds with Go 1.7
and above (possibly even lower versions, but they're not regularly tested).
and above (possibly even lower versions, but they're not regularly tested).

**Using Go Modules (Recommended)**
#### Using Go Modules (Recommended)

```plain
git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go
```

**Using GOPATH**
#### Using GOPATH

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

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

### From GitHub releases (any OS)

You may also install a binary release from our
[releases](https://github.com/magefile/mage/releases) page.
[releases](https://github.com/magefile/mage/releases) page.

### With Homebrew (MacOS)

`brew install mage`

See [mage homebrew formula](https://formulae.brew.sh/formula/mage).

### With Scoop (Windows)

`scoop install mage`

See [scoop](https://scoop.sh/).

### Using asdf

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.

```shell
asdf plugin add mage
asdf install mage latest
asdf global mage latest
```

## Example Magefile

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

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


## Plugins

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

## Usage

```plain
mage [options] [target]
Expand All @@ -101,7 +126,7 @@ Options:
-f force recreation of compiled magefile
-goarch sets the GOARCH for the binary created by -compile (default: current arch)
-gocmd <string>
use the given go binary to compile the output (default: "go")
use the given go binary to compile the output (default: "go")
-goos sets the GOOS for the binary created by -compile (default: current OS)
-h show description of a target
-keep keep intermediate mage files around after running
Expand All @@ -110,7 +135,7 @@ Options:
-v show verbose output when running mage targets
-w <string>
working directory where magefiles will run (default -d value)
```
```

## Why?

Expand Down
4 changes: 2 additions & 2 deletions site/content/zeroInstall/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Now you can `go run mage.go <target>` and it'll work just as if you ran
package main

import (
"os"
"github.com/magefile/mage/mage"
"os"
"github.com/magefile/mage/mage"
)

func main() { os.Exit(mage.Main()) }
Expand Down

0 comments on commit 493d9db

Please sign in to comment.