go_make

    0

    0

    go make file

    Shortcut: go_make

    Filename pattern: Makefile, *.sh

    .PHONY: all build compile package clean rpcgen check install release
    
    BUILDTIME ?= $(shell date +%Y-%m-%d_%I:%M:%S)
    GITCOMMIT ?= $(shell git rev-parse HEAD)
    ifeq ($(CI_PIPELINE_ID),)
        BUILDNUMER := "private"
    else
        BUILDNUMER := $(CI_PIPELINE_ID)
    endif
    VERSION ?= $(shell git describe --tags --always --dirty)
    
    LDFLAGS = -extldflags \
      -static \
      -X "main.BuildTime=$(BUILDTIME)" \
      -X "main.GitCommit=$(GITCOMMIT)" \
      -X "main.BuildNumber=$(BUILDNUMER)"
    
    PREFIX ?= /usr/local
    
    TAG ?= $(shell ./docker-tag.sh -s)
    BRANCH ?= $(git rev-parse --abbrev-ref HEAD)
    
    all: build
    
    clean:
      rm -rf bin
    
    build:
      go build -o bin/ssh-go -ldflags "$(LDFLAGS)" .
    
    vars:
      @echo export SHELL="'$(SHELL)'"
      @echo export TAG="'$(TAG)'"
      @echo export BRANCH="'$(BRANCH)'"
    
    compile: bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER)
    
    package: bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER)
      echo $(GITCOMMIT) > commit.txt
      echo $(VERSION) > version.txt
      zip -r ssh-go-$(VERSION)-$(BUILDNUMER).zip bin commit.txt version.txt
    
    bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER):
      GOOS=linux GOARCH=amd64 go build -o bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER) -ldflags "$(LDFLAGS)"
      cp bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER) bin/ssh-go-linux-amd64-$(VERSION)
    ifeq ($(BRANCH),master)
      cp bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER) bin/ssh-go
    endif
    
    rpcgen:
      buf generate --template api/templates/go.yaml -o rpc/ssh-ca api/protobuf/ssh-ca
    
    check:
      golangci-lint run
    
    install: clean bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER)
      install -d ${PREFIX}/bin
      sudo install bin/ssh-go-linux-amd64-$(VERSION)-$(BUILDNUMER) ${PREFIX}/bin/ssh-go
    
    # use `source .env` and then `make release`
    release: compile
      @rclone --config build/rclone.conf -v copy bin/ssh-go-linux-amd64-$(VERSION) 42:fastone-artifects/ssh-go/
      @echo "linux bin access url is : \n"
      @RCLONE_LOG_LEVEL=ERROR rclone --config build/rclone.conf link 42:fastone-artifects/ssh-go/ssh-go-linux-amd64-$(VERSION)
    
    list:
      @rclone --config build/rclone.conf ls 42:fastone-artifects/ssh-go/
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.