Skip to content

Commit

Permalink
publish to marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
jaylevin authored Oct 6, 2023
1 parent 9182965 commit 9df8b4f
Showing 1 changed file with 31 additions and 71 deletions.
102 changes: 31 additions & 71 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ name: CI
on:
push:
branches:
- master
- main # TODO: change default branch to master and remove this line
- main
- release-*
pull_request: {}
workflow_dispatch: {}

env:
# Common versions
GO_VERSION: '1.20'
GOLANGCI_VERSION: 'v1.52.2'
GO_VERSION: '1.18'
GOLANGCI_VERSION: 'v1.47.1'
DOCKER_BUILDX_VERSION: 'v0.8.2'

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
# a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether
# credentials have been provided before trying to run steps that need them.
CONTRIB_DOCKER_USR: ${{ secrets.CONTRIB_DOCKER_USR }}
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
AWS_USR: ${{ secrets.AWS_USR }}

Expand All @@ -44,12 +42,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -74,12 +72,13 @@ jobs:
- name: Vendor Dependencies
run: make vendor vendor.check

# We could run 'make lint' but we prefer this action because it leaves
# 'annotations' (i.e. it comments on PRs to point out linter violations).
# This action uses its own setup-go, which always seems to use the latest
# stable version of Go. We could run 'make lint' to ensure our desired Go
# version, but we prefer this action because it leaves 'annotations' (i.e.
# it comments on PRs to point out linter violations).
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=30m
version: ${{ env.GOLANGCI_VERSION }}

check-diff:
Expand All @@ -89,12 +88,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -115,35 +114,12 @@ jobs:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check
- name: make generate
run: |
make generate > /dev/null || true
- name: debug
run: |
tree .work || true
- name: pre-process-docs
continue-on-error: true
run: |
set +e
broken_doc_file=".work/confluentinc/confluent/docs/resources/confluent_ksql_cluster.md"
if ! grep -q page_title "$broken_doc_file"; then
echo '---
# generated by Github Action
page_title: "confluent_ksql_cluster Resource - terraform-provider-confluent"
subcategory: ""
description: |-
---' | cat - $broken_doc_file > temp && mv temp $broken_doc_file
fi

- name: Check Diff
run: |
set +e
go install golang.org/x/tools/cmd/goimports@latest
make generate && make check-diff
git status
run: make check-diff

unit-tests:
runs-on: ubuntu-20.04
Expand All @@ -152,15 +128,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

Expand Down Expand Up @@ -212,15 +188,15 @@ jobs:
install: true

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

Expand All @@ -242,19 +218,11 @@ jobs:
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-pkg-
- name: Vendor Dependencies
run: make vendor vendor.check

- name: Build Helm Chart
run: make -j2 build
env:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Run E2E Tests
run: make e2e USE_HELM3=true
#- name: Run E2E Tests
# run: make e2e USE_HELM3=true

publish-artifacts:
runs-on: ubuntu-20.04
Expand All @@ -274,15 +242,15 @@ jobs:
install: true

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: true

- name: Fetch History
run: git fetch --prune --unshallow

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

Expand Down Expand Up @@ -313,42 +281,34 @@ jobs:
# We're using docker buildx, which doesn't actually load the images it
# builds by default. Specifying --load does so.
BUILD_ARGS: "--load"

- name: Publish Artifacts to GitHub
uses: actions/upload-artifact@v2
with:
name: output
path: _output/**

- name: Login to Docker
uses: docker/login-action@v1
if: env.CONTRIB_DOCKER_USR != ''
with:
username: ${{ secrets.CONTRIB_DOCKER_USR }}
password: ${{ secrets.CONTRIB_DOCKER_PSW }}


- name: Login to Upbound
uses: docker/login-action@v1
if: env.XPKG_ACCESS_ID != ''
with:
registry: xpkg.upbound.io
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}

- name: Publish Artifacts to S3 and Docker Hub
- name: Publish Artifacts to S3 and Upbound Marketplace
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}
if: env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
if: env.AWS_USR != '' && env.XPKG_ACCESS_ID != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Promote Artifacts in S3 and Docker Hub
if: github.ref == 'refs/heads/master' && env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
- name: Promote Artifacts in S3 and Upbound Marketplace
if: github.ref == 'refs/heads/main' && env.AWS_USR != '' && env.XPKG_ACCESS_ID != ''
run: make -j2 promote
env:
BRANCH_NAME: master
CHANNEL: master
BRANCH_NAME: main
CHANNEL: main
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}

0 comments on commit 9df8b4f

Please sign in to comment.