diff options
-rw-r--r-- | .github/workflows/release.yml | 18 | ||||
-rw-r--r-- | Dockerfile | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | Makefile | 40 | ||||
-rwxr-xr-x | build.sh | 71 |
4 files changed, 37 insertions, 94 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2a5972df..55525260 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,6 @@ name: release on: release: # Docs: <https://help.github.com/en/articles/events-that-trigger-workflows#release-event-release> types: [published] - push: # TODO just for a test (remove this line) jobs: build: @@ -12,16 +11,17 @@ jobs: strategy: fail-fast: false matrix: - os: [linux, freebsd, darwin] - compiler: [gcc] - archiver: [tar] - arch: [amd64] + os: [windows, freebsd, darwin] # linux, freebsd, darwin, windows + compiler: [gcc] # gcc, musl-gcc + archiver: [zip] # tar, zip + arch: [amd64] # amd64, 386 include: - - os: windows # include build for windows directly + - os: linux compiler: gcc - archiver: zip + archiver: tar arch: amd64 - - compiler: musl-gcc # more info: <https://musl.libc.org/> + - os: '' + compiler: musl-gcc # more info: <https://musl.libc.org/> archiver: tar arch: amd64 steps: @@ -119,7 +119,7 @@ jobs: uses: actions/checkout@v2 - name: Make docker login - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin &> /dev/null + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin - name: Generate builder values id: values @@ -1,5 +1,5 @@ # Image page: <https://hub.docker.com/_/golang> -FROM golang:1.15.6-alpine as builder +FROM golang:1.15.5-alpine as builder # app version and build date must be passed during image building (version without any prefix). # e.g.: `docker build --build-arg "APP_VERSION=1.2.3" --build-arg "BUILD_TIME=$(date +%FT%T%z)" .` @@ -1,16 +1,29 @@ -build: - @./build.sh -all: - @./build.sh all -clean: - rm -rf rr -install: all +#!/usr/bin/make +# Makefile readme (ru): <http://linux.yaroslavl.ru/docs/prog/gnu_make_3-79_russian_manual.html> +# Makefile readme (en): <https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents> + +SHELL = /bin/sh + +.DEFAULT_GOAL := build + +# This will output the help for each task. thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +help: ## Show this help + @printf "\033[33m%s:\033[0m\n" 'Available commands' + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +build: ## Build RR binary file for local os/arch + CGO_ENABLED=0 go build -trimpath -ldflags "-s" -o ./rr ./cmd/rr/main.go + +clean: ## Make some clean + rm ./rr + +install: build ## Build and install RR locally cp rr /usr/local/bin/rr -uninstall: + +uninstall: ## Uninstall locally installed RR rm -f /usr/local/bin/rr -test: - composer update - go test -v -race -cover + +test: ## Run application tests go test -v -race -cover ./util go test -v -race -cover ./service go test -v -race -cover ./service/env @@ -23,6 +36,7 @@ test: go test -v -race -cover ./service/health go test -v -race -cover ./service/gzip go test -v -race -cover ./service/reload -lint: + +lint: ## Run application linters go fmt ./... - golint ./...
\ No newline at end of file + golint ./... diff --git a/build.sh b/build.sh deleted file mode 100755 index 64411dba..00000000 --- a/build.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -cd $(dirname "${BASH_SOURCE[0]}") -OD="$(pwd)" - -# Pushes application version into the build information. -RR_VERSION=1.9.0 - -# Hardcode some values to the core package -LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}" -LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.BuildTime=$(date +%FT%T%z)" -# remove debug info from binary as well as string and symbol tables -LDFLAGS="$LDFLAGS -s" - -build() { - echo Packaging "$1" Build - bdir=roadrunner-${RR_VERSION}-$2-$3 - rm -rf builds/"$bdir" && mkdir -p builds/"$bdir" - GOOS=$2 GOARCH=$3 ./build.sh - - if [ "$2" == "windows" ]; then - mv rr builds/"$bdir"/rr.exe - else - mv rr builds/"$bdir" - fi - - cp README.md builds/"$bdir" - cp CHANGELOG.md builds/"$bdir" - cp LICENSE builds/"$bdir" - cd builds - - if [ "$2" == "linux" ]; then - tar -zcf "$bdir".tar.gz "$bdir" - else - zip -r -q "$bdir".zip "$bdir" - fi - - rm -rf "$bdir" - cd .. -} - -# For musl build you should have musl-gcc installed. If not, please, use: -# go build -a -ldflags "-linkmode external -extldflags '-static' -s" -build_musl() { - echo Packaging "$2" Build - bdir=roadrunner-${RR_VERSION}-$1-$2-$3 - rm -rf builds/"$bdir" && mkdir -p builds/"$bdir" - CC=musl-gcc GOARCH=amd64 go build -trimpath -ldflags "$LDFLAGS" -o "$OD/rr" cmd/rr/main.go - - mv rr builds/"$bdir" - - cp README.md builds/"$bdir" - cp CHANGELOG.md builds/"$bdir" - cp LICENSE builds/"$bdir" - cd builds - zip -r -q "$bdir".zip "$bdir" - - rm -rf "$bdir" - cd .. -} - -if [ "$1" == "all" ]; then - rm -rf builds/ - build "Windows" "windows" "amd64" - build "Mac" "darwin" "amd64" - build "Linux" "linux" "amd64" - build "FreeBSD" "freebsd" "amd64" - build_musl "unknown" "musl" "amd64" - exit -fi - -CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" -o "$OD/rr" cmd/rr/main.go |