From 63d96fc642d8d7d58e70a902d1d926b42658e583 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 21:54:02 +0000 Subject: [PATCH 1/9] feat(release): automate updating homebrew tap formula --- .github/workflows/release.yaml | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 42d6a2f8620fc..3c6831762d507 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -328,11 +328,74 @@ jobs: event-type: coder-release client-payload: '{"coder_version": "${{ steps.version.outputs.version }}"}' + publish-homebrew: + name: Publish to Homebrew tap + runs-on: ubuntu-latest + needs: release + if: ${{ !inputs.dry_run }} + + steps: + # TODO: skip this if it's not a new release (i.e. not a backport). This is + # fine right now because it just makes a PR that we can close. + # TODO: delete the temp dir. Doesn't really matter right now since + # releases only happen a few times per month and the runners get + # cycled once a day anyways. + - name: Update homebrew + env: + # Variables used by the `gh` command + GH_REPO: coder/homebrew-coder + GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }} + run: | + # Keep version number around for reference, removing any potential leading v + CODER_VERSION="$(echo "${{ needs.release.outputs.version }}" | tr -d v)" + + set -euxo pipefail + + # Get the SHAs + darwin_arm_sha="$(sha256sum coder-cli-darwin-arm64.zip | awk '{ print $1 }')" + darwin_intel_sha="$(sha256sum coder-cli-darwin-amd64.zip | awk '{ print $1 }')" + linux_sha="$(sha256sum coder-cli-linux-amd64.tar.gz | awk '{ print $1 }')" + + # Setup Git + git config --global user.email "ci@coder.com" + git config --global user.name "Coder CI" + + # Check out the homebrew repo + temp_dir="$(mktemp -d)" + cd "$temp_dir" + git clone "git@github.com:$GH_REPO.git" homebrew-coder + cd homebrew-coder + + brew_branch="auto-release/$CODER_VERSION" + + # Check if a PR already exists. + pr_count="$(gh pr list --search "head:$brew_branch" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)" + if [[ "$pr_count" > 0 ]]; then + echo "Bailing out as PR already exists" 2>&1 + exit 0 + fi + + # Update the formulae and push + git checkout -b "$brew_branch" + ./scripts/update-v2.sh "$CODER_VERSION" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" + git add . + git commit -m "coder $CODER_VERSION" + git push -u origin -f "$brew_branch" + + # Create PR + gh pr create \ + -B master -H "$brew_branch" \ + -t "coder $CODER_VERSION" \ + -b "" \ + -r "${{ github.actor }}" \ + -a "${{ github.actor }}" + publish-winget: name: Publish to winget-pkgs runs-on: windows-latest needs: release if: ${{ !inputs.dry_run }} + steps: - name: Checkout uses: actions/checkout@v3 @@ -412,6 +475,7 @@ jobs: runs-on: windows-latest needs: release if: ${{ !inputs.dry_run }} + steps: - name: Checkout uses: actions/checkout@v3 From c3d8ff880e3a929c5f7b854dca76a8320ccc0812 Mon Sep 17 00:00:00 2001 From: Kayla Washburn Date: Wed, 30 Aug 2023 10:04:13 -0600 Subject: [PATCH 2/9] remove comment Co-authored-by: Dean Sheather --- .github/workflows/release.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3c6831762d507..3840de38ce859 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -337,9 +337,6 @@ jobs: steps: # TODO: skip this if it's not a new release (i.e. not a backport). This is # fine right now because it just makes a PR that we can close. - # TODO: delete the temp dir. Doesn't really matter right now since - # releases only happen a few times per month and the runners get - # cycled once a day anyways. - name: Update homebrew env: # Variables used by the `gh` command From 8bc1caba0e299e42d576f94d1dedc431f49b7593 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 16:49:23 +0000 Subject: [PATCH 3/9] try to test the release flow --- .github/workflows/release.yaml | 32 ++++--- .github/workflows/releases-test.yaml | 120 +++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/releases-test.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3840de38ce859..8ed9d773c8a51 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -335,7 +335,7 @@ jobs: if: ${{ !inputs.dry_run }} steps: - # TODO: skip this if it's not a new release (i.e. not a backport). This is + # TODO: skip this if it's not a new release (i.e. a backport). This is # fine right now because it just makes a PR that we can close. - name: Update homebrew env: @@ -344,27 +344,33 @@ jobs: GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }} run: | # Keep version number around for reference, removing any potential leading v - CODER_VERSION="$(echo "${{ needs.release.outputs.version }}" | tr -d v)" + coder_version="$(echo "${{ needs.release.outputs.version }}" | tr -d v)" set -euxo pipefail - # Get the SHAs - darwin_arm_sha="$(sha256sum coder-cli-darwin-arm64.zip | awk '{ print $1 }')" - darwin_intel_sha="$(sha256sum coder-cli-darwin-amd64.zip | awk '{ print $1 }')" - linux_sha="$(sha256sum coder-cli-linux-amd64.tar.gz | awk '{ print $1 }')" - # Setup Git git config --global user.email "ci@coder.com" git config --global user.name "Coder CI" - # Check out the homebrew repo temp_dir="$(mktemp -d)" cd "$temp_dir" + + # Download checksums + checksums_url="$(gh release view --repo coder/coder v2.1.4 --json assets \ + | jq -r ".assets | map(.url) | .[]" \ + | grep -e ".checksums.txt\$")" + wget "$checksums_url" -O checksums.txt + + # Get the SHAs + darwin_arm_sha="$(cat checksums.txt | grep "darwin_arm64.zip" | awk '{ print $1 }')" + darwin_intel_sha="$(cat checksums.txt | grep "darwin_amd64.zip" | awk '{ print $1 }')" + linux_sha="$(cat checksums.txt | grep "linux_amd64.tar.gz" | awk '{ print $1 }')" + + # Check out the homebrew repo git clone "git@github.com:$GH_REPO.git" homebrew-coder + brew_branch="auto-release/$coder_version" cd homebrew-coder - brew_branch="auto-release/$CODER_VERSION" - # Check if a PR already exists. pr_count="$(gh pr list --search "head:$brew_branch" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)" if [[ "$pr_count" > 0 ]]; then @@ -374,15 +380,15 @@ jobs: # Update the formulae and push git checkout -b "$brew_branch" - ./scripts/update-v2.sh "$CODER_VERSION" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" + ./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" git add . - git commit -m "coder $CODER_VERSION" + git commit -m "coder $coder_version" git push -u origin -f "$brew_branch" # Create PR gh pr create \ -B master -H "$brew_branch" \ - -t "coder $CODER_VERSION" \ + -t "coder $coder_version" \ -b "" \ -r "${{ github.actor }}" \ -a "${{ github.actor }}" diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml new file mode 100644 index 0000000000000..0be83e0a4e8cb --- /dev/null +++ b/.github/workflows/releases-test.yaml @@ -0,0 +1,120 @@ +# GitHub release workflow. +name: Release +on: + pull_request: + branches: ["**"] + +permissions: + # Required to publish a release + contents: write + # Necessary to push docker images to ghcr.io. + packages: write + # Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage) + id-token: write + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +env: + # Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual + # booleans, not strings. + # https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/ + CODER_RELEASE: ${{ !inputs.dry_run }} + CODER_DRY_RUN: ${{ inputs.dry_run }} + +jobs: + release: + name: Build and publish + runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} + env: + # Necessary for Docker manifest + DOCKER_CLI_EXPERIMENTAL: "enabled" + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # If the event that triggered the build was an annotated tag (which our + # tags are supposed to be), actions/checkout has a bug where the tag in + # question is only a lightweight tag and not a full annotated tag. This + # command seems to fix it. + # https://github.com/actions/checkout/issues/290 + - name: Fetch git tags + run: git fetch --tags --force + + - name: Print version + id: version + run: | + set -euo pipefail + version="$(./scripts/version.sh)" + echo "version=$version" >> $GITHUB_OUTPUT + # Speed up future version.sh calls. + echo "CODER_FORCE_VERSION=$version" >> $GITHUB_ENV + echo "$version" + + publish-homebrew: + name: Publish to Homebrew tap + runs-on: ubuntu-latest + needs: release + if: ${{ !inputs.dry_run }} + + steps: + # TODO: skip this if it's not a new release (i.e. a backport). This is + # fine right now because it just makes a PR that we can close. + - name: Update homebrew + env: + # Variables used by the `gh` command + GH_REPO: coder/homebrew-coder + GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }} + run: | + # Keep version number around for reference, removing any potential leading v + coder_version="$(echo "${{ needs.release.outputs.version }}" | tr -d v)" + + set -euxo pipefail + + # Setup Git + git config --global user.email "ci@coder.com" + git config --global user.name "Coder CI" + + temp_dir="$(mktemp -d)" + cd "$temp_dir" + + # Download checksums + checksums_url="$(gh release view --repo coder/coder v2.1.4 --json assets \ + | jq -r ".assets | map(.url) | .[]" \ + | grep -e ".checksums.txt\$")" + wget "$checksums_url" -O checksums.txt + + # Get the SHAs + darwin_arm_sha="$(cat checksums.txt | grep "darwin_arm64.zip" | awk '{ print $1 }')" + darwin_intel_sha="$(cat checksums.txt | grep "darwin_amd64.zip" | awk '{ print $1 }')" + linux_sha="$(cat checksums.txt | grep "linux_amd64.tar.gz" | awk '{ print $1 }')" + + # Check out the homebrew repo + git clone "git@github.com:$GH_REPO.git" homebrew-coder + brew_branch="auto-release/$coder_version" + cd homebrew-coder + + # Check if a PR already exists. + pr_count="$(gh pr list --search "head:$brew_branch" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)" + if [[ "$pr_count" > 0 ]]; then + echo "Bailing out as PR already exists" 2>&1 + exit 0 + fi + + # Update the formulae and push + git checkout -b "$brew_branch" + ./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" + git add . + git commit -m "coder $coder_version" + git push -u origin -f "$brew_branch" + + # Create PR + gh pr create \ + -B master -H "$brew_branch" \ + -t "coder $coder_version" \ + -b "" \ + -r "${{ github.actor }}" \ + -a "${{ github.actor }}" From cff44cb7adcdb45c120afaa2d9c8113a76eb1f83 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 16:53:42 +0000 Subject: [PATCH 4/9] pin test --- .github/workflows/releases-test.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml index 0be83e0a4e8cb..dff4642b61499 100644 --- a/.github/workflows/releases-test.yaml +++ b/.github/workflows/releases-test.yaml @@ -48,11 +48,10 @@ jobs: id: version run: | set -euo pipefail - version="$(./scripts/version.sh)" - echo "version=$version" >> $GITHUB_OUTPUT + echo "version=2.1.4" >> $GITHUB_OUTPUT # Speed up future version.sh calls. - echo "CODER_FORCE_VERSION=$version" >> $GITHUB_ENV - echo "$version" + echo "CODER_FORCE_VERSION=2.1.4" >> $GITHUB_ENV + echo "2.1.4" publish-homebrew: name: Publish to Homebrew tap From 542f3196d1e80942b28be369e0ffe245862e35d1 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 17:04:23 +0000 Subject: [PATCH 5/9] use https, inspect sha --- .github/workflows/release.yaml | 6 +++++- .github/workflows/releases-test.yaml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8ed9d773c8a51..a2b7278561dc9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -366,8 +366,12 @@ jobs: darwin_intel_sha="$(cat checksums.txt | grep "darwin_amd64.zip" | awk '{ print $1 }')" linux_sha="$(cat checksums.txt | grep "linux_amd64.tar.gz" | awk '{ print $1 }')" + echo "macOS arm64: $darwin_arm_sha" + echo "macOS amd64: $darwin_intel_sha" + echo "Linux amd64: $linux_sha" + # Check out the homebrew repo - git clone "git@github.com:$GH_REPO.git" homebrew-coder + git clone "https://github.com/$GH_REPO" homebrew-coder brew_branch="auto-release/$coder_version" cd homebrew-coder diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml index dff4642b61499..6ae8d1ab06e67 100644 --- a/.github/workflows/releases-test.yaml +++ b/.github/workflows/releases-test.yaml @@ -91,8 +91,12 @@ jobs: darwin_intel_sha="$(cat checksums.txt | grep "darwin_amd64.zip" | awk '{ print $1 }')" linux_sha="$(cat checksums.txt | grep "linux_amd64.tar.gz" | awk '{ print $1 }')" + echo "macOS arm64: $darwin_arm_sha" + echo "macOS amd64: $darwin_intel_sha" + echo "Linux amd64: $linux_sha" + # Check out the homebrew repo - git clone "git@github.com:$GH_REPO.git" homebrew-coder + git clone "https://github.com/$GH_REPO" homebrew-coder brew_branch="auto-release/$coder_version" cd homebrew-coder From 6e24a9149ec21be84b4643a5a701fc77a7fd6a79 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 17:07:48 +0000 Subject: [PATCH 6/9] older version that will actually have a diff --- .github/workflows/releases-test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml index 6ae8d1ab06e67..5d241c07b6d65 100644 --- a/.github/workflows/releases-test.yaml +++ b/.github/workflows/releases-test.yaml @@ -48,10 +48,10 @@ jobs: id: version run: | set -euo pipefail - echo "version=2.1.4" >> $GITHUB_OUTPUT + echo "version=2.1.3" >> $GITHUB_OUTPUT # Speed up future version.sh calls. - echo "CODER_FORCE_VERSION=2.1.4" >> $GITHUB_ENV - echo "2.1.4" + echo "CODER_FORCE_VERSION=2.1.3" >> $GITHUB_ENV + echo "2.1.3" publish-homebrew: name: Publish to Homebrew tap From 35c462342e5723ba123c1fbf8fe1de0f4e63be07 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 17:19:22 +0000 Subject: [PATCH 7/9] set up git r/w --- .github/workflows/release.yaml | 2 ++ .github/workflows/releases-test.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a2b7278561dc9..3a85ead9e81b9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -382,6 +382,8 @@ jobs: exit 0 fi + # Set up cdrci credentials for pushing to homebrew-coder + echo "https://x-access-token:$GH_TOKEN@github.com" >> ~/.git-credentials # Update the formulae and push git checkout -b "$brew_branch" ./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml index 5d241c07b6d65..9e73148d80bf7 100644 --- a/.github/workflows/releases-test.yaml +++ b/.github/workflows/releases-test.yaml @@ -107,6 +107,8 @@ jobs: exit 0 fi + # Set up cdrci credentials for pushing to homebrew-coder + echo "https://x-access-token:$GH_TOKEN@github.com" >> ~/.git-credentials # Update the formulae and push git checkout -b "$brew_branch" ./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" From 131c57ec5a804c3323f3f77cc7ea25042e3b0672 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 17:22:14 +0000 Subject: [PATCH 8/9] store --- .github/workflows/release.yaml | 1 + .github/workflows/releases-test.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3a85ead9e81b9..44f3bd1e2656b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -351,6 +351,7 @@ jobs: # Setup Git git config --global user.email "ci@coder.com" git config --global user.name "Coder CI" + git config --global credential.helper "store" temp_dir="$(mktemp -d)" cd "$temp_dir" diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml index 9e73148d80bf7..cafc576894f18 100644 --- a/.github/workflows/releases-test.yaml +++ b/.github/workflows/releases-test.yaml @@ -76,6 +76,7 @@ jobs: # Setup Git git config --global user.email "ci@coder.com" git config --global user.name "Coder CI" + git config --global credential.helper "store" temp_dir="$(mktemp -d)" cd "$temp_dir" From 01cd4ce0f7ae41a7d23a87fce07fc080aa879ef2 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 30 Aug 2023 17:26:46 +0000 Subject: [PATCH 9/9] it works! --- .github/workflows/release.yaml | 3 +- .github/workflows/releases-test.yaml | 126 --------------------------- 2 files changed, 2 insertions(+), 127 deletions(-) delete mode 100644 .github/workflows/releases-test.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 44f3bd1e2656b..514b8dda4f2cc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -398,7 +398,8 @@ jobs: -t "coder $coder_version" \ -b "" \ -r "${{ github.actor }}" \ - -a "${{ github.actor }}" + -a "${{ github.actor }}" \ + -b "This automatic PR was triggered by the release of Coder v$coder_version" publish-winget: name: Publish to winget-pkgs diff --git a/.github/workflows/releases-test.yaml b/.github/workflows/releases-test.yaml deleted file mode 100644 index cafc576894f18..0000000000000 --- a/.github/workflows/releases-test.yaml +++ /dev/null @@ -1,126 +0,0 @@ -# GitHub release workflow. -name: Release -on: - pull_request: - branches: ["**"] - -permissions: - # Required to publish a release - contents: write - # Necessary to push docker images to ghcr.io. - packages: write - # Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage) - id-token: write - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -env: - # Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual - # booleans, not strings. - # https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/ - CODER_RELEASE: ${{ !inputs.dry_run }} - CODER_DRY_RUN: ${{ inputs.dry_run }} - -jobs: - release: - name: Build and publish - runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} - env: - # Necessary for Docker manifest - DOCKER_CLI_EXPERIMENTAL: "enabled" - outputs: - version: ${{ steps.version.outputs.version }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - # If the event that triggered the build was an annotated tag (which our - # tags are supposed to be), actions/checkout has a bug where the tag in - # question is only a lightweight tag and not a full annotated tag. This - # command seems to fix it. - # https://github.com/actions/checkout/issues/290 - - name: Fetch git tags - run: git fetch --tags --force - - - name: Print version - id: version - run: | - set -euo pipefail - echo "version=2.1.3" >> $GITHUB_OUTPUT - # Speed up future version.sh calls. - echo "CODER_FORCE_VERSION=2.1.3" >> $GITHUB_ENV - echo "2.1.3" - - publish-homebrew: - name: Publish to Homebrew tap - runs-on: ubuntu-latest - needs: release - if: ${{ !inputs.dry_run }} - - steps: - # TODO: skip this if it's not a new release (i.e. a backport). This is - # fine right now because it just makes a PR that we can close. - - name: Update homebrew - env: - # Variables used by the `gh` command - GH_REPO: coder/homebrew-coder - GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }} - run: | - # Keep version number around for reference, removing any potential leading v - coder_version="$(echo "${{ needs.release.outputs.version }}" | tr -d v)" - - set -euxo pipefail - - # Setup Git - git config --global user.email "ci@coder.com" - git config --global user.name "Coder CI" - git config --global credential.helper "store" - - temp_dir="$(mktemp -d)" - cd "$temp_dir" - - # Download checksums - checksums_url="$(gh release view --repo coder/coder v2.1.4 --json assets \ - | jq -r ".assets | map(.url) | .[]" \ - | grep -e ".checksums.txt\$")" - wget "$checksums_url" -O checksums.txt - - # Get the SHAs - darwin_arm_sha="$(cat checksums.txt | grep "darwin_arm64.zip" | awk '{ print $1 }')" - darwin_intel_sha="$(cat checksums.txt | grep "darwin_amd64.zip" | awk '{ print $1 }')" - linux_sha="$(cat checksums.txt | grep "linux_amd64.tar.gz" | awk '{ print $1 }')" - - echo "macOS arm64: $darwin_arm_sha" - echo "macOS amd64: $darwin_intel_sha" - echo "Linux amd64: $linux_sha" - - # Check out the homebrew repo - git clone "https://github.com/$GH_REPO" homebrew-coder - brew_branch="auto-release/$coder_version" - cd homebrew-coder - - # Check if a PR already exists. - pr_count="$(gh pr list --search "head:$brew_branch" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)" - if [[ "$pr_count" > 0 ]]; then - echo "Bailing out as PR already exists" 2>&1 - exit 0 - fi - - # Set up cdrci credentials for pushing to homebrew-coder - echo "https://x-access-token:$GH_TOKEN@github.com" >> ~/.git-credentials - # Update the formulae and push - git checkout -b "$brew_branch" - ./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha" - git add . - git commit -m "coder $coder_version" - git push -u origin -f "$brew_branch" - - # Create PR - gh pr create \ - -B master -H "$brew_branch" \ - -t "coder $coder_version" \ - -b "" \ - -r "${{ github.actor }}" \ - -a "${{ github.actor }}"