-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: clean up, set up automatic builds
- Loading branch information
1 parent
0aafd67
commit 54b4520
Showing
9 changed files
with
122 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
eval $(gimme 1.20) | ||
PATH_add dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: goreleaser | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v5 | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
# either 'goreleaser' (default) or 'goreleaser-pro' | ||
distribution: goreleaser | ||
# 'latest', 'nightly', or a semver | ||
version: '~> v2' | ||
args: release --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution | ||
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
.vscode | ||
.goreleaser | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[tools] | ||
go = "1.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,69 @@ | ||
export prefix?=$(HOME)/.local | ||
export bindir?=$(prefix)/bin | ||
#? https://www.gnu.org/prep/standards/html_node/DESTDIR.html | ||
export DESTDIR ?= | ||
export PREFIX ?= $(HOME)/.local | ||
|
||
.default: info | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
CURRENT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) | ||
HOST_OS := $(shell uname -s) | ||
HOST_ARCH := $(shell uname -m) | ||
|
||
ZSH_PROMPT_SETUP_SCRIPT := $(CURRENT_DIR)/plugin/zsh/prompt_asynczle_setup.zsh | ||
GORELEASER_VERSION := v2.0.1 | ||
GORELEASER_TAR_URL := https://github.com/goreleaser/goreleaser/releases/download/$(GORELEASER_VERSION)/goreleaser_$(HOST_OS)_$(HOST_ARCH).tar.gz | ||
|
||
USR_BIN_DIR := $(HOME)/bin | ||
USR_ZSH_DIR := $(HOME)/.local/share/zsh-funcs | ||
GORELEASER := ./.goreleaser | ||
|
||
.PHONY: publish | ||
publish: | ||
goreleaser release --rm-dist | ||
GO_FILES = $(sort $(shell find . -type f -name '*.go') go.mod go.sum) | ||
STATIC_FILES = $(sort $(shell find ./plugin -type f)) | ||
GORELEASER_FILES = $(sort .goreleaser .goreleaser.yaml) | ||
|
||
.PHONY: release | ||
release: | ||
goreleaser release --rm-dist --snapshot --skip-publish | ||
# ------------------------------------------------------------------------------ | ||
|
||
BUILD_DIST ?= dist | ||
BUILD_GORELEASER_BIN ?= $(BUILD_DIST)/goreleaser | ||
|
||
INSTALL_BIN_DIR ?= $(DESTDIR)$(PREFIX)/bin | ||
INSTALL_ZSH_FUNCS_DIR ?= $(DESTDIR)$(PREFIX)/share/zsh-funcs | ||
|
||
# ------------------------------------------------------------------------------ | ||
|
||
.PNONY: info | ||
info: | ||
@echo "OS: $(HOST_OS)" | ||
@echo "ARCH: $(HOST_ARCH)" | ||
@echo | ||
@echo "PREFIX: $(PREFIX)" | ||
@echo "INSTALL_BIN_DIR: $(INSTALL_BIN_DIR)" | ||
@echo "INSTALL_ZSH_FUNCS_DIR: $(INSTALL_ZSH_FUNCS_DIR)" | ||
|
||
$(GORELEASER): | ||
sh scripts/fetch-goreleaser.sh "$(GORELEASER_TAR_URL)" "$(GORELEASER)" | ||
|
||
.PHONY: build | ||
build: | ||
goreleaser build --rm-dist --snapshot --single-target --output dist/goprompt | ||
$(INSTALL_BIN_DIR) $(INSTALL_ZSH_FUNCS_DIR): | ||
mkdir -p $@ | ||
|
||
.PHONY: install | ||
install: build | ||
mkdir -p "$(USR_BIN_DIR)" | ||
cp dist/goprompt "$(USR_BIN_DIR)/goprompt" | ||
# ------------------------------------------------------------------------------ | ||
|
||
.PHONY: clean build install release publish | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf dist | ||
|
||
build: $(BUILD_GORELEASER_BIN) | ||
|
||
install: $(BUILD_GORELEASER_BIN) $(INSTALL_BIN_DIR) $(INSTALL_ZSH_FUNCS_DIR) | ||
cp "$(BUILD_GORELEASER_BIN)" "$(INSTALL_BIN_DIR)/goprompt" | ||
|
||
$(BUILD_GORELEASER_BIN): $(GO_FILES) $(STATIC_FILES) $(GORELEASER_FILES) | ||
$(GORELEASER) build --clean --snapshot --single-target \ | ||
--id goreleaser \ | ||
--output "$(BUILD_GORELEASER_BIN)" | ||
|
||
release: | ||
$(GORELEASER) release --clean --auto-snapshot --skip=publish | ||
|
||
publish: | ||
$(GORELEASER) release --clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
set -euxo pipefail | ||
|
||
readonly GORELEASER_TAR_URL=$1 | ||
readonly TARGET_BIN_PATH=$2 | ||
readonly TMPDIR=$(mktemp -d) | ||
|
||
on_exit() { | ||
rm -rf "$TMPDIR" | ||
} | ||
trap on_exit EXIT | ||
|
||
curl -sfL "${GORELEASER_TAR_URL}" -o "${TMPDIR}/goreleaser.tar.gz" | ||
tar -xf "${TMPDIR}/goreleaser.tar.gz" -C "$TMPDIR" | ||
cp "${TMPDIR}/goreleaser" "${TARGET_BIN_PATH}" |