From 0f4686c7cb9fbb01014ae8c19df073b3abef11e7 Mon Sep 17 00:00:00 2001 From: asararatnakar Date: Mon, 25 Sep 2023 12:40:32 -0400 Subject: [PATCH] Fix builds for non main branches Signed-off-by: asararatnakar --- .github/workflows/endtoend-tests.yaml | 4 +- .github/workflows/image-build-pr.yaml | 2 +- .github/workflows/image-build.yaml | 2 +- .github/workflows/integration-tests.yaml | 6 +- .github/workflows/release.yaml | 91 ++++++++++++++++++++++++ .github/workflows/unit-tests.yaml | 9 ++- Makefile | 2 +- 7 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/endtoend-tests.yaml b/.github/workflows/endtoend-tests.yaml index d250b196..3594ebb3 100644 --- a/.github/workflows/endtoend-tests.yaml +++ b/.github/workflows/endtoend-tests.yaml @@ -19,9 +19,9 @@ name: Sample Network E2E Test on: push: - branches: [main] + branches: [v1.*] pull_request: - branches: [main] + branches: [v1.*] jobs: suite: diff --git a/.github/workflows/image-build-pr.yaml b/.github/workflows/image-build-pr.yaml index fa162491..47dd26b7 100644 --- a/.github/workflows/image-build-pr.yaml +++ b/.github/workflows/image-build-pr.yaml @@ -2,7 +2,7 @@ name: Build Operator image on: pull_request: - branches: [main] + branches: [v1.*] jobs: image: diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml index 8003a025..4041c5c2 100644 --- a/.github/workflows/image-build.yaml +++ b/.github/workflows/image-build.yaml @@ -2,7 +2,7 @@ name: Build Operator image on: push: - branches: [main] + branches: [v1.*] jobs: image: diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index e3713f74..a139e1b7 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -19,15 +19,15 @@ name: Integration Test on: push: - branches: [main] + branches: [v1.*] pull_request: - branches: [main] + branches: [v1.*] env: KUBECONFIG_PATH: /tmp/kubeconfig.yaml OPERATOR_NAMESPACE: inttest DOCKERCONFIGJSON: ${{ secrets.DOCKERCONFIGJSON }} - GO_VER: 1.18 + GO_VER: 1.20 jobs: suite: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..def4b773 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,91 @@ +name: Release Operator + +on: + pull_request: + branches: [v1.*] + push: + tags: [v1.*] + +env: + GO_VER: 1.20.6 + GO_TAGS: "" + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + SEMREV_LABEL: ${{ github.ref_name }} + +permissions: + contents: read + +jobs: + build-and-push-image: + runs-on: ubuntu-20.04 + + permissions: + contents: read + packages: write + + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + buildkitd-flags: --debug + config-inline: | + [worker.oci] + max-parallelism = 1 + + - name: Checkout + uses: actions/checkout@v3 + + - name: Login to the GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}}.{{minor}}.{{patch}} + + - name: Build and push + id: push + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + push: ${{ github.event_name != 'pull_request' }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GO_VER=${{ env.GO_VER }} + GO_TAGS=${{ env.GO_TAGS }} + BUILD_ID=${{ env.SEMREV_LABEL }} + BUILD_DATE=${{ env.BUILD_DATE }} + + + create-release: + name: Create GitHub Release + needs: [ build-and-push-image ] + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Release Operator Version + uses: ncipollo/release-action@v1 + with: + allowUpdates: "true" + bodyFile: release_notes/${{ env.SEMREV_LABEL }}.md + tag: ${{ env.SEMREV_LABEL }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 01420788..e5289be0 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -19,14 +19,13 @@ name: unit-tests on: - # TODO: uncomment this when moved to hyperledger-labs repo - # push: - # branches: [main] + push: + branches: [v1.*] pull_request: - branches: [main] + branches: [v1.*] env: - GO_VER: 1.18 + GO_VER: 1.20 jobs: make-checks: diff --git a/Makefile b/Makefile index 9418c969..b33f7751 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ IMAGE ?= ghcr.io/hyperledger-labs/fabric-operator TAG ?= $(shell git rev-parse --short HEAD) ARCH ?= $(shell go env GOARCH) -OSS_GO_VER ?= 1.20.3 +OSS_GO_VER ?= 1.20.6 BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") OS = $(shell go env GOOS)