~nromdotcom/gemif

c57c4daa61de5a100cdb73b9fa3ab8d88199b25c — Norm MacLennan 11 months ago 62be8d3
Added ability to automatically attach built packages to tagged refs
3 files changed, 36 insertions(+), 7 deletions(-)

M .build.yml
M Makefile
A scripts/release_version.sh
M .build.yml => .build.yml +6 -0
@@ 2,10 2,13 @@ image: debian/testing
packages:
  - golang
  - make
  - curl
sources:
  - https://git.sr.ht/~nromdotcom/gemif
environment:
  PATH: /usr/local/bin:/usr/bin:/bin:/home/build/go/bin
secrets:
  - 58699430-3a3c-435a-8cc9-948ce5810eb0
tasks:
  - setup: |
      cd gemif


@@ 16,3 19,6 @@ tasks:
  - build: |
      cd gemif
      make build
  - release: |
      export SRHT_TOKEN=$(cat ~/.srht_token)
      make release

M Makefile => Makefile +16 -7
@@ 1,4 1,4 @@
.PHONY: help build clean build-all release promote
.PHONY: help build clean build-all package release
.DEFAULT_GOAL := help
### Calculate a few variables for use in building and deploying the app
VERSION = $(shell git describe --tags --always)


@@ 38,17 38,17 @@ gemif-build: clean generate ## Build GemIF server for your native architecture
	go build -o ./bin/gemif -ldflags=$(ldflags) gemif/cmd/gemif

gemif-build-all: clean generate ## Build GemIF server for linux and mac
	GOOS=darwin GOARCH=amd64 go build -o ./bin/darwin-amd64/gemif -ldflags=$(ldflags) gemif/cmd/gemif
	GOOS=linux GOARCH=amd64 go build -o ./bin/linux-amd64/gemif -ldflags=$(ldflags) gemif/cmd/gemif
	GOOS=linux GOARCH=arm64 go build -o ./bin/linux-arm64/gemif -ldflags=$(ldflags) gemif/cmd/gemif
	GOOS=darwin GOARCH=amd64 go build -o ./bin/gemif-darwin-amd64/gemif -ldflags=$(ldflags) gemif/cmd/gemif
	GOOS=linux GOARCH=amd64 go build -o ./bin/gemif-linux-amd64/gemif -ldflags=$(ldflags) gemif/cmd/gemif
	GOOS=linux GOARCH=arm64 go build -o ./bin/gemif-linux-arm64/gemif -ldflags=$(ldflags) gemif/cmd/gemif

gemifc-build: clean ## Build story copiler for your native architecture
	go build -o ./bin/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc

gemifc-build-all: clean ## Build story compiler for linux and mac
	GOOS=darwin GOARCH=amd64 go build -o ./bin/darwin-amd64/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc
	GOOS=linux GOARCH=amd64 go build -o ./bin/linux-amd64/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc
	GOOS=linux GOARCH=arm64 go build -o ./bin/linux-arm64/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc
	GOOS=darwin GOARCH=amd64 go build -o ./bin/gemif-darwin-amd64/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc
	GOOS=linux GOARCH=amd64 go build -o ./bin/gemif-linux-amd64/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc
	GOOS=linux GOARCH=arm64 go build -o ./bin/gemif-linux-arm64/gemifc -ldflags=$(ldflags) gemif/cmd/gemifc

build: gemif-build gemifc-build ## Build gemif and gemifc for native architecture
build-all: gemif-build-all gemifc-build-all ## Build gemif and gemifc for linux and mac


@@ 62,6 62,15 @@ generate: ## Generate bindata from static files
protobuf: ## until i can reliably re-generate this, separate it from generate
	protoc -I pkg/ --go_out=pkg/ pkg/gamemanager/statetoken.proto

##@ Deploy
package: build-all ## Build everything and package up arch-specific tarballs
	tar czvf ./bin/gemif-darwin-amd64.tar.gz ./bin/gemif-darwin-amd64
	tar czvf ./bin/gemif-linux-amd64.tar.gz ./bin/gemif-linux-amd64
	tar czvf ./bin/gemif-linux-arm64.tar.gz ./bin/gemif-linux-arm64

release: package ## Attach packages to sr.ht ref for current tag
	./scripts/release_version.sh

##@ Test
test: ## Run tests
	go test $(shell go list ./...) -coverprofile=coverage.out

A scripts/release_version.sh => scripts/release_version.sh +14 -0
@@ 0,0 1,14 @@
#!/usr/bin/env sh
set -e

git_tag=`git describe --exact-match 2> /dev/null || echo ""`
if [ "$git_tag" != "" ]; then
    echo "Releasing $git_tag!"
    curl -H"Authorization: token $SRHT_TOKEN" https://git.sr.ht/api/~nromdotcom/repos/gemif/artifacts/$git_tag -F "file=@./bin/gemif-darwin-amd64.tar.gz"
    curl -H"Authorization: token $SRHT_TOKEN" https://git.sr.ht/api/~nromdotcom/repos/gemif/artifacts/$git_tag -F "file=@./bin/gemif-linux-amd64.tar.gz"
    curl -H"Authorization: token $SRHT_TOKEN" https://git.sr.ht/api/~nromdotcom/repos/gemif/artifacts/$git_tag -F "file=@./bin/gemif-linux-arm64.tar.gz"
    echo ""
    echo "DONE!"
else
    echo "Non-tagged commit, not releasing!"
fi
\ No newline at end of file