From a64423331e24f33f138cb80e1c8890663e7842be Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Fri, 29 Dec 2023 04:58:04 +0100 Subject: [PATCH] Release v1.1.0 (#26) --- .github/workflows/build.yml | 8 ++- .github/workflows/golangci-lint.yml | 4 +- .github/workflows/release.yml | 5 +- .goreleaser.yaml | 33 ++++++------ deprecated/addpath/main.go | 80 ----------------------------- deprecated/delpath/main.go | 61 ---------------------- 6 files changed, 26 insertions(+), 165 deletions(-) delete mode 100644 deprecated/addpath/main.go delete mode 100644 deprecated/delpath/main.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e72e8b5..abd792f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,13 +11,17 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - uses: actions/setup-go@v4 with: - go-version: '>1.18' + go-version: '1.21' - run: go version - run: make build - run: go test -race -cover -covermode=atomic -coverprofile=coverage.out ./... + - run: ./build/pathctl -version - uses: codecov/codecov-action@v3 with: file: ./coverage.out diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d6bcb14..f9beae6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -12,10 +12,10 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 89264d4..d500ff5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,14 +16,15 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: true - run: git fetch --force --tags - uses: actions/setup-go@v4 with: go-version: stable - - uses: goreleaser/goreleaser-action@v4 + - uses: goreleaser/goreleaser-action@v5 with: distribution: goreleaser version: latest diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 33e7e7b..8fc28c1 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -14,9 +14,9 @@ gomod: mod: readonly builds: - - main: ./cmd/addpath - id: "addpath" - binary: addpath + - main: ./cmd/elvoke + id: "elvoke" + binary: elvoke env: - CGO_ENABLED=0 goos: @@ -25,9 +25,9 @@ builds: - openbsd - freebsd - - main: ./cmd/delpath - id: "delpath" - binary: delpath + - main: ./cmd/mcd + id: "mcd" + binary: mcd env: - CGO_ENABLED=0 goos: @@ -36,9 +36,9 @@ builds: - openbsd - freebsd - - main: ./cmd/elvoke - id: "elvoke" - binary: elvoke + - main: ./cmd/pathctl + id: "pathctl" + binary: pathctl env: - CGO_ENABLED=0 goos: @@ -47,9 +47,9 @@ builds: - openbsd - freebsd - - main: ./cmd/mcd - id: "mcd" - binary: mcd + - main: ./cmd/popbak + id: "popbak" + binary: popbak env: - CGO_ENABLED=0 goos: @@ -58,16 +58,13 @@ builds: - openbsd - freebsd - - main: ./cmd/popbak - id: "popbak" - binary: popbak + - main: ./cmd/portup + id: "portup" + binary: portup env: - CGO_ENABLED=0 goos: - - linux - darwin - - openbsd - - freebsd - main: ./cmd/pushbak id: "pushbak" diff --git a/deprecated/addpath/main.go b/deprecated/addpath/main.go deleted file mode 100644 index fe605c5..0000000 --- a/deprecated/addpath/main.go +++ /dev/null @@ -1,80 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "os" - "path" - - intpath "al.essio.dev/pkg/tools/internal/path" -) - -var ( - helpMode bool - appendMode bool - progName = "addpath" -) - -func init() { - detectAppendMode() - - if !appendMode { - flag.BoolVar(&appendMode, "append", false, "append DIR to ENVVAR.") - } - - flag.BoolVar(&helpMode, "help", false, "display this help and exit.") - flag.Usage = usage -} - -func detectAppendMode() { - appendMode = path.Base(os.Args[0]) == "appendpath" - if appendMode { - progName = "appendpath" - } -} - -func main() { - var ( - envvar string - dir string - ) - - log.SetFlags(0) - log.SetPrefix(fmt.Sprintf("%s: ", progName)) - log.SetOutput(os.Stderr) - flag.Parse() - - if helpMode { - usage() - os.Exit(0) - } - - switch flag.NArg() { - case 0: - fallthrough - case 1: - log.Fatal("missing operand(s)") - case 2: - envvar = flag.Arg(0) - dir = flag.Arg(1) - oldVal := os.Getenv(envvar) - newVal := intpath.AddDir(oldVal, dir, appendMode) - fmt.Println(newVal) - default: - log.Fatal("invalid arguments") - } -} - -func usage() { - usageString := fmt.Sprintf(`Usage: %s ENVVAR DIR -Add directory to a PATH-like environment variable and -print the new contents of ENVVAR. - -If the program's filename is appendpath, the append -mode is turned on. -`, progName) - _, _ = fmt.Fprintln(os.Stderr, usageString) - - flag.PrintDefaults() -} diff --git a/deprecated/delpath/main.go b/deprecated/delpath/main.go deleted file mode 100644 index 1d325e3..0000000 --- a/deprecated/delpath/main.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "os" - - "al.essio.dev/pkg/tools/internal/path" -) - -var ( - helpMode bool -) - -func init() { - flag.BoolVar(&helpMode, "help", false, "display this help and exit.") - flag.Usage = usage -} - -func main() { - var ( - envvar string - dir string - ) - - log.SetFlags(0) - log.SetPrefix("delpath: ") - log.SetOutput(os.Stderr) - flag.Parse() - - if helpMode { - usage() - os.Exit(0) - } - - switch flag.NArg() { - case 0: - fallthrough - case 1: - log.Fatal("missing operand(s)") - case 2: - envvar = flag.Arg(0) - dir = flag.Arg(1) - oldVal := os.Getenv(envvar) - newVal := path.RemoveDir(oldVal, dir) - fmt.Println(newVal) - default: - log.Fatal("invalid arguments") - } -} - -func usage() { - usageString := `Usage: delpath ENVVAR DIR -Remove a directory from a PATH-like environment variable and -print the new contents of ENVVAR. -` - _, _ = fmt.Fprintln(os.Stderr, usageString) - - flag.PrintDefaults() -}