Skip to content

Commit 20ea35f

Browse files
fix(release_homebrew): fix empty outputs when validate is false (#97)
1 parent 4586d79 commit 20ea35f

3 files changed

Lines changed: 49 additions & 33 deletions

File tree

actions/release_homebrew/action.yml

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -176,30 +176,33 @@ runs:
176176
run: |
177177
"${{ steps.venv.outputs.python-path }}" -u main.py
178178
179-
- name: GitHub Commit & Push (org homebrew repo)
179+
- name: GitHub Push (org homebrew repo)
180180
if: ${{ inputs.publish == 'true' }}
181-
uses: actions-js/[email protected]
182-
with:
183-
author_email: ${{ inputs.git_email }}
184-
author_name: ${{ inputs.git_username }}
185-
branch: ${{ steps.homebrew-tests.outputs.org_homebrew_repo_branch }}
186-
directory: ${{ github.workspace }}/release_homebrew_action/org_homebrew_repo
187-
github_token: ${{ inputs.token }}
188-
message: "chore: ${{ steps.homebrew-tests.outputs.commit_message }}"
189-
repository: ${{ inputs.org_homebrew_repo }}
181+
env:
182+
GH_TOKEN: ${{ inputs.token }}
183+
ORG_HOMEBREW_REPO_BRANCH: ${{ steps.homebrew-tests.outputs.org_homebrew_repo_branch }}
184+
INPUT_ORG_HOMEBREW_REPO: ${{ inputs.org_homebrew_repo }}
185+
shell: bash
186+
working-directory: ${{ github.workspace }}/release_homebrew_action/org_homebrew_repo
187+
run: |
188+
# Push the branch to remote
189+
git push https://x-access-token:${GH_TOKEN}@github.com/${INPUT_ORG_HOMEBREW_REPO}.git \
190+
${ORG_HOMEBREW_REPO_BRANCH}:${ORG_HOMEBREW_REPO_BRANCH} \
191+
--force
190192
191-
- name: GitHub Commit & Push (homebrew-core)
193+
- name: GitHub Push (homebrew-core)
192194
if: ${{ inputs.contribute_to_homebrew_core == 'true' && inputs.publish == 'true' }}
193-
uses: actions-js/[email protected]
194-
with:
195-
author_email: ${{ inputs.git_email }}
196-
author_name: ${{ inputs.git_username }}
197-
branch: ${{ steps.homebrew-tests.outputs.homebrew_core_branch }}
198-
directory: ${{ github.workspace }}/release_homebrew_action/homebrew_core_fork_repo
199-
force: true # need to force since the branch is sometimes reset
200-
github_token: ${{ inputs.token }}
201-
message: "${{ steps.homebrew-tests.outputs.commit_message }}"
202-
repository: ${{ inputs.homebrew_core_fork_repo }}
195+
env:
196+
GH_TOKEN: ${{ inputs.token }}
197+
HOMEBREW_CORE_BRANCH: ${{ steps.homebrew-tests.outputs.homebrew_core_branch }}
198+
HOMEBREW_CORE_FORK_REPO: ${{ inputs.homebrew_core_fork_repo }}
199+
shell: bash
200+
working-directory: ${{ github.workspace }}/release_homebrew_action/homebrew_core_fork_repo
201+
run: |
202+
# Push the branch to remote
203+
git push https://x-access-token:${GH_TOKEN}@github.com/${HOMEBREW_CORE_FORK_REPO}.git \
204+
${HOMEBREW_CORE_BRANCH}:${HOMEBREW_CORE_BRANCH} \
205+
--force
203206
204207
- name: Create Pull Request (org homebrew repo)
205208
env:
@@ -217,21 +220,21 @@ runs:
217220
218221
# Check if a pull request already exists with the same head branch
219222
PR_EXISTS=$(gh pr list \
220-
--head ${ORG_HOMEBREW_REPO_BRANCH} \
221-
--repo ${INPUT_ORG_HOMEBREW_REPO})
223+
--head "${ORG_HOMEBREW_REPO_BRANCH}" \
224+
--repo "${INPUT_ORG_HOMEBREW_REPO}")
222225
223226
# If the pull request does not exist, create it
224227
if [[ -z "$PR_EXISTS" ]]; then
225228
echo "Creating pull request"
226229
227230
# https://cli.github.com/manual/gh_pr_create
228231
gh pr create \
229-
--base ${BASE_BRANCH} \
230-
--head ${ORG_HOMEBREW_REPO_BRANCH} \
232+
--base "${BASE_BRANCH}" \
233+
--head "${ORG_HOMEBREW_REPO_BRANCH}" \
231234
--title "chore: ${COMMIT_MESSAGE}" \
232235
--body \
233236
"Created by the LizardByte [release_homebrew](https://github.com/LizardByte/actions) action" \
234-
--repo ${INPUT_ORG_HOMEBREW_REPO}
237+
--repo "${INPUT_ORG_HOMEBREW_REPO}"
235238
else
236239
echo "Pull request already exists"
237240
fi
@@ -257,8 +260,8 @@ runs:
257260
# Check if a pull request already exists from fork to upstream
258261
# We check in the upstream repo for PRs from our fork
259262
PR_EXISTS=$(gh pr list \
260-
--head ${FORK_OWNER}:${HOMEBREW_CORE_BRANCH} \
261-
--repo ${INPUT_UPSTREAM_HOMEBREW_CORE_REPO})
263+
--head "${FORK_OWNER}:${HOMEBREW_CORE_BRANCH}" \
264+
--repo "${INPUT_UPSTREAM_HOMEBREW_CORE_REPO}")
262265
263266
# If the pull request does not exist, create it
264267
if [[ -z "$PR_EXISTS" ]]; then
@@ -268,9 +271,9 @@ runs:
268271
# Note: we're in the fork's working directory, so gh will use the fork's context
269272
# https://cli.github.com/manual/gh_pr_create
270273
gh pr create \
271-
--repo ${INPUT_UPSTREAM_HOMEBREW_CORE_REPO} \
272-
--base ${BASE_BRANCH} \
273-
--head ${FORK_OWNER}:${HOMEBREW_CORE_BRANCH} \
274+
--repo "${INPUT_UPSTREAM_HOMEBREW_CORE_REPO}" \
275+
--base "${BASE_BRANCH}" \
276+
--head "${FORK_OWNER}:${HOMEBREW_CORE_BRANCH}" \
274277
--title "${COMMIT_MESSAGE}" \
275278
--body "Created by the LizardByte [release_homebrew](https://github.com/LizardByte/actions) action"
276279
else

