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

Automates brew formula version bump for new release #687

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

carmal891
Copy link
Contributor

Automates the process of updating the Brew formula version in the tap repository (ppc64le-cloud/homebrew-pvsadm) for each platform-dependent formula (linux_amd64, darwin_arm64, darwin_amd64) to reflect the latest release version upon new releases in this repository.

This PR addresses issue #667 and resumes the changes from #675, which was previously put on hold due to the limitations of the proposed solutions utilizing GitHub Actions:

dawidd6/action-homebrew-bump-formula
mislav/bump-homebrew-formula-action

Above actions are unable to correctly parse and update a nested/custom formula file as maintained in ppc64le-cloud/homebrew-pvsadm. Additionally, the approach of maintaining three separate formulas did not work out for the reasons outlined here: ppc64le-cloud/homebrew-pvsadm#6

As discussed, alternate solution uses a custom Bash script to update the formula file. The script has been thoroughly tested against a personal forked repository.

NOTE:
It requires additional token to create PR using GH cli in the name GH_TOKEN. Required scopes include read:org, repo, workflow, write:packages

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 20, 2024
@carmal891
Copy link
Contributor Author

Depends on ppc64le-cloud/homebrew-pvsadm#7

GH_TOKEN: ${{ secrets.GH_TOKEN}}
run: |
cd ci/
chmod +x brew_formula_updater.sh
Copy link
Member

Choose a reason for hiding this comment

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

can you change the permission while pushing this file itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +167 to +166
git config --global user.name "pvsadm GitHub Actions"
git config --global user.email "[email protected]"
Copy link
Member

Choose a reason for hiding this comment

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

who is the real owner of this token who is going to push the change? may that user name configuration is more relevant.

Copy link
Contributor Author

@carmal891 carmal891 Nov 2, 2024

Choose a reason for hiding this comment

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

The owner would be the same as to the existing GITHUB_TOKEN earlier set in the repo Action secrets. Since this automation is handled by Actions I have set the author as such to denote its a commit made by automated process.

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
GH_TOKEN: ${{ secrets.GH_TOKEN}}
run: |
cd ci/
Copy link
Member

Choose a reason for hiding this comment

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

can we use the fullpath instead of changing the directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

exit 1
fi

cd brew_tap_repo_temp || { echo "Error: Failed to navigate to brew_tap_repo_temp"; exit 1; }
Copy link
Member

Choose a reason for hiding this comment

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

use mktemp command to generate the temporary folder and assign it to variable and use it everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

cd brew_tap_repo_temp || { echo "Error: Failed to navigate to brew_tap_repo_temp"; exit 1; }
BRANCH_NAME="bump_formula_v$NEW_VERSION"
git checkout -b "$BRANCH_NAME" || { echo "Error: Failed to create branch $BRANCH_NAME"; exit 1; }
cd "$FORMULA_PATH" || { echo "Error: Failed to navigate to $FORMULA_PATH"; exit 1; }
Copy link
Member

Choose a reason for hiding this comment

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

use pushd, popd wherever needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

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

/lgtm

@ppc64le-cloud-bot ppc64le-cloud-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 4, 2024
@ppc64le-cloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: carmal891, mkumatag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ppc64le-cloud-bot ppc64le-cloud-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 4, 2024
@ppc64le-cloud-bot ppc64le-cloud-bot merged commit dfe9f76 into ppc64le-cloud:main Nov 4, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants