mirror of https://github.com/coder/coder.git
feat: automate updating homebrew tap formula (#9412)
This commit is contained in:
parent
c6f4f0f8ad
commit
9c9d035354
|
@ -328,11 +328,85 @@ 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. 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 }}" \
|
||||
-b "This automatic PR was triggered by the release of Coder v$coder_version"
|
||||
|
||||
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 +486,7 @@ jobs:
|
|||
runs-on: windows-latest
|
||||
needs: release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
|
Loading…
Reference in New Issue