Skip to content
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

tap-new: enable bottles publishing #8762

Merged
merged 1 commit into from
Oct 3, 2020
Merged

Conversation

dawidd6
Copy link
Contributor

@dawidd6 dawidd6 commented Sep 18, 2020

We now support bottles publishing to GitHub Releases.
Add a workflow for that and modify tests.yml a bit, so users can have bottles in their taps too and be happier.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Sorry, something went wrong.

@dawidd6 dawidd6 requested a review from MikeMcQuaid September 18, 2020 11:08
@dawidd6
Copy link
Contributor Author

dawidd6 commented Sep 18, 2020

Also, is it intentional we don't do git init in new tap directory?

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is SO COOL 😍

@chdiza
Copy link
Contributor

chdiza commented Sep 19, 2020

Also, is it intentional we don't do git init in new tap directory?

Taps don't have to be git repos.


- name: Pull bottles
env:
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the default GITHUB_TOKEN here? Means less setup for tap maintainers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least something clever like using it unless it's a PR from a fork?

token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}

- name: Delete branch
uses: peter-evans/close-pull@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if this was something in the Homebrew org.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably simple enough for https://github.com/actions/github-script.

Comment on lines 143 to 147
When a pull request making changes to a formula (or formulae) becomes green
(all checks passed), then you can publish the built bottles.
To do so, run:
brew pr-publish --tap=#{tap} <pull_request_number>
or trigger the workflow via GitHub UI in Actions tab.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this text ought to go in the README, rather than a one-time thing that's printed to the terminal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea or, better still, be something that's linked to in our documentation so we can update it.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻


- name: Pull bottles
env:
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least something clever like using it unless it's a PR from a fork?

token: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}

- name: Delete branch
uses: peter-evans/close-pull@v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Comment on lines 143 to 147
When a pull request making changes to a formula (or formulae) becomes green
(all checks passed), then you can publish the built bottles.
To do so, run:
brew pr-publish --tap=#{tap} <pull_request_number>
or trigger the workflow via GitHub UI in Actions tab.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea or, better still, be something that's linked to in our documentation so we can update it.

@MikeMcQuaid
Copy link
Member

Also, is it intentional we don't do git init in new tap directory?

Taps don't have to be git repos.

This is true but I think, by default at least, brew tap-new should setup a git repository given we're adding files that should be committed and pushed to GitHub.

uses: actions/cache@v1
with:
path: ${{ steps.set-up-homebrew.outputs.gems-path }}
key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
restore-keys: ${{ runner.os }}-rubygems-

- name: Install Homebrew Bundler RubyGems
if: steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does something like this (👇 ) achieve the desired behavior?

Suggested change
run: brew install-bundler-gems
if: github.repository_owner == 'Homebrew' || steps.cache.outputs.cache-hit != 'true'
run: brew install-bundler-gems

@dawidd6 dawidd6 force-pushed the tap-new-gh-rel branch 3 times, most recently from 4cf6d15 to daabae9 Compare October 2, 2020 11:18
@dawidd6
Copy link
Contributor Author

dawidd6 commented Oct 2, 2020

Changes since almost 2 weeks:

  • added --no-git option
  • initialize the git repo in tap directory by default
  • skip installing bundler gems step if cache hit
  • trigger publish workflow on pull request ok label
  • delete branch via git push if the pull request is not from forked repo
  • shorter notice after tap creation

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very minor suggestions here but I'm happy for this to ship whenever you're happy with it and it's tested. Great work @dawidd6!

- labeled
jobs:
pr-pull:
if: contains(github.event.pull_request.labels.*.name, 'ok')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: contains(github.event.pull_request.labels.*.name, 'ok')
if: contains(github.event.pull_request.labels.*.name, 'homebrew-publish-bottles')

or something? I'm pretty open to anything but something more descriptive and/or homebrew-specific might be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imma name it as pr-pull by default, it matches the workflow name and is short enough.


When a pull request making changes to a formula (or formulae) becomes green
(all checks passed), then you can publish the built bottles.
To do so, label your PR as 'ok' and the workflow will be triggered.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To do so, label your PR as 'ok' and the workflow will be triggered.
To do so, label your PR as #{label} and the workflow will be triggered.

and could share the variable above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better, it could be an option with default value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh, good idea 👍🏻

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, for a counterpoint: I tend to think it's not worth adding options until someone requests them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I request it 😄

@dawidd6
Copy link
Contributor Author

dawidd6 commented Oct 2, 2020

I encountered this error, while testing the publishing workflow:

Error: undefined method `split' for nil:NilClass
Please report this issue:
  https://docs.brew.sh/Troubleshooting
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:385:in `block in pr_pull'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:378:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:378:in `pr_pull'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'
Error: Process completed with exit code 1.

04687ae#r42912894

@dawidd6
Copy link
Contributor Author

dawidd6 commented Oct 3, 2020

It's working:
https://github.com/dawidd6/homebrew-test-tap-new/pull/1

@dawidd6 dawidd6 merged commit 9ec618f into Homebrew:master Oct 3, 2020
@dawidd6 dawidd6 deleted the tap-new-gh-rel branch October 3, 2020 17:18
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 3, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants