From 740af331e34ac9d33be7fd46a4aed442355a582d Mon Sep 17 00:00:00 2001 From: f41gh7 Date: Thu, 25 Mar 2021 17:42:30 +0300 Subject: [PATCH] Adds github actions changes gh actions, adds few more binaries fixes build --- .github/workflows/master.yaml | 23 +++++++++++++++ .github/workflows/release.yaml | 32 +++++++++++++++++++++ Makefile | 31 ++++++++++++++++++++ packages/victoria-metrics-ui/Dockerfile-web | 7 +++-- 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/master.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 Makefile diff --git a/.github/workflows/master.yaml b/.github/workflows/master.yaml new file mode 100644 index 0000000..cf5b80c --- /dev/null +++ b/.github/workflows/master.yaml @@ -0,0 +1,23 @@ +name: publish latest +# This workflow will run on master branch +on: + push: + branches: + - 'master' +jobs: + build: + name: build + runs-on: ubuntu-18.04 + steps: + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v2.x + + - name: Code checkout + uses: actions/checkout@master + + - name: build and push to remote registry + env: + TAG: ${{ env.GITHUB_REF_SLUG }} + run: | + echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin + make latest-push diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7a697b4 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,32 @@ +name: Release +on: + release: + types: + - created +jobs: + release: + name: Release on GitHub + runs-on: ubuntu-18.04 + steps: + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v2.x + + - name: Check out code + uses: actions/checkout@v2 + + - name: build and push to remote registry + env: + TAG: ${{ env.GITHUB_REF_SLUG }} + run: | + echo ${{secrets.REPO_KEY}} | docker login --username ${{secrets.REPO_USER}} --password-stdin + make release-push + + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + ui-web-amd64.zip + ui-web-windows.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e644f56 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +REPO=victoriametrics/ui + +BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \ + git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -c 10-17))) + +PKG_TAG ?= $(shell git tag -l --points-at HEAD) +ifeq ($(PKG_TAG),) +PKG_TAG := $(BUILDINFO_TAG) +endif + + +package-via-docker: + cd packages/victoria-metrics-ui &&\ + docker build -t ${REPO}:latest -f Dockerfile-web . + +release-via-docker: package-via-docker + echo ${PKG_TAG} + docker tag ${REPO}:latest ${REPO}:${PKG_TAG} + docker rm ui-build-${PKG_TAG} 2>> /dev/null || true + docker create --name ui-build-${PKG_TAG} ${REPO}:${PKG_TAG} + docker cp ui-build-${PKG_TAG}:/app/web $(shell pwd)/ui-web-amd64 + docker cp ui-build-${PKG_TAG}:/app/web-windows $(shell pwd)/ui-web-windows + zip -r ui-web-amd64.zip ui-web-amd64 + zip -r ui-web-windows.zip ui-web-windows + docker rm ui-build-${PKG_TAG} + +latest-push: package-via-docker + docker push ${REPO} + +release-push: release-via-docker + docker push ${REPO}:${PKG_TAG} \ No newline at end of file diff --git a/packages/victoria-metrics-ui/Dockerfile-web b/packages/victoria-metrics-ui/Dockerfile-web index d87b7a0..d839ba9 100644 --- a/packages/victoria-metrics-ui/Dockerfile-web +++ b/packages/victoria-metrics-ui/Dockerfile-web @@ -16,11 +16,14 @@ COPY --from=build-static-stage /app/build /build WORKDIR /build COPY web/ /build/ -RUN CGO_ENABLED=0 go build main.go && chmod +x main +RUN GOOS=linux GOARCH=amd64 GO111MODULE=on CGO_ENABLED=0 go build -o web-amd64 github.com/VictoriMetrics/vmui/ && \ + GOOS=windows GOARCH=amd64 GO111MODULE=on CGO_ENABLED=0 go build -o web-windows github.com/VictoriMetrics/vmui/ FROM alpine:3.13.2 USER root -COPY --from=build-web-stage /build/main /app/web + +COPY --from=build-web-stage /build/web-amd64 /app/web +COPY --from=build-web-stage /build/web-windows /app/web-windows RUN adduser -S -D -u 1000 web && chown -R web /app USER web