From 98d49bf1dbb315ae2400e196a9554ad98948bd43 Mon Sep 17 00:00:00 2001 From: Dennis Kniep Date: Thu, 21 Mar 2024 20:50:32 +0100 Subject: [PATCH] Changes for local build --- .github/workflows/backport.yml | 34 ----- .github/workflows/commands.yml | 31 ---- .github/workflows/e2e.yaml | 12 -- .github/workflows/{ci.yml => release.yaml} | 158 ++++++++++----------- .github/workflows/tag.yaml | 26 ---- Makefile | 5 +- 6 files changed, 76 insertions(+), 190 deletions(-) delete mode 100644 .github/workflows/backport.yml delete mode 100644 .github/workflows/commands.yml delete mode 100644 .github/workflows/e2e.yaml rename .github/workflows/{ci.yml => release.yaml} (57%) delete mode 100644 .github/workflows/tag.yaml diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml deleted file mode 100644 index b58fca2..0000000 --- a/.github/workflows/backport.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Backport - -on: - # NOTE(negz): This is a risky target, but we run this action only when and if - # a PR is closed, then filter down to specifically merged PRs. We also don't - # invoke any scripts, etc from within the repo. I believe the fact that we'll - # be able to review PRs before this runs makes this fairly safe. - # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ - pull_request_target: - types: [closed] - # See also commands.yml for the /backport triggered variant of this workflow. - -jobs: - # NOTE(negz): I tested many backport GitHub actions before landing on this - # one. Many do not support merge commits, or do not support pull requests with - # more than one commit. This one does. It also handily links backport PRs with - # new PRs, and provides commentary and instructions when it can't backport. - # The main gotchas with this action are that it _only_ supports merge commits, - # and that PRs _must_ be labelled before they're merged to trigger a backport. - open-pr: - runs-on: ubuntu-22.04 - if: github.event.pull_request.merged - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - - name: Open Backport PR - uses: zeebe-io/backport-action@e8161d6a0dbfa2651b7daa76cbb75bc7c925bbf3 # v2.4.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - github_workspace: ${{ github.workspace }} - version: v0.0.8 diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml deleted file mode 100644 index de2b8be..0000000 --- a/.github/workflows/commands.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Comment Commands - -on: issue_comment - -jobs: - backport: - runs-on: ubuntu-22.04 - if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport') - steps: - - name: Extract Command - id: command - uses: xt0rted/slash-command-action@bf51f8f5f4ea3d58abc7eca58f77104182b23e88 # v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - command: backport - reaction: "true" - reaction-type: "eyes" - allow-edits: "false" - permission-level: write - - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - - name: Open Backport PR - uses: zeebe-io/backport-action@e8161d6a0dbfa2651b7daa76cbb75bc7c925bbf3 # v2.4.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - github_workspace: ${{ github.workspace }} - version: v0.0.4 diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml deleted file mode 100644 index 4aae1d9..0000000 --- a/.github/workflows/e2e.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: End to End Testing - -on: - issue_comment: - types: [created] - -jobs: - e2e: - uses: upbound/uptest/.github/workflows/pr-comment-trigger.yml@main - secrets: - UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }} - UPTEST_DATASOURCE: ${{ secrets.UPTEST_DATASOURCE }} diff --git a/.github/workflows/ci.yml b/.github/workflows/release.yaml similarity index 57% rename from .github/workflows/ci.yml rename to .github/workflows/release.yaml index a599dae..4cad283 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/release.yaml @@ -1,23 +1,17 @@ -name: CI +name: Release on: push: - branches: - - main - - release-* + tags: + - "v*.*.*" # Run workflow on version tags, e.g. release-v1.0.0. pull_request: {} workflow_dispatch: {} env: # Common versions GO_VERSION: '1.21' - GOLANGCI_VERSION: 'v1.55.2' - DOCKER_BUILDX_VERSION: 'v0.8.2' - - # Common users. We can't run a step 'if secrets.XXX != ""' but we can run a - # step 'if env.XXX != ""', so we copy these to succinctly test whether - # credentials have been provided before trying to run steps that need them. - UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + GOLANGCI_VERSION: 'v1.54.0' + DOCKER_BUILDX_VERSION: 'v0.9.1' jobs: detect-noop: @@ -27,7 +21,7 @@ jobs: steps: - name: Detect No-op Changes id: noop - uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 + uses: fkirc/skip-duplicate-actions@v5.2.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} paths_ignore: '["**.md", "**.png", "**.jpg"]' @@ -41,12 +35,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@v2 with: submodules: true - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} @@ -55,14 +49,14 @@ jobs: run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT - name: Cache the Go Build Cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-lint- - name: Cache Go Dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -74,7 +68,7 @@ jobs: # 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). - name: Lint - uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4 + uses: golangci/golangci-lint-action@v4 with: version: ${{ env.GOLANGCI_VERSION }} @@ -85,12 +79,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@v2 with: submodules: true - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 + uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} @@ -102,14 +96,14 @@ jobs: run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT - name: Cache the Go Build Cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-check-diff-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-check-diff- - name: Cache Go Dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -119,7 +113,14 @@ jobs: run: make vendor vendor.check - name: Check Diff - run: make check-diff + id: check-diff + run: | + mkdir _output + make check-diff + + - name: Show diff + if: failure() && steps.check-diff.outcome == 'failure' + run: git diff unit-tests: runs-on: ubuntu-22.04 @@ -128,7 +129,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@v2 with: submodules: true @@ -136,7 +137,7 @@ jobs: run: git fetch --prune --unshallow - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 + uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} @@ -145,14 +146,14 @@ jobs: run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT - name: Cache the Go Build Cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-unit-tests- - name: Cache Go Dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -170,76 +171,39 @@ jobs: flags: unittests file: _output/tests/linux_amd64/coverage.txt - local-deploy: - runs-on: ubuntu-22.04 - needs: detect-noop - if: needs.detect-noop.outputs.noop != 'true' - - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - submodules: true - - - name: Fetch History - run: git fetch --prune --unshallow - - - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Find the Go Build Cache - id: go - run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT - - - name: Cache the Go Build Cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 - with: - path: ${{ steps.go.outputs.cache }} - key: ${{ runner.os }}-build-unit-tests-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-build-unit-tests- - - - name: Cache Go Dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 - with: - path: .work/pkg - key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-pkg- - - - name: Vendor Dependencies - run: make vendor vendor.check - - - name: Deploying locally built provider package - run: make local-deploy publish-artifacts: runs-on: ubuntu-22.04 - needs: detect-noop + needs: + - detect-noop + - unit-tests + - check-diff + - lint if: needs.detect-noop.outputs.noop != 'true' steps: - name: Setup QEMU - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3 + uses: docker/setup-qemu-action@v1 with: platforms: all - name: Setup Docker Buildx - uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3 + uses: docker/setup-buildx-action@v1 with: version: ${{ env.DOCKER_BUILDX_VERSION }} install: true + - name: Install up + run: curl -sL https://cli.upbound.io | sh && sudo mv up /usr/local/bin/ + - name: Login to Upbound - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3 - if: env.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR != '' - with: - registry: xpkg.upbound.io - username: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} - password: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + env: + UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + run: | + echo "${UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW}" | up login -t - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + uses: actions/checkout@v2 with: submodules: true @@ -247,23 +211,23 @@ jobs: run: git fetch --prune --unshallow - name: Setup Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5 + uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} - name: Find the Go Build Cache id: go - run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT + run: echo "::set-output name=cache::$(make go.cachedir)" - name: Cache the Go Build Cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: ${{ steps.go.outputs.cache }} key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }} restore-keys: ${{ runner.os }}-build-publish-artifacts- - name: Cache Go Dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4 + uses: actions/cache@v2 with: path: .work/pkg key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} @@ -279,11 +243,35 @@ jobs: # builds by default. Specifying --load does so. BUILD_ARGS: "--load" - - name: Upload Artifacts to GitHub - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4 + - name: Publish Artifacts to GitHub + uses: actions/upload-artifact@v3 with: name: output path: _output/** - name: Publish Artifacts - run: make publish BRANCH_NAME=${GITHUB_REF##*/} + run: make publish BRANCH_NAME=release-${GITHUB_REF##*/} + + - name: Rename xpkg linux_amd64 + run: cd _output/xpkg/linux_amd64/ && ls | xargs -I {} mv {} linux_amd64-{} + + - name: Rename xpkg linux_arm64 + run: cd _output/xpkg/linux_arm64/ && ls | xargs -I {} mv {} linux_arm64-{} + + - name: Rename bin linux_amd64 + run: cd _output/bin/linux_amd64/ && ls | xargs -I {} mv {} linux_amd64-{} + + - name: Rename bin linux_arm64 + run: cd _output/bin/linux_arm64/ && ls | xargs -I {} mv {} linux_arm64-{} + + - name: Create Github release + uses: softprops/action-gh-release@v1 + with: + draft: true + generate_release_notes: true + files: | + _output/xpkg/** + _output/bin/** + body: | + **This is a Github draft release.** + Once ready please remove this and publish the release. \ No newline at end of file diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml deleted file mode 100644 index 6f12ffd..0000000 --- a/.github/workflows/tag.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Tag - -on: - workflow_dispatch: - inputs: - version: - description: 'Release version (e.g. v0.1.0)' - required: true - message: - description: 'Tag message' - required: true - -jobs: - create-tag: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - - name: Create Tag - uses: negz/create-tag@39bae1e0932567a58c20dea5a1a0d18358503320 # v1 - with: - version: ${{ github.event.inputs.version }} - message: ${{ github.event.inputs.message }} - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Makefile b/Makefile index b8a85f0..8ca7f13 100644 --- a/Makefile +++ b/Makefile @@ -65,10 +65,11 @@ IMAGES = $(PROJECT_NAME) # ==================================================================================== # Setup XPKG -XPKG_REG_ORGS ?= xpkg.upbound.io/crossplane-contrib + +XPKG_REG_ORGS ?= xpkg.upbound.io/denniskniep # NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are # inferred. -XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/crossplane-contrib +XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/denniskniep XPKGS = $(PROJECT_NAME) -include build/makelib/xpkg.mk