diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 928c69c7..77f7394a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -238,84 +238,3 @@ jobs: - name: Deploying locally built provider package run: make local-deploy - - publish-artifacts: - runs-on: ubuntu-22.04 - needs: - - detect-noop - - report-breaking-changes - - lint - - check-diff - - unit-tests - - local-deploy - if: needs.detect-noop.outputs.noop != 'true' - - steps: - - name: Setup QEMU - uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2 - with: - platforms: all - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 - with: - version: ${{ env.DOCKER_BUILDX_VERSION }} - install: true - - - name: Login to Upbound - uses: docker/login-action@v2 - 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 }} - - - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3 - with: - submodules: true - - - name: Fetch History - run: git fetch --prune --unshallow - - - name: Setup Go - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3 - 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@v3 - 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@v3 - 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: Build Artifacts - run: make -j2 build.all - 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: Upload Artifacts to GitHub - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 #v3 - with: - name: output - path: _output/** - - - name: Publish Artifacts - run: make publish BRANCH_NAME=${GITHUB_REF##*/} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..547f5664 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,105 @@ +name: Release + +on: + push: + branches: + - main + +env: + # Common versions + GO_VERSION: '1.20' + GOLANGCI_VERSION: 'v1.52.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 }} + +jobs: + publish-artifacts: + name: Publish Artifacts + runs-on: ubuntu-22.04 + needs: release_please + if: ${{ needs.release_please.outputs.release_created == 'true' }} + + steps: + - 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: Login to Upbound + uses: docker/login-action@v1 + 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 }} + + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Fetch History + run: git fetch --prune --unshallow + + - 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: Build Artifacts + run: make -j2 build.all + 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: Upload Artifacts to GitHub + uses: actions/upload-artifact@v2 + with: + name: output + path: _output/** + + - name: Publish Artifacts + run: | + make up.login + make publish BRANCH_NAME=${GITHUB_REF##*/} + env: + UP_ACCOUNT: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} + UP_TOKEN: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} + + - name: Update docs.crds.dev + continue-on-error: true + run: | + export VERSION_TAG=$GITHUB_REF_NAME + curl -s -X GET "https://doc.crds.dev/github.com/huaweicloud/provider-huaweicloud@${VERSION_TAG}" diff --git a/Makefile b/Makefile index e8448db5..21850cc7 100644 --- a/Makefile +++ b/Makefile @@ -222,6 +222,15 @@ schema-version-diff: .PHONY: cobertura submodules fallthrough run crds.clean +# ==================================================================================== +# UP Login +up.login: + @$(INFO) logging into up + @$(UP) login + @$(OK) logging into up + +# ==================================================================================== + # ==================================================================================== # Special Targets