diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 25620f7b..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,205 +0,0 @@ -version: 2.1 - -orbs: - aws: circleci/aws-cli@0.1.13 - -jobs: - build: - docker: - - - image: circleci/golang:1.14 - environment: - GOFLAGS: -mod=readonly - - steps: - - checkout - - - - restore_cache: - name: Restore build dependencies - keys: - - build-deps-v1-{{ .Branch }}-{{ checksum "Makefile" }} - - - - restore_cache: - name: Restore Go module cache - keys: - - gomod-v1-{{ .Branch }}-{{ checksum "go.sum" }} - - gomod-v1-{{ .Branch }} - - gomod-v1-master - - gomod-v1 - - - - run: - name: Download Go module cache - command: go mod download - - - - save_cache: - name: Save Go module cache - key: gomod-v1-{{ .Branch }}-{{ checksum "go.sum" }} - paths: - - /go/pkg/mod - - - - restore_cache: - name: Restore license cache - keys: - - licensei-v1-{{ .Branch }}-{{ checksum "go.sum" }} - - licensei-v1-{{ .Branch }} - - licensei-v1-master - - licensei-v1 - - - - run: - name: Download license information for dependencies - command: make license-cache - - - - save_cache: - name: Save license cache - key: licensei-v1-{{ .Branch }}-{{ checksum "go.sum" }} - paths: - - .licensei.cache - - - - run: - name: Check dependency licenses - command: make license-check - - - - run: - name: Build - command: make build - - - - run: - name: Run linter - command: make lint - - - - run: - name: Run tests - command: GOARGS="-p=2" make test - - - - save_cache: - name: Save build dependencies - key: build-deps-v1-{{ .Branch }}-{{ checksum "Makefile" }} - paths: - - bin/ - - - - store_test_results: - path: build/test_results/ - - - store_artifacts: - path: build/ - - release: - docker: - - - image: circleci/golang:1.14 - environment: - GOFLAGS: -mod=readonly - - steps: - - checkout - - - - restore_cache: - name: Restore Go module cache - keys: - - gomod-v1-{{ .Branch }}-{{ checksum "go.sum" }} - - gomod-v1-{{ .Branch }} - - gomod-v1-master - - gomod-v1 - - - - run: - name: Release - command: make release - - cdn-invalidate: - executor: aws/default - steps: - - - aws/install - - - aws/configure - - - run: - name: Invalidate cloudfront edge cache - command: | - aws cloudfront create-invalidation \ - --distribution-id ${CDN_DISTRIBUTION_ID} \ - --paths "/downloads/pke/*" - - - - trigger-pke-image-build: - docker: - - - image: circleci/golang:1.14 - resource_class: small - steps: - - checkout - - - run: - name: Create tag - command: | - scripts/create-git-tag.sh 'banzaicloud' 'pke-image' 'refs/heads/master' "pke-${CIRCLE_TAG}" - - trigger-docs-update: - docker: - - image: cimg/base:stable - resource_class: small - steps: - - checkout - - run: - name: Trigger - command: scripts/trigger-docs-update.sh "${CIRCLE_TAG}" - -workflows: - version: 2 - ci: - jobs: - - - build: - filters: - tags: - only: /^v?\d+\.\d+\.\d+(-\S*)?$/ - - - release: - requires: - - build - filters: - tags: - only: /^v?\d+\.\d+\.\d+(-\S*)?$/ - branches: - ignore: /.*/ - - - cdn-invalidate: - requires: - - release - filters: - tags: - only: /^v?\d+\.\d+\.\d+(-\S*)?$/ - branches: - ignore: /.*/ - - - trigger-pke-image-build: - requires: - - release - filters: - tags: - only: /^v?\d+\.\d+\.\d+(-\S*)?$/ - branches: - ignore: /.*/ - - - trigger-docs-update: - requires: - - release - filters: - tags: - only: /^v?\d+\.\d+\.\d+$/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..687f92f5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +name: Build PKE +on: + pull_request: + branches: [master] + paths-ignore: + - "README.md" + - "docs/**" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Set up Go 1.17 + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Check licenses + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: make license-check + + - name: Build code + run: make build + + - name: Lint code + run: make lint + + - name: Run test + run: GOARGS="-p=2" make test diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml new file mode 100644 index 00000000..2d95a303 --- /dev/null +++ b/.github/workflows/image-build.yaml @@ -0,0 +1,32 @@ +name: Trigger PKE image build +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + trigger-image-build: + runs-on: ubuntu-latest + needs: release + + steps: + + - name: Check out code + uses: actions/checkout@v2 + - name: Set env + run: ::set-output name=tag::${GITHUB_REF#refs/*/} + + - name: Trigger pke-image build + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'banzaicloud', + repo: 'pke-image', + workflow_id: 'packer-build.yml', + ref: 'master', + inputs: { + tag: '${{ steps.vars.outputs.tag }}' + } + }) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9cb91ca4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: Release PKE +on: + push: + tags: + - "*" + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: 1.5.0 + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index eab43e27..879e5540 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -33,10 +33,3 @@ nfpms: bindir: /usr/local/bin license: Apache 2.0 file_name_template: "{{ .ProjectName }}-{{ .Version }}_{{ .Os }}_{{ .Arch }}" - -blobs: - - - provider: s3 - bucket: banzaicloud.com - region: us-east-1 - folder: "downloads/pke"