mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
commit
4d61e9c718
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
|
@ -27,8 +27,12 @@ jobs:
|
|||
check-latest: true
|
||||
- name: Test
|
||||
run: make test
|
||||
- name: Build all targets
|
||||
run: make all
|
||||
- name: Install GoReleaser
|
||||
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
|
||||
with:
|
||||
install-only: true
|
||||
- name: Build
|
||||
run: make build
|
||||
|
||||
generate:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
36
.github/workflows/release.yml
vendored
Normal file
36
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Extract release notes from Changes
|
||||
run: |
|
||||
tag="${{ github.ref_name }}"
|
||||
sed -n "/^${tag} /,/^v[0-9]/{/^v[0-9]/!p}" Changes > release-notes.md
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
|
||||
with:
|
||||
version: "~> v2"
|
||||
args: release --clean --release-notes=release-notes.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -36,3 +36,4 @@ vendor
|
|||
github_token
|
||||
|
||||
releases
|
||||
dist
|
||||
|
|
|
|||
44
.goreleaser.yml
Normal file
44
.goreleaser.yml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
version: 2
|
||||
|
||||
builds:
|
||||
- id: peco
|
||||
main: ./cmd/peco
|
||||
binary: peco
|
||||
ldflags:
|
||||
- -s -w -X github.com/peco/peco.version={{.Version}}
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
- arm
|
||||
- arm64
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
|
||||
archives:
|
||||
- formats:
|
||||
- tar.gz
|
||||
format_overrides:
|
||||
- goos: darwin
|
||||
formats:
|
||||
- zip
|
||||
- goos: windows
|
||||
formats:
|
||||
- zip
|
||||
files:
|
||||
- README.md
|
||||
- Changes
|
||||
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
algorithm: sha256
|
||||
|
||||
changelog:
|
||||
disable: true
|
||||
147
Makefile
147
Makefile
|
|
@ -1,143 +1,32 @@
|
|||
MAKEFLAGS += --no-print-directory
|
||||
GOVERSION=$(shell go version)
|
||||
GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION))))
|
||||
GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION))))
|
||||
VERSION=$(patsubst "%",%,$(lastword $(shell grep 'const version' peco.go)))
|
||||
RELEASE_DIR=releases
|
||||
ARTIFACTS_DIR=$(RELEASE_DIR)/artifacts/$(VERSION)
|
||||
GITHUB_USERNAME=peco
|
||||
BUILD_TARGETS= \
|
||||
build-linux-arm64 \
|
||||
build-linux-arm \
|
||||
build-linux-amd64 \
|
||||
build-darwin-amd64 \
|
||||
build-darwin-arm64 \
|
||||
build-windows-amd64
|
||||
RELEASE_TARGETS=\
|
||||
release-linux-arm64 \
|
||||
release-linux-arm \
|
||||
release-linux-amd64 \
|
||||
release-darwin-amd64 \
|
||||
release-darwin-arm64 \
|
||||
release-windows-amd64
|
||||
export PATH := $(HOME)/go/bin:$(PATH)
|
||||
|
||||
.PHONY: default deps install clean build all test generate cover lint $(RELEASE_TARGETS) $(BUILD_TARGETS) $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/peco$(SUFFIX)
|
||||
.PHONY: build snapshot test lint generate cover clean deps check-goreleaser
|
||||
|
||||
# the first target in the file is the entrypoint, this is run when you call `make` with no arguments
|
||||
default: deps build
|
||||
check-goreleaser:
|
||||
@command -v goreleaser >/dev/null 2>&1 || { echo "goreleaser not found. Install it: https://goreleaser.com/install/"; exit 1; }
|
||||
|
||||
build: $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/peco$(SUFFIX)
|
||||
build: check-goreleaser
|
||||
goreleaser build --snapshot --single-target --clean
|
||||
|
||||
install:
|
||||
@cp $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/peco$(SUFFIX) /usr/sbin/peco
|
||||
snapshot: check-goreleaser
|
||||
goreleaser release --snapshot --clean
|
||||
|
||||
deps:
|
||||
@echo "Downloading dependencies..."
|
||||
@go mod download
|
||||
|
||||
build-windows-amd64:
|
||||
@$(MAKE) build GOOS=windows GOARCH=amd64 SUFFIX=.exe
|
||||
|
||||
build-windows-386:
|
||||
@$(MAKE) build GOOS=windows GOARCH=386 SUFFIX=.exe
|
||||
|
||||
build-linux-amd64:
|
||||
@$(MAKE) build GOOS=linux GOARCH=amd64
|
||||
|
||||
build-linux-arm:
|
||||
@$(MAKE) build GOOS=linux GOARCH=arm
|
||||
|
||||
build-linux-arm64:
|
||||
@$(MAKE) build GOOS=linux GOARCH=arm64
|
||||
|
||||
build-linux-386:
|
||||
@$(MAKE) build GOOS=linux GOARCH=386
|
||||
|
||||
build-darwin-amd64:
|
||||
@$(MAKE) build GOOS=darwin GOARCH=amd64
|
||||
|
||||
build-darwin-arm64:
|
||||
@$(MAKE) build GOOS=darwin GOARCH=arm64
|
||||
|
||||
$(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/peco$(SUFFIX):
|
||||
@echo "Building $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/peco$(SUFFIX)"
|
||||
@go build -o $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/peco$(SUFFIX) cmd/peco/peco.go
|
||||
|
||||
all: deps $(BUILD_TARGETS)
|
||||
|
||||
release: deps $(RELEASE_TARGETS)
|
||||
|
||||
$(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/Changes:
|
||||
@cp Changes $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)
|
||||
|
||||
$(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/README.md:
|
||||
@cp README.md $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)
|
||||
|
||||
release-changes: $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/Changes
|
||||
release-readme: $(RELEASE_DIR)/peco_$(GOOS)_$(GOARCH)/README.md
|
||||
|
||||
release-windows-amd64: build-windows-amd64
|
||||
@$(MAKE) release-changes release-readme release-zip GOOS=windows GOARCH=amd64
|
||||
|
||||
release-windows-386: build-windows-386
|
||||
@$(MAKE) release-changes release-readme release-zip GOOS=windows GOARCH=386
|
||||
|
||||
release-linux-amd64: build-linux-amd64
|
||||
@$(MAKE) release-changes release-readme release-targz GOOS=linux GOARCH=amd64
|
||||
|
||||
release-linux-arm: build-linux-arm
|
||||
@$(MAKE) release-changes release-readme release-targz GOOS=linux GOARCH=arm
|
||||
|
||||
release-linux-arm64: build-linux-arm64
|
||||
@$(MAKE) release-changes release-readme release-targz GOOS=linux GOARCH=arm64
|
||||
|
||||
release-linux-386: build-linux-386
|
||||
@$(MAKE) release-changes release-readme release-targz GOOS=linux GOARCH=386
|
||||
|
||||
release-darwin-amd64: build-darwin-amd64
|
||||
@$(MAKE) release-changes release-readme release-zip GOOS=darwin GOARCH=amd64
|
||||
|
||||
release-darwin-arm64: build-darwin-arm64
|
||||
@$(MAKE) release-changes release-readme release-zip GOOS=darwin GOARCH=arm64
|
||||
|
||||
$(ARTIFACTS_DIR):
|
||||
@mkdir -p $(ARTIFACTS_DIR)
|
||||
|
||||
# note: I dreamt of using tar.bz2 for my releases, but then historically
|
||||
# (for whatever reason that is unknown to me now) I was creating .zip for
|
||||
# darwin/windows, and .tar.gz for linux, so I guess we'll stick with those.
|
||||
# (I think this is from goxc days)
|
||||
release-tarbz: $(ARTIFACTS_DIR)
|
||||
tar -cjf $(ARTIFACTS_DIR)/peco_$(GOOS)_$(GOARCH).tar.bz2 -C $(RELEASE_DIR) peco_$(GOOS)_$(GOARCH)
|
||||
|
||||
release-targz: $(ARTIFACTS_DIR)
|
||||
tar -czf $(ARTIFACTS_DIR)/peco_$(GOOS)_$(GOARCH).tar.gz -C $(RELEASE_DIR) peco_$(GOOS)_$(GOARCH)
|
||||
|
||||
release-zip: $(ARTIFACTS_DIR)
|
||||
cd $(RELEASE_DIR) && zip -9 $(CURDIR)/$(ARTIFACTS_DIR)/peco_$(GOOS)_$(GOARCH).zip peco_$(GOOS)_$(GOARCH)/*
|
||||
|
||||
release-github-token: github_token
|
||||
@echo "file `github_token` is required"
|
||||
|
||||
release-upload: release release-github-token
|
||||
ghr -u $(GITHUB_USERNAME) -t $(shell cat github_token) --draft --replace $(VERSION) $(ARTIFACTS_DIR)
|
||||
|
||||
test: deps
|
||||
@echo "Running tests..."
|
||||
@go test -v -race ./...
|
||||
test:
|
||||
go test -v -race ./...
|
||||
|
||||
lint:
|
||||
golangci-lint run ./...
|
||||
|
||||
generate:
|
||||
@go generate ./...
|
||||
go generate ./...
|
||||
|
||||
cover: deps
|
||||
@echo "Running tests with coverage..."
|
||||
@go test -race -coverprofile=coverage.out ./...
|
||||
@go tool cover -func=coverage.out
|
||||
cover:
|
||||
go test -race -coverprofile=coverage.out ./...
|
||||
go tool cover -func=coverage.out
|
||||
|
||||
clean:
|
||||
@echo "Cleaning.."
|
||||
-rm -rf $(RELEASE_DIR)
|
||||
-rm -rf $(ARTIFACTS_DIR)/*
|
||||
rm -rf dist
|
||||
|
||||
deps:
|
||||
go mod download
|
||||
|
|
|
|||
32
README.md
32
README.md
|
|
@ -316,35 +316,23 @@ mamba install -c conda-forge peco
|
|||
pixi global install peco
|
||||
```
|
||||
|
||||
### Using go install
|
||||
|
||||
If you have a Go toolchain installed, you can install peco with:
|
||||
|
||||
```
|
||||
go install github.com/peco/peco/cmd/peco@latest
|
||||
```
|
||||
|
||||
### Building peco yourself
|
||||
|
||||
Make sure to clone the source code under $GOPATH (i.e. $GOPATH/src/github.com/peco/peco). This is required
|
||||
as the main binary refers to an internal package, which requires that the source code be located in
|
||||
the correct package location.
|
||||
|
||||
Navigate to the directory above, then run:
|
||||
Clone the repository and run:
|
||||
|
||||
```
|
||||
make build
|
||||
```
|
||||
|
||||
This will do the following:
|
||||
|
||||
1. Run `go build` to create `releases/$VERSION_NUMBER/peco`
|
||||
|
||||
You can copy the binary to somewhere in your $PATH, and it should just work.
|
||||
|
||||
The above installs the correct versions of peco's dependencies. Then build it:
|
||||
|
||||
```
|
||||
go build cmd/peco/peco.go
|
||||
```
|
||||
|
||||
This compiles a peco binary in the root of the cloned peco repository. Copy this file to an appropriate location.
|
||||
|
||||
### go get IS NOT RECOMMENDED
|
||||
|
||||
Please DO NOT use `go get` to install this tool. It bypasses the developers' intention of controlling the dependency versioning.
|
||||
This will build the binary into `releases/peco_<os>_<arch>/peco`. Copy it to somewhere in your `$PATH`.
|
||||
|
||||
# Command Line Options
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue