Skip to content

Commit

Permalink
Merge pull request #90 from oasisprotocol/jberci/feature/macos
Browse files Browse the repository at this point in the history
Add macOS releases
  • Loading branch information
jberci committed Jun 8, 2023
2 parents 3f7985f + ff2fc29 commit ef2bf68
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ on:

jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
# NOTE: This name appears in GitHub's Checks API.
name: tests
runs-on: ubuntu-latest
name: tests-${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
12 changes: 8 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ before:
hooks:
- go mod tidy

universal_binaries:
- replace: true
name_template: oasis

builds:
- binary: oasis
flags:
- -trimpath
ldflags:
- -buildid=
- "{{.Env.GOLDFLAGS_VERSION}}"
goos:
- linux
goarch:
- amd64
targets:
- linux_amd64
- darwin_amd64
- darwin_arm64

archives:
- name_template: "{{replace .ProjectName \" \" \"_\" | tolower}}_{{.Version}}_{{.Os}}_{{.Arch}}"
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ all: build

# Build.
build:
@$(ECHO) "$(MAGENTA)*** Building Go code...$(OFF)"
@$(PRINT) "$(MAGENTA)*** Building Go code...$(OFF)\n"
@$(GO) build -v -o oasis $(GOFLAGS) $(GO_EXTRA_FLAGS)

# Format code.
fmt:
@$(ECHO) "$(CYAN)*** Running Go formatters...$(OFF)"
@$(PRINT) "$(CYAN)*** Running Go formatters...$(OFF)"
@gofumpt -w .
@goimports -w -local github.com/oasisprotocol/cli .

# Lint code, commits and documentation.
lint-targets := lint-go lint-docs lint-git lint-go-mod-tidy

lint-go:
@$(ECHO) "$(CYAN)*** Running Go linters...$(OFF)"
@$(PRINT) "$(CYAN)*** Running Go linters...$(OFF)"
@env -u GOPATH golangci-lint run --verbose

lint-git:
@$(ECHO) "$(CYAN)*** Running gitlint...$(OFF)"
@$(PRINT) "$(CYAN)*** Running gitlint...$(OFF)"
@$(CHECK_GITLINT)

lint-docs:
@$(ECHO) "$(CYAN)*** Running markdownlint-cli...$(OFF)"
@$(PRINT) "$(CYAN)*** Running markdownlint-cli...$(OFF)"
@npx --yes markdownlint-cli '**/*.md'

lint-go-mod-tidy:
@$(ECHO) "$(CYAN)*** Checking go mod tidy...$(OFF)"
@$(PRINT) "$(CYAN)*** Checking go mod tidy...$(OFF)"
@$(ENSURE_GIT_CLEAN)
@$(CHECK_GO_MOD_TIDY)

Expand All @@ -49,14 +49,14 @@ release-build:
test-targets := test-unit

test-unit:
@$(ECHO) "$(CYAN)*** Running unit tests...$(OFF)"
@$(PRINT) "$(CYAN)*** Running unit tests...$(OFF)"
@$(GO) test -v -race ./...

test: $(test-targets)

# Clean.
clean:
@$(ECHO) "$(CYAN)*** Cleaning up ...$(OFF)"
@$(PRINT) "$(CYAN)*** Cleaning up ...$(OFF)"
@$(GO) clean -x
rm -f oasis
$(GO) clean -testcache
Expand Down
10 changes: 4 additions & 6 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ ifdef ISATTY
RED := \e[0;31m
OFF := \e[0m
# Use external echo command since the built-in echo doesn't support '-e'.
ECHO_CMD := /bin/echo -e
else
MAGENTA := ""
CYAN := ""
RED := ""
OFF := ""
ECHO_CMD := echo
endif

# Output messages to stderr instead stdout.
ECHO := $(ECHO_CMD) 1>&2
PRINT := printf 1>&2

# Name of git remote pointing to the canonical upstream git repository, i.e.
# git@github.com:oasisprotocol/cli.git.
Expand Down Expand Up @@ -67,7 +65,7 @@ export GOLDFLAGS ?= "$(GOLDFLAGS_VERSION)"
# Helper that ensures the git workspace is clean.
define ENSURE_GIT_CLEAN =
if [[ ! -z `git status --porcelain` ]]; then \
$(ECHO) "$(RED)Error: Git workspace is dirty.$(OFF)"; \
$(PRINT) "$(RED)Error: Git workspace is dirty.$(OFF)\n"; \
exit 1; \
fi
endef
Expand All @@ -78,7 +76,7 @@ endef
define CHECK_GO_MOD_TIDY =
$(GO) mod tidy; \
if [[ ! -z `git status --porcelain go.mod go.sum` ]]; then \
$(ECHO) "$(RED)Error: The following changes detected after running 'go mod tidy':$(OFF)"; \
$(PRINT) "$(RED)Error: The following changes detected after running 'go mod tidy':$(OFF)\n"; \
git diff go.mod go.sum; \
exit 1; \
fi
Expand All @@ -91,6 +89,6 @@ endef
define CHECK_GITLINT =
BRANCH=$(OASIS_CLI_GIT_ORIGIN_REMOTE)/$(RELEASE_BRANCH); \
COMMIT_SHA=`git rev-parse $$BRANCH` && \
$(ECHO) "$(CYAN)*** Running gitlint for commits from $$BRANCH ($${COMMIT_SHA:0:7})... $(OFF)"; \
$(PRINT) "$(CYAN)*** Running gitlint for commits from $$BRANCH ($${COMMIT_SHA:0:7})... $(OFF)\n"; \
gitlint --commits $$BRANCH..HEAD
endef

0 comments on commit ef2bf68

Please sign in to comment.