Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
laktak committed Jun 3, 2024
1 parent aa2fc6d commit b5b5978
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ci

on:
push:
branches: [ master ]
pull_request:

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: chkfmt
run: scripts/chkfmt

- name: xbuild
run: scripts/xbuild

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/zfind
/dist
8 changes: 8 additions & 0 deletions cmd/zfind/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type FileInfo struct {
ModTime time.Time
}

var appVersion = "vdev"

func (file FileInfo) Context() filter.VariableGetter {

return func(name string) *filter.Value {
Expand Down Expand Up @@ -223,6 +225,7 @@ func main() {
Where string `short:"w" help:"The where-filter (using sql-where syntax, see -H)."`
Long bool `short:"l" help:"Show long listing."`
Paths []string `arg:"" name:"path" optional:"" help:"Paths to search."`
Version bool `short:"V" help:"Show version."`
}

arg := kong.Parse(&cli)
Expand All @@ -232,6 +235,11 @@ func main() {
os.Exit(0)
}

if cli.Version {
fmt.Println(appVersion)
os.Exit(0)
}

if cli.Where == "" {
cli.Where = "1"
}
Expand Down
10 changes: 10 additions & 0 deletions scripts/chkfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eE -o pipefail

res="$(gofmt -l . 2>&1)"

if [ -n "$res" ]; then
echo "gofmt check failed:"
echo "${res}"
exit 1
fi
46 changes: 46 additions & 0 deletions scripts/xbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
set -eE -o pipefail

if [ -z "$version" ]; then
version=$(git rev-parse HEAD)
fi

mkdir -p dist
rm -f dist/*

build() {
echo "- $1-$2"
rm -f dist/zfind
CGO_ENABLED=0 GOOS="$1" GOARCH="$2" go build -o dist -ldflags="-X main.appVersion=$version" ./cmd/zfind

pushd dist

case "$1" in
windows)
outfile="zfind-$1-$2.zip"
zip "$outfile" zfind.exe --move
;;
*)
outfile="zfind-$1-$2.tar.gz"
tar -czf "$outfile" zfind --remove-files
;;
esac

popd
}

build android arm64
build darwin amd64
build darwin arm64
build freebsd amd64
build freebsd arm64
build freebsd riscv64
build linux amd64
build linux arm64
build linux riscv64
build netbsd amd64
build netbsd arm64
build openbsd amd64
build openbsd arm64
build windows amd64
build windows arm64

0 comments on commit b5b5978

Please sign in to comment.