+30
.github/workflows/release.yaml
+30
.github/workflows/release.yaml
···
1
+
# .github/workflows/release.yaml
2
+
3
+
on:
4
+
release:
5
+
types: [created]
6
+
7
+
permissions:
8
+
contents: write
9
+
packages: write
10
+
11
+
jobs:
12
+
releases-matrix:
13
+
name: Release Go Binary
14
+
runs-on: ubuntu-latest
15
+
strategy:
16
+
matrix:
17
+
# build and publish in parallel: linux/amd64, linux/arm64, windows/amd64, darwin/amd64, darwin/arm64
18
+
goos: [linux, windows, darwin]
19
+
goarch: [amd64, arm64]
20
+
exclude:
21
+
- goarch: arm64
22
+
goos: windows
23
+
steps:
24
+
- uses: actions/checkout@v3
25
+
- uses: wangyoucao577/go-release-action@v1
26
+
with:
27
+
github_token: ${{ secrets.GITHUB_TOKEN }}
28
+
goos: ${{ matrix.goos }}
29
+
goarch: ${{ matrix.goarch }}
30
+
project_path: "./cmd/atr.go"
+11
-3
cmd/atr.go
+11
-3
cmd/atr.go
···
12
12
"path/filepath"
13
13
"regexp"
14
14
"strings"
15
+
"syscall"
15
16
16
17
"github.com/alecthomas/chroma"
17
18
"github.com/alecthomas/chroma/formatters"
18
19
"github.com/alecthomas/chroma/lexers"
19
20
"github.com/alecthomas/chroma/styles"
20
21
repo "github.com/atscan/atr/repo"
22
+
"github.com/atscan/atr/util/version"
21
23
"github.com/dustin/go-humanize"
22
24
"github.com/fatih/color"
23
25
"github.com/ipfs/go-cid"
···
30
32
func main() {
31
33
32
34
app := &cli.App{
33
-
Name: "atr",
34
-
Usage: "AT Protocol IPLD-CAR Repository toolkit",
35
+
Name: "atr",
36
+
Usage: "AT Protocol IPLD-CAR Repository toolkit",
37
+
Version: version.Version,
35
38
Flags: []cli.Flag{
36
39
&cli.StringFlag{
37
40
Name: "C",
···
78
81
}
79
82
yellow := color.New(color.FgYellow).SprintFunc()
80
83
cyan := color.New(color.FgCyan).SprintFunc()
81
-
fmt.Printf("%v\n Head: %s\n Size: %s Commits: %v\n\n", yellow(ss.File), cyan(ss.Root.String()), cyan(humanize.Bytes(uint64(ss.Size))), cyan(humanize.Comma(int64(len(ss.Items)))))
84
+
fmt.Printf("%v:\n Head: %s\n Size: %s Commits: %v\n\n", yellow(ss.File), cyan(ss.Root.String()), cyan(humanize.Bytes(uint64(ss.Size))), cyan(humanize.Comma(int64(len(ss.Items)))))
82
85
}
83
86
84
87
stat, _ := os.Stdin.Stat()
···
203
206
}
204
207
205
208
func WalkFiles(ctx *cli.Context, cb func(RepoSnapshot, error)) error {
209
+
wd := ctx.String("C")
210
+
if wd != "." {
211
+
syscall.Chdir(wd)
212
+
}
213
+
206
214
dir := ctx.Args().First()
207
215
if dir == "" {
208
216
dir = "."
+27
util/version/version.go
+27
util/version/version.go
···
1
+
package version
2
+
3
+
import (
4
+
"runtime/debug"
5
+
)
6
+
7
+
// Version holds the version number.
8
+
var Version string
9
+
10
+
func init() {
11
+
if Version == "" {
12
+
Version = "dev-" + revision()
13
+
}
14
+
}
15
+
16
+
func revision() string {
17
+
info, ok := debug.ReadBuildInfo()
18
+
if ok {
19
+
for _, setting := range info.Settings {
20
+
switch setting.Key {
21
+
case "vcs.revision":
22
+
return setting.Value[:7]
23
+
}
24
+
}
25
+
}
26
+
return ""
27
+
}