From 25dea934f12bbd07d6d892b0e56c1952d1a8a763 Mon Sep 17 00:00:00 2001 From: Puskar Basu <45908484+pskrbasu@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:07:02 +0530 Subject: [PATCH] Split out docker and brew publish workflows (#4120) --- .github/workflows/publish_docker.yml | 40 +------- .github/workflows/publish_docker_and_brew.yml | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/publish_docker_and_brew.yml diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml index 81a49630d..1bd2a0e22 100644 --- a/.github/workflows/publish_docker.yml +++ b/.github/workflows/publish_docker.yml @@ -1,4 +1,4 @@ -name: Publish Docker Release and Update Brew +name: Publish Docker Release on: workflow_dispatch: inputs: @@ -59,41 +59,3 @@ jobs: - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} - - update_homebrew_tap: - name: Update homebrew-tap formula - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - repository: turbot/homebrew-tap - token: ${{ secrets.GH_ACCESS_TOKEN }} - ref: main - - - name: Get pull request title - id: pr_title - run: >- - echo "PR_TITLE=$( - gh pr view $STEAMPIPE_VERSION --json title | jq .title | tr -d '"' - )" >> $GITHUB_OUTPUT - - - name: Output - run: | - echo ${{ steps.pr_title.outputs.PR_TITLE }} - echo ${{ env.STEAMPIPE_VERSION }} - - - name: Fail if PR title does not match with version - run: | - if ${{ (steps.pr_title.outputs.PR_TITLE == env.STEAMPIPE_VERSION) }} == 'true';then - echo "Correct version" - else - echo "Incorrect version" - exit 1 - fi - - - name: Merge pull request to update brew formula - run: | - git fetch --all - gh pr merge $STEAMPIPE_VERSION --squash --delete-branch - git push origin --delete bump-brew diff --git a/.github/workflows/publish_docker_and_brew.yml b/.github/workflows/publish_docker_and_brew.yml new file mode 100644 index 000000000..81a49630d --- /dev/null +++ b/.github/workflows/publish_docker_and_brew.yml @@ -0,0 +1,99 @@ +name: Publish Docker Release and Update Brew +on: + workflow_dispatch: + inputs: + release: + description: "The name of the released version to publish" + required: true + +env: + STEAMPIPE_VERSION: ${{ github.event.inputs.release }} + GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} + GH_PUBLISH_ACCESS_TOKEN: ${{ secrets.GH_PUBLISH_ACCESS_TOKEN }} + +jobs: + publish_docker: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # TODO: v0.21.x will be the last version we publish our images to Docker Hub. Update Docker + # publish workflow to stop publishing to Docker Hub just before v0.22.0 comes out. + # https://github.com/turbot/steampipe/issues/3327 + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_PUBLISH_ACCESS_TOKEN }} + + - name: Clean Version for Tag + id: generate_docker_tag + run: | + echo "docker_tag=${STEAMPIPE_VERSION#"v"}" >> $GITHUB_OUTPUT + + - name: Build and Push to DockerHub and Container Registry + id: docker_build + uses: docker/build-push-action@v5 + with: + push: true + platforms: linux/amd64,linux/arm64 + build-args: | + TARGETVERSION=${{ env.STEAMPIPE_VERSION }} + tags: | + turbot/steampipe:${{ steps.generate_docker_tag.outputs.docker_tag }} + turbot/steampipe:latest + ghcr.io/turbot/steampipe:${{ steps.generate_docker_tag.outputs.docker_tag }} + ghcr.io/turbot/steampipe:latest + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + update_homebrew_tap: + name: Update homebrew-tap formula + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: turbot/homebrew-tap + token: ${{ secrets.GH_ACCESS_TOKEN }} + ref: main + + - name: Get pull request title + id: pr_title + run: >- + echo "PR_TITLE=$( + gh pr view $STEAMPIPE_VERSION --json title | jq .title | tr -d '"' + )" >> $GITHUB_OUTPUT + + - name: Output + run: | + echo ${{ steps.pr_title.outputs.PR_TITLE }} + echo ${{ env.STEAMPIPE_VERSION }} + + - name: Fail if PR title does not match with version + run: | + if ${{ (steps.pr_title.outputs.PR_TITLE == env.STEAMPIPE_VERSION) }} == 'true';then + echo "Correct version" + else + echo "Incorrect version" + exit 1 + fi + + - name: Merge pull request to update brew formula + run: | + git fetch --all + gh pr merge $STEAMPIPE_VERSION --squash --delete-branch + git push origin --delete bump-brew