-
Notifications
You must be signed in to change notification settings - Fork 940
feat: automate updating homebrew tap formula #9412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
63d96fc
feat(release): automate updating homebrew tap formula
aslilac c3d8ff8
remove comment
aslilac 173edb8
Merge branch 'main' into auto-homebrew
aslilac 8bc1cab
try to test the release flow
aslilac cff44cb
pin test
aslilac 542f319
use https, inspect sha
aslilac 6e24a91
older version that will actually have a diff
aslilac 35c4623
set up git r/w
aslilac 131c57e
store
aslilac 01cd4ce
it works!
aslilac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} | ||
aslilac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 "[email protected]" | ||
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:[email protected]" >> ~/.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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.