Skip to content

Commit

Permalink
chore: add build-macos job to workflows and recover Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
tingzhen.lin committed Sep 26, 2022
1 parent daae05e commit 3983532
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*'

jobs:
build:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -26,4 +26,26 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: latest
args: release --rm-dist
args: release

build-macos:
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: latest
args: release
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
COMMIT_REVISION := $(shell git log --pretty=%h -1)
REVISION_FLAG := "-X github.com/lintingzhen/commitizen-go/cmd.revision=${COMMIT_REVISION}"
TARGET := commitizen-go
GOFILES := $(wildcard *.go) $(wildcard cmd/*.go) $(wildcard git/*.go) $(wildcard commit/*.go)

ifeq ($(OS),Windows_NT)
GOOS := windows
COPY := copy
else
COPY := cp
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
GOOS := linux
else ifeq ($(UNAME_S),Darwin)
GOOS := darwin
endif
endif

GIT_EXEC_PATH := $(shell git --exec-path)

all: ${TARGET}
install:
$(COPY) commitizen-go $(GIT_EXEC_PATH)/git-cz
clean:
rm -rf ${TARGET}


commitizen-go: $(GOFILES)
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=amd64 go build -o $@ -ldflags ${REVISION_FLAG}

.PHONY: all install clean

0 comments on commit 3983532

Please sign in to comment.