From 767bc5ce6cf752a24714c27b84b5d8480cac7dbc Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 14 May 2020 07:38:58 +0200 Subject: [PATCH] chore: matrix build (#106) * chore: matrix build * chore: test goos goarch * fix: artifact path * chore: new download version * artifact paths --- .github/workflows/release.yml | 27 +++++++++++++++++++-------- .releaserc.js | 8 +++++++- build/docker/prod | 9 +++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7809c2562c..9aaf6c4d40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,23 +84,28 @@ jobs: go-build: runs-on: ubuntu-18.04 needs: [angular-build, angular-test, angular-lint, go-test] ### We need the artifact from the angular build and that's why we wait here + name: Build ${{ matrix.goos }}-${{ matrix.goarch }} + strategy: + matrix: + goos: [ 'linux', 'darwin', 'windows' ] + goarch: ['amd64'] steps: - uses: actions/checkout@v2 - uses: actions/setup-go@v2-beta with: go-version: ${{ env.GO_VERSION }} - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v2 with: name: angular path: console/dist/app - run: go get github.com/rakyll/statik - run: ./build/console/generate-static.sh - run: cat pkg/console/statik/statik.go - - run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o zitadel cmd/zitadel/main.go + - run: CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o zitadel-${{ matrix.goos }}-${{ matrix.goarch }} cmd/zitadel/main.go - uses: actions/upload-artifact@v1 with: - name: go-binary - path: zitadel + name: zitadel-${{ matrix.goos }}-${{ matrix.goarch }} + path: zitadel-${{ matrix.goos }}-${{ matrix.goarch }} container-prod: runs-on: ubuntu-18.04 @@ -108,10 +113,10 @@ jobs: steps: - name: Source checkout uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v2 with: - name: go-binary - path: .build/go + name: zitadel-linux-amd64 + path: .artifacts - uses: docker/build-push-action@v1 with: dockerfile: build/docker/prod @@ -175,6 +180,12 @@ jobs: - name: Generate Short SHA Container Tag id: vars run: echo "::set-output name=sha_short::SHA-$(git rev-parse --short HEAD)" + - uses: actions/download-artifact@v2 + with: + path: .artifacts + - name: Display structure of downloaded files + run: ls -R + working-directory: .artifacts - name: Docker Login run: docker login $REGISTRY -u $GITHUB_ACTOR -p $GITHUB_TOKEN - name: Docker Pull short-sha @@ -182,7 +193,7 @@ jobs: - name: Semantic Release uses: cycjimmy/semantic-release-action@v2 with: - dry_run:  false + dry_run: false semantic_version: 17.0.4 extra_plugins: | @semantic-release/exec@5.0.0 diff --git a/.releaserc.js b/.releaserc.js index 5c80756feb..51683a3d09 100644 --- a/.releaserc.js +++ b/.releaserc.js @@ -3,7 +3,13 @@ module.exports = { plugins: [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", - "@semantic-release/github", + ["@semantic-release/github", { + "assets": [ + {"path": ".artifacts/zitadel-darwin-amd64/zitadel-darwin-amd64", "label": "Darwin x86_64"}, + {"path": ".artifacts/zitadel-linux-amd64/zitadel-linux-amd64", "label": "Linux x86_64"}, + {"path": ".artifacts/zitadel-windows-amd64/zitadel-windows-amd64", "label": "Windows x86_64"} + ] + }], ["@semantic-release/exec", { "publishCmd": "echo '::set-env name=CAOS_NEXT_VERSION::${nextRelease.version}'" }], diff --git a/build/docker/prod b/build/docker/prod index 368d9abb74..86c5fd8b9f 100644 --- a/build/docker/prod +++ b/build/docker/prod @@ -1,18 +1,15 @@ -# +# This Stage prepares the user in the container and copies the files FROM alpine:latest as prepare RUN adduser -D zitadel -COPY .build/go/zitadel / +COPY .artifacts/zitadel-linux-amd64 /zitadel COPY cmd/zitadel/*.yaml / RUN chmod a+x /zitadel -# +# This Stage is intended as production image FROM scratch as final COPY --from=prepare /etc/passwd /etc/passwd COPY --from=prepare / / - USER zitadel - HEALTHCHECK NONE - ENTRYPOINT ["/zitadel"] ## TODO enable CMD \ No newline at end of file