diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml new file mode 100644 index 000000000..8213bd82f --- /dev/null +++ b/.github/workflows/release-check.yml @@ -0,0 +1,18 @@ +on: + push: + tags: + - v0.*.* + - v1.*.* + +jobs: + tests: + name: Release sanity tests + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - name: Checking code health + run: make tools lint test + + - name: Checking the version + run: make check-version diff --git a/GNUmakefile b/GNUmakefile index 627458abc..4f64da979 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -13,26 +13,36 @@ link-git-hooks: find .git/hooks -type l -exec rm {} \; find githooks -type f -exec ln -sf ../../{} .git/hooks/ \; +.PHONY: build build: go install ./$(PKG_NAME) +.PHONY: test test: go test $(SOURCE_FILES) -coverprofile $(COVERAGE) -timeout=30s -parallel=4 -cover -race +.PHONY: fmt fmt: @echo "==> Fixing source code with gofmt..." gofmt -s -w ./$(PKG_NAME) goimports -w ./$(PKG_NAME) +.PHONY: lint-fix lint-fix: golangci-lint run --fix +.PHONY: lint lint: golangci-lint run $(SOURCE_FILES) +.PHONY: check check: test lint-fix +.PHONY: tools tools: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION) -.PHONY: build test fmt lint lint-fix check tools +TAG=$(patsubst v%,%,$(shell git describe --tags --dirty --always)) +.PHONY: check-version +check-version: + scripts/check-version.sh "$(TAG)" diff --git a/README.md b/README.md index 05c346ce8..e1253d71b 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,9 @@ Each version of the client is tagged and the version is updated accordingly. To see the list of past versions, run `git tag`. +To release a new version, first ensure that [Version](./mongodbatlas/mongodbatlas.go) is updated +(i.e., before running `git push origin vx.y.z`, verify that `Version=x.y.z` should match the tag being pushed to GitHub) + ## Roadmap This library is being initially developed for [mongocli](https://github.com/mongodb/mongocli), diff --git a/githooks/pre-push b/githooks/pre-push new file mode 100755 index 000000000..65d839d6c --- /dev/null +++ b/githooks/pre-push @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# A simple pre-push hook which ensures that the tag being pushed to GitHub +# matches the version defined in code. +# +# Determine if a tag is being pushed +tag= +input=$(