tap-new: add --github-packages switch

This commit is contained in:
fn ⌃ ⌥ 2021-11-19 12:30:28 -08:00
parent 27a76295a4
commit 56724da0b7

View File

@ -24,6 +24,8 @@ module Homebrew
flag "--branch=", flag "--branch=",
description: "Initialize Git repository and setup GitHub Actions workflows with the " \ description: "Initialize Git repository and setup GitHub Actions workflows with the " \
"specified branch name (default: `main`)." "specified branch name (default: `main`)."
switch "--github-packages",
description: "Upload bottles to GitHub Packages."
named_args :tap, number: 1 named_args :tap, number: 1
end end
@ -43,6 +45,17 @@ module Homebrew
titleized_user[0] = titleized_user[0].upcase titleized_user[0] = titleized_user[0].upcase
titleized_repo[0] = titleized_repo[0].upcase titleized_repo[0] = titleized_repo[0].upcase
pr_pull_env = {}
pr_pull_env["HOMEBREW_GITHUB_API_TOKEN"] = "${{ github.token }}"
pr_pull_env["PULL_REQUEST"] = "${{ github.event.pull_request.number }}"
if args.github_packages?
pr_pull_env["HOMEBREW_GITHUB_PACKAGES_USER"] = "${{ github.actor }}"
pr_pull_env["HOMEBREW_GITHUB_PACKAGES_TOKEN"] = "${{ github.token }}"
root_url = GitHubPackages.root_url(tap.user, "homebrew-#{tap.repo}")
end
(tap.path/"Formula").mkpath (tap.path/"Formula").mkpath
readme = <<~MARKDOWN readme = <<~MARKDOWN
@ -96,7 +109,7 @@ module Homebrew
- run: brew test-bot --only-tap-syntax - run: brew test-bot --only-tap-syntax
- run: brew test-bot --only-formulae - run: brew test-bot --only-formulae#{" --root-url=#{root_url}" if root_url}
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
- name: Upload bottles as artifact - name: Upload bottles as artifact
@ -126,8 +139,7 @@ module Homebrew
- name: Pull bottles - name: Pull bottles
env: env:
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} #{pr_pull_env.map { |k, v| "#{k}: #{v}" }.join "\n#{" " * 10}"}
PULL_REQUEST: ${{ github.event.pull_request.number }}
run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST
- name: Push commits - name: Push commits