2020-04-06 04:44:28 +00:00
|
|
|
name: Release
|
|
|
|
on: push
|
|
|
|
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
REGISTRY: docker.pkg.github.com
|
|
|
|
IMAGE: zitadel
|
|
|
|
NODE_VERSION: '12'
|
|
|
|
GO_VERSION: '^1.14.1'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
2020-07-07 13:21:18 +00:00
|
|
|
## Angular test, will be added later
|
|
|
|
|
|
|
|
angular-lint:
|
2020-05-13 12:41:43 +00:00
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ./console
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-07-07 13:21:18 +00:00
|
|
|
- name: Install Protoc
|
|
|
|
uses: arduino/setup-protoc@master
|
|
|
|
with:
|
|
|
|
version: '3.x'
|
|
|
|
- run: wget -O protoc-gen-grpc-web https://github.com/grpc/grpc-web/releases/download/1.2.0/protoc-gen-grpc-web-1.2.0-linux-x86_64
|
|
|
|
- run: sudo mv protoc-gen-grpc-web /usr/local/bin/protoc-gen-grpc-web
|
|
|
|
- run: sudo chmod +x /usr/local/bin/protoc-gen-grpc-web
|
|
|
|
- uses: actions/checkout@v2
|
2020-05-13 12:41:43 +00:00
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- run: npm ci
|
|
|
|
- run: npm run lint
|
|
|
|
|
|
|
|
angular-build:
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ./console
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-07-07 13:21:18 +00:00
|
|
|
- name: Install Protoc
|
|
|
|
uses: arduino/setup-protoc@master
|
|
|
|
with:
|
|
|
|
version: '3.x'
|
|
|
|
- run: wget -O protoc-gen-grpc-web https://github.com/grpc/grpc-web/releases/download/1.2.0/protoc-gen-grpc-web-1.2.0-linux-x86_64
|
|
|
|
- run: sudo mv protoc-gen-grpc-web /usr/local/bin/protoc-gen-grpc-web
|
|
|
|
- run: sudo chmod +x /usr/local/bin/protoc-gen-grpc-web
|
2020-05-13 12:41:43 +00:00
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- run: npm ci
|
|
|
|
- run: npm run prodbuild
|
2020-04-06 04:44:28 +00:00
|
|
|
- uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: angular
|
2020-05-13 12:41:43 +00:00
|
|
|
path: console/dist/console
|
|
|
|
|
|
|
|
go-test:
|
2020-04-06 04:44:28 +00:00
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-go@v2-beta
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
|
|
|
- run: go test -race -v -coverprofile=profile.cov ./...
|
|
|
|
- uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: go-coverage
|
|
|
|
path: profile.cov
|
|
|
|
- uses: codecov/codecov-action@v1
|
|
|
|
with:
|
|
|
|
file: ./profile.cov
|
|
|
|
name: codecov-go
|
2020-05-13 12:41:43 +00:00
|
|
|
|
2020-07-07 13:21:18 +00:00
|
|
|
## go lint, will be added later
|
2020-05-13 12:41:43 +00:00
|
|
|
|
|
|
|
go-build:
|
|
|
|
runs-on: ubuntu-18.04
|
2020-07-03 08:04:37 +00:00
|
|
|
needs: [angular-build, angular-lint, go-test] ### We need the artifact from the angular build and that's why we wait here
|
2020-05-14 05:38:58 +00:00
|
|
|
name: Build ${{ matrix.goos }}-${{ matrix.goarch }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
goos: [ 'linux', 'darwin', 'windows' ]
|
|
|
|
goarch: ['amd64']
|
2020-05-13 12:41:43 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-go@v2-beta
|
|
|
|
with:
|
|
|
|
go-version: ${{ env.GO_VERSION }}
|
2020-05-14 05:38:58 +00:00
|
|
|
- uses: actions/download-artifact@v2
|
2020-04-06 04:44:28 +00:00
|
|
|
with:
|
|
|
|
name: angular
|
2020-07-08 11:56:37 +00:00
|
|
|
path: console/dist/console
|
2020-05-13 12:41:43 +00:00
|
|
|
- run: go get github.com/rakyll/statik
|
|
|
|
- run: ./build/console/generate-static.sh
|
2020-07-08 11:56:37 +00:00
|
|
|
- run: cat internal/ui/console/statik/statik.go
|
2020-06-05 05:50:04 +00:00
|
|
|
- run: ./build/login/generate-static.sh
|
2020-07-08 11:56:37 +00:00
|
|
|
- run: cat internal/ui/login/statik/statik.go
|
2020-06-09 13:11:42 +00:00
|
|
|
- run: ./build/notification/generate-static.sh
|
|
|
|
- run: cat internal/notification/statik/statik.go
|
2020-06-22 11:51:44 +00:00
|
|
|
- run: ./build/zitadel/generate-static.sh
|
|
|
|
- run: cat internal/statik/statik.go
|
2020-05-14 05:38:58 +00:00
|
|
|
- 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
|
2020-05-13 12:41:43 +00:00
|
|
|
- uses: actions/upload-artifact@v1
|
|
|
|
with:
|
2020-05-14 05:38:58 +00:00
|
|
|
name: zitadel-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
|
|
path: zitadel-${{ matrix.goos }}-${{ matrix.goarch }}
|
2020-05-13 12:41:43 +00:00
|
|
|
|
|
|
|
container-prod:
|
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
needs: go-build
|
|
|
|
steps:
|
|
|
|
- name: Source checkout
|
|
|
|
uses: actions/checkout@v2
|
2020-05-14 05:38:58 +00:00
|
|
|
- uses: actions/download-artifact@v2
|
2020-04-06 04:44:28 +00:00
|
|
|
with:
|
2020-05-14 05:38:58 +00:00
|
|
|
name: zitadel-linux-amd64
|
|
|
|
path: .artifacts
|
2020-04-06 04:44:28 +00:00
|
|
|
- uses: docker/build-push-action@v1
|
|
|
|
with:
|
2020-07-03 08:04:37 +00:00
|
|
|
dockerfile: build/docker/Dockerfile
|
2020-04-06 04:44:28 +00:00
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ github.token }}
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
repository: ${{ github.repository }}/${{ env.IMAGE }}
|
|
|
|
tag_with_ref: true
|
|
|
|
tag_with_sha: true
|
|
|
|
|
|
|
|
container-vulnerability-scan:
|
|
|
|
runs-on: ubuntu-18.04
|
2020-05-13 12:41:43 +00:00
|
|
|
needs: container-prod
|
2020-04-06 04:44:28 +00:00
|
|
|
steps:
|
|
|
|
- name: Source checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Generate Short SHA Container Tag
|
|
|
|
id: vars
|
|
|
|
run: echo "::set-output name=sha_short::SHA-$(git rev-parse --short HEAD)"
|
|
|
|
- name: Check outputs
|
|
|
|
run: echo ${{ steps.vars.outputs.sha_short }}
|
|
|
|
- name: Docker Login
|
|
|
|
run: docker login $REGISTRY -u $GITHUB_ACTOR -p $GITHUB_TOKEN
|
|
|
|
- uses: anchore/scan-action@master
|
|
|
|
with:
|
|
|
|
image-reference: "${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE }}:${{ steps.vars.outputs.sha_short }}"
|
2020-07-03 08:04:37 +00:00
|
|
|
dockerfile-path: "./build/docker/Dockerfile"
|
2020-04-06 04:44:28 +00:00
|
|
|
fail-build: false
|
2020-07-02 13:45:04 +00:00
|
|
|
acs-report-enable: true
|
|
|
|
- name: Upload Anchore Scan Report
|
|
|
|
uses: github/codeql-action/upload-sarif@v1
|
2020-04-06 04:44:28 +00:00
|
|
|
with:
|
2020-07-02 13:45:04 +00:00
|
|
|
sarif_file: results.sarif
|
2020-04-06 04:44:28 +00:00
|
|
|
|
2020-04-07 12:45:59 +00:00
|
|
|
release:
|
2020-04-06 04:44:28 +00:00
|
|
|
runs-on: ubuntu-18.04
|
2020-07-03 08:04:37 +00:00
|
|
|
needs: [container-prod]
|
2020-04-06 07:44:32 +00:00
|
|
|
env:
|
|
|
|
DOCKER_USERNAME: ${{ github.actor }}
|
|
|
|
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
|
2020-04-06 04:44:28 +00:00
|
|
|
steps:
|
|
|
|
- name: Source checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Generate Short SHA Container Tag
|
|
|
|
id: vars
|
|
|
|
run: echo "::set-output name=sha_short::SHA-$(git rev-parse --short HEAD)"
|
2020-05-14 05:38:58 +00:00
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
path: .artifacts
|
|
|
|
- name: Display structure of downloaded files
|
|
|
|
run: ls -R
|
|
|
|
working-directory: .artifacts
|
2020-04-06 04:44:28 +00:00
|
|
|
- name: Docker Login
|
|
|
|
run: docker login $REGISTRY -u $GITHUB_ACTOR -p $GITHUB_TOKEN
|
|
|
|
- name: Docker Pull short-sha
|
|
|
|
run: docker pull $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:${{ steps.vars.outputs.sha_short }}
|
2020-04-07 12:45:59 +00:00
|
|
|
- name: Semantic Release
|
|
|
|
uses: cycjimmy/semantic-release-action@v2
|
|
|
|
with:
|
2020-05-14 05:38:58 +00:00
|
|
|
dry_run: false
|
2020-04-07 12:45:59 +00:00
|
|
|
semantic_version: 17.0.4
|
|
|
|
extra_plugins: |
|
2020-04-16 11:46:43 +00:00
|
|
|
@semantic-release/exec@5.0.0
|
|
|
|
- name: Docker Tag Version
|
|
|
|
run: docker tag $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:${{ steps.vars.outputs.sha_short }} $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:$CAOS_NEXT_VERSION
|
|
|
|
if: env.CAOS_NEXT_VERSION != ''
|
|
|
|
- name: Docker Tag Latest
|
|
|
|
run: docker tag $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:${{ steps.vars.outputs.sha_short }} $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:latest
|
|
|
|
if: env.CAOS_NEXT_VERSION != ''
|
|
|
|
- name: Docker Push Version
|
|
|
|
run: docker push $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:$CAOS_NEXT_VERSION
|
|
|
|
if: env.CAOS_NEXT_VERSION != ''
|
|
|
|
- name: Docker Push Latest
|
|
|
|
run: docker push $REGISTRY/$GITHUB_REPOSITORY/$IMAGE:latest
|
|
|
|
if: env.CAOS_NEXT_VERSION != ''
|
2020-06-10 10:38:13 +00:00
|
|
|
- name: Deploy DEV environment
|
|
|
|
env:
|
|
|
|
TARGET_ENVIRONMENT: "dev"
|
|
|
|
GIT_OPSREPO_DEPLOYTOKEN: ${{secrets.GIT_OPSREPO_DEPLOYTOKEN}}
|
|
|
|
run: |
|
|
|
|
source ./.github/scripts/githelper.sh
|
|
|
|
setup_git
|
|
|
|
checkout_project
|
|
|
|
change_image_version
|
|
|
|
upload_files
|
|
|
|
if: env.CAOS_NEXT_VERSION != ''
|