From 20bdd8e3a1f9179de5a29383046fd37bea8c754e Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Tue, 12 Apr 2022 16:44:49 +0200 Subject: [PATCH] feat: cloud-run compatibility (#3438) * ci: don't run on tags anymore * ci: also test docker builds * .releaserc.js entry and wf dispatch for prerel * .releaserc.js entry and wf dispatch for prerel * create prerelease * create prereleases * fix syntax * fix: release * test before tag * temporarily disable tests * fix: prerelease * fix: add --rm-dist flag * fix: push to zitadel-common * fix: gcr login * fix: release * fix: ignore generated assets.md * fix: don't use go-releaser before hooks * build grpc client before testing * fix: use docker buildkit * debug * debug * fix: debug * fix: debug * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * fix: run action steps in $GOPATH * unignore * fix: unignore * fix: unignore * build base * fix: ignore * no mod proxy * fix: test using goreleaser before hook * fix: build without having a git tag * fix: build without having a git tag * fix: push to ghcr * fix: login to ghcr * fix: login to ghcr if releasing * fix: permit to write packages * fix: aesthetics * fix: login using base64 encoded key * fix: publish images with short sha and tag * fix: read masterkey from file for start-from-init * fix: release if workflow_dispatch or main * ci: only test before tag * fix: no workdir, login action for gcr * fix: review * fix: run on PR * push amd64 images to gcr --- .github/workflows/zitadel.yml | 73 +++++---- .gitignore | 6 +- .goreleaser.yaml | 15 +- .releaserc.js | 5 +- docs/docs/apis/assets/.gitignore | 1 + docs/docs/apis/assets/.gitkeep | 0 docs/docs/apis/assets/assets.md | 259 ------------------------------- 7 files changed, 57 insertions(+), 302 deletions(-) create mode 100644 docs/docs/apis/assets/.gitignore create mode 100644 docs/docs/apis/assets/.gitkeep delete mode 100755 docs/docs/apis/assets/assets.md diff --git a/.github/workflows/zitadel.yml b/.github/workflows/zitadel.yml index f44686a807..b1e0e17793 100644 --- a/.github/workflows/zitadel.yml +++ b/.github/workflows/zitadel.yml @@ -1,30 +1,28 @@ name: ZITADEL Release on: - #pull_request: + pull_request: push: + tags-ignore: + - "*" + workflow_dispatch: permissions: contents: write + packages: write jobs: Build: runs-on: ubuntu-20.04 + env: + DOCKER_BUILDKIT: 1 steps: - - name: Source checkout - uses: actions/checkout@v2 - - name: Semantic Release - id: semantic - uses: cycjimmy/semantic-release-action@v2 - with: - dry_run: true - semantic_version: 19.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.17 + - name: Source checkout + uses: actions/checkout@v2 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx @@ -32,41 +30,54 @@ jobs: with: driver: docker install: true - - name: Run GoReleaser Snapshot - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - uses: goreleaser/goreleaser-action@v2 + - name: Test + run: docker build -f build/grpc/Dockerfile -t zitadel-base:local . && docker build -f build/zitadel/Dockerfile . -t zitadel-go-test --target go-codecov -o .artifacts/codecov + - name: Tag + id: semantic + uses: cycjimmy/semantic-release-action@v2 with: - distribution: goreleaser - version: v1.5.0 - args: release --snapshot + dry_run: false + semantic_version: 19.0.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Run GoReleaser Release on tag - if: ${{ startsWith(github.ref, 'refs/tags/') }} - uses: goreleaser/goreleaser-action@v2 + - name: GitHub Container Registry Login + if: steps.semantic.outputs.new_release_published == 'true' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Google Artifact Registry Login + if: steps.semantic.outputs.new_release_published == 'true' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' + uses: docker/login-action@v1 + with: + registry: europe-docker.pkg.dev + username: _json_key_base64 + password: ${{ secrets.GCR_JSON_KEY_BASE64 }} + - uses: goreleaser/goreleaser-action@v2 + name: Publish ZITADEL + if: steps.semantic.outputs.new_release_published == 'true' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' with: distribution: goreleaser version: v1.5.0 args: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/upload-artifact@v2 - name: Upload goreleaser dist - with: - name: goreleaser-dist - path: .artifacts/goreleaser - - uses: actions/upload-artifact@v2 - name: Upload gRPC clients + RELEASE_VERSION: ${{ steps.semantic.outputs.release-version }} # I think this line is not needed. Nevertheless, it's explicit + - name: Publish gRPC clients + uses: actions/upload-artifact@v2 + if: steps.semantic.outputs.new_release_published == 'true' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' with: name: grpc-clients path: .artifacts/grpc - - uses: actions/upload-artifact@v2 - name: Upload compiled console + - name: Publish console + uses: actions/upload-artifact@v2 + if: steps.semantic.outputs.new_release_published == 'true' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' with: name: console path: .artifacts/console - - uses: codecov/codecov-action@v1 - name: Upload go coverage + - name: Publish go coverage + uses: codecov/codecov-action@v1 with: files: .artifacts/codecov/profile.cov name: go-codecov diff --git a/.gitignore b/.gitignore index 2a4d1b88e6..b5f00620af 100644 --- a/.gitignore +++ b/.gitignore @@ -4,13 +4,13 @@ *.dll *.so *.dylib -zitadelctl # Test binary, build with `go test -c` *.test # Coverage coverage.txt +profile.cov # Output of the go coverage tool, specifically when used with LiteIDE *.out @@ -40,7 +40,8 @@ cockroach-data/* #binaries cmd/zitadel/zitadel **/statik/statik.go -zitadelctl +/zitadelctl +/zitadel # buildfolders and generated js tmp/ @@ -62,3 +63,4 @@ migrations/cockroach/migrate_cloud.go .notifications .artifacts /zitadel + diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 87ee398cce..9d545a2572 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -27,13 +27,17 @@ builds: dist: .artifacts/goreleaser dockers: - image_templates: - - "caos/zitadel:{{ .Version }}-amd64" + - ghcr.io/caos/zitadel:{{ .Tag }}-amd64 + - ghcr.io/caos/zitadel:{{ .ShortCommit }}-amd64 + - europe-docker.pkg.dev/zitadel-common/zitadel-repo/zitadel:{{ .Tag }}-amd64 + - europe-docker.pkg.dev/zitadel-common/zitadel-repo/zitadel:{{ .ShortCommit }}-amd64 use: buildx dockerfile: build/Dockerfile build_flag_templates: - "--platform=linux/amd64" - image_templates: - - "caos/zitadel:{{ .Version }}-arm64" + - ghcr.io/caos/zitadel:{{ .Tag }}-arm64 + - ghcr.io/caos/zitadel:{{ .ShortCommit }}-arm64 use: buildx dockerfile: build/Dockerfile build_flag_templates: @@ -41,14 +45,9 @@ dockers: archives: - format: binary gomod: - proxy: true - env: - - GOPROXY=https://proxy.golang.org,direct - - GOSUMDB=sum.golang.org + proxy: false checksum: name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" changelog: sort: asc filters: diff --git a/.releaserc.js b/.releaserc.js index 4d5a788627..fbddf38239 100644 --- a/.releaserc.js +++ b/.releaserc.js @@ -1,8 +1,9 @@ module.exports = { branches: [ {name: 'main'}, - {name: '1.x.x', range: '1.x.x', channel: '1.x.x'}, - ], + {name: '1.x.x', range: '1.x.x', channel: '1.x.x'}, + {name: 'workflow-dispatch', prerelease: true}, + ], plugins: [ "@semantic-release/commit-analyzer" ] diff --git a/docs/docs/apis/assets/.gitignore b/docs/docs/apis/assets/.gitignore new file mode 100644 index 0000000000..a0f98a4ea3 --- /dev/null +++ b/docs/docs/apis/assets/.gitignore @@ -0,0 +1 @@ +assets.md diff --git a/docs/docs/apis/assets/.gitkeep b/docs/docs/apis/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/docs/apis/assets/assets.md b/docs/docs/apis/assets/assets.md deleted file mode 100755 index 3bbde85a83..0000000000 --- a/docs/docs/apis/assets/assets.md +++ /dev/null @@ -1,259 +0,0 @@ ---- -title: zitadel/assets ---- - -## AssetsService - - - - - -### UploadDefaultLabelPolicyFont() - -> UploadDefaultLabelPolicyFont() - -POST: /iam/policy/label/font - - - -### GetDefaultLabelPolicyFont() - -> GetDefaultLabelPolicyFont() - -GET: /iam/policy/label/font - - - -### GetPreviewDefaultLabelPolicyFont() - -> GetPreviewDefaultLabelPolicyFont() - -GET: /iam/policy/label/font/_preview - - - - - -### UploadDefaultLabelPolicyIcon() - -> UploadDefaultLabelPolicyIcon() - -POST: /iam/policy/label/icon - -### UploadDefaultLabelPolicyIcon() - -> UploadDefaultLabelPolicyIconDark() - -POST: /iam/policy/label/icon/dark - - - -### GetDefaultLabelPolicyIcon() - -> GetDefaultLabelPolicyIcon() - -GET: /iam/policy/label/icon - -### GetDefaultLabelPolicyIcon() - -> GetDefaultLabelPolicyIconDark() - -GET: /iam/policy/label/icon/dark - - - -### GetPreviewDefaultLabelPolicyIcon() - -> GetPreviewDefaultLabelPolicyIcon() - -GET: /iam/policy/label/icon/_preview - -### GetPreviewDefaultLabelPolicyIcon() - -> GetPreviewDefaultLabelPolicyIconDark() - -GET: /iam/policy/label/icon/dark/_preview - - - - - -### UploadDefaultLabelPolicyLogo() - -> UploadDefaultLabelPolicyLogo() - -POST: /iam/policy/label/logo - -### UploadDefaultLabelPolicyLogo() - -> UploadDefaultLabelPolicyLogoDark() - -POST: /iam/policy/label/logo/dark - - - -### GetDefaultLabelPolicyLogo() - -> GetDefaultLabelPolicyLogo() - -GET: /iam/policy/label/logo - -### GetDefaultLabelPolicyLogo() - -> GetDefaultLabelPolicyLogoDark() - -GET: /iam/policy/label/logo/dark - - - -### GetPreviewDefaultLabelPolicyLogo() - -> GetPreviewDefaultLabelPolicyLogo() - -GET: /iam/policy/label/logo/_preview - -### GetPreviewDefaultLabelPolicyLogo() - -> GetPreviewDefaultLabelPolicyLogoDark() - -GET: /iam/policy/label/logo/dark/_preview - - - - - - - -### UploadOrgLabelPolicyFont() - -> UploadOrgLabelPolicyFont() - -POST: /org/policy/label/font - - - -### GetOrgLabelPolicyFont() - -> GetOrgLabelPolicyFont() - -GET: /org/policy/label/font - - - -### GetPreviewOrgLabelPolicyFont() - -> GetPreviewOrgLabelPolicyFont() - -GET: /org/policy/label/font/_preview - - - - - -### UploadOrgLabelPolicyIcon() - -> UploadOrgLabelPolicyIcon() - -POST: /org/policy/label/icon - -### UploadOrgLabelPolicyIcon() - -> UploadOrgLabelPolicyIconDark() - -POST: /org/policy/label/icon/dark - - - -### GetOrgLabelPolicyIcon() - -> GetOrgLabelPolicyIcon() - -GET: /org/policy/label/icon - -### GetOrgLabelPolicyIcon() - -> GetOrgLabelPolicyIconDark() - -GET: /org/policy/label/icon/dark - - - -### GetPreviewOrgLabelPolicyIcon() - -> GetPreviewOrgLabelPolicyIcon() - -GET: /org/policy/label/icon/_preview - -### GetPreviewOrgLabelPolicyIcon() - -> GetPreviewOrgLabelPolicyIconDark() - -GET: /org/policy/label/icon/dark/_preview - - - - - -### UploadOrgLabelPolicyLogo() - -> UploadOrgLabelPolicyLogo() - -POST: /org/policy/label/logo - -### UploadOrgLabelPolicyLogo() - -> UploadOrgLabelPolicyLogoDark() - -POST: /org/policy/label/logo/dark - - - -### GetOrgLabelPolicyLogo() - -> GetOrgLabelPolicyLogo() - -GET: /org/policy/label/logo - -### GetOrgLabelPolicyLogo() - -> GetOrgLabelPolicyLogoDark() - -GET: /org/policy/label/logo/dark - - - -### GetPreviewOrgLabelPolicyLogo() - -> GetPreviewOrgLabelPolicyLogo() - -GET: /org/policy/label/logo/_preview - -### GetPreviewOrgLabelPolicyLogo() - -> GetPreviewOrgLabelPolicyLogoDark() - -GET: /org/policy/label/logo/dark/_preview - - - - - - - -### UploadMyUserAvatar() - -> UploadMyUserAvatar() - -POST: /users/me/avatar - - - -### GetMyUserAvatar() - -> GetMyUserAvatar() - -GET: /users/me/avatar - - - -