From 59ea74b15d49283482b64030af922b194ed44a91 Mon Sep 17 00:00:00 2001 From: Catalin Date: Tue, 23 Jul 2024 17:51:33 +0300 Subject: [PATCH] fix CI publish-artifacts action and release based on tags --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yaml | 86 ---------------------------------- .github/workflows/tag.yml | 81 ++++++++++++++++++++++++++++++-- 3 files changed, 78 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87bebb2..77dd4f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -231,7 +231,7 @@ jobs: run: make vendor vendor.check - name: Build Artifacts - run: make -j2 build.all + run: make -j2 -i build.all env: # We're using docker buildx, which doesn't actually load the images it # builds by default. Specifying --load does so. diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 70b3b40..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,86 +0,0 @@ -name: Release builds - -on: - push: - tags: - - '*' - -jobs: - build-and-pack: - name: Build and pack - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - name: CR authentication - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.ACCESS_TOKEN }} - - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@github.com" - - - name: Set VERSION env - run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV - - - name: Setup QEMU - uses: docker/setup-qemu-action@v1 - with: - platforms: all - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v1 - with: - version: ${{ env.DOCKER_BUILDX_VERSION }} - install: true - - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Find the Go Build Cache - id: go - run: echo "::set-output name=cache::$(make go.cachedir)" - - - name: Cache the Go Build Cache - 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@v2 - 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: Get make submodules - run: make submodules - - - name: Process swagger.json - run: make process.scheme - - - name: Install crossplane CLI - id: crossplane - run: curl -sL "https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh" | sh - - - name: Build provider image - run: docker build -t ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} ./cluster - - - name: Build and push crossplane packages - run: ./crossplane xpkg build -f package -o provider-magento --embed-runtime-image ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} && ./crossplane xpkg push -f provider-magento ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} || true || true; \ No newline at end of file diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 24c5cb1..ab0cd6a 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -1,4 +1,4 @@ -name: Tag +name: Tag release on: workflow_dispatch: @@ -11,9 +11,10 @@ on: required: true jobs: - create-tag: + create-tag-build-and-pack: runs-on: ubuntu-22.04 - + permissions: + contents: write steps: - name: Checkout uses: actions/checkout@v2 @@ -23,4 +24,76 @@ jobs: with: version: ${{ github.event.inputs.version }} message: ${{ github.event.inputs.message }} - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} + + - name: CR authentication + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.ACCESS_TOKEN }} + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@github.com" + + - name: Set VERSION env + run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + + - name: Setup QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + version: ${{ env.DOCKER_BUILDX_VERSION }} + install: true + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Find the Go Build Cache + id: go + run: echo "::set-output name=cache::$(make go.cachedir)" + + - name: Cache the Go Build Cache + 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@v2 + 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: Get make submodules + run: make submodules + + - name: Process swagger.json + run: make process.scheme + + - name: Install crossplane CLI + id: crossplane + run: curl -sL "https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh" | sh + + - name: Build provider image + run: docker build -t ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} ./cluster + + - name: Build and push crossplane packages + run: ./crossplane xpkg build -f package -o provider-magento --embed-runtime-image ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} && ./crossplane xpkg push -f provider-magento ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }}; \ No newline at end of file