actions/release_homebrew/ci-matrix.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,17 @@
2626
"token": "${ secrets.GH_BOT_TOKEN }",
2727
"upstream_homebrew_core_repo": "LizardByte/homebrew-core"
2828
}
29+
},
30+
{
31+
"runs-on": "ubuntu-latest",
32+
"with": {
33+
"contribute_to_homebrew_core": false,
34+
"formula_file": "${ github.workspace }/tests/release_homebrew/Formula/hello_world.rb",
35+
"git_email": "${ secrets.GH_BOT_EMAIL }",
36+
"git_username": "${ secrets.GH_BOT_NAME }",
37+
"publish": true,
38+
"token": "${ secrets.GH_BOT_TOKEN }",
39+
"validate": false
40+
}
2941
}
3042
]

actions/release_homebrew/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,9 @@ def main():
932932
if not is_brew_installed():
933933
raise SystemExit(1, 'Homebrew is not installed')
934934

935+
# Always process the formula to set up branches and copy files, even if validation is skipped
936+
formula = process_input_formula(args.formula_file)
937+
935938
if os.environ['INPUT_VALIDATE'].lower() != 'true':
936939
print('Skipping audit, install, and test')
937940
return
@@ -941,8 +944,6 @@ def main():
941944
print('::error:: Homebrew update or upgrade failed')
942945
raise SystemExit(1)
943946

944-
formula = process_input_formula(args.formula_file)
945-
946947
if not brew_test_bot_only_cleanup_before():
947948
print('::error:: brew test-bot --only-cleanup-before failed')
948949
raise SystemExit(1)

0 commit comments

Comments
 (0)