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

workflows: Add automation for choco upgrade #2691

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

vyncent-t
Copy link
Contributor

@vyncent-t vyncent-t commented Dec 13, 2024

Description

Solves issue #2683

This PR introduces an automation workflow and a supporting script to streamline the process of updating the Chocolatey package for Headlamp. The automation workflow automatically updates the headlamp.nuspec file and the checksum in app/windows/chocolatey/tools/chocolateyinstall.ps1, then creates a new PR with the changes for the updated version.

Key Changes

  1. New Automation Workflow:

    • Added a GitHub Actions workflow that:
      • Runs the choco-auto.js script to update the headlamp.nuspec file with the new version number.
      • Updates the checksum in chocolateyinstall.ps1 to match the new version.
      • Automatically opens a new PR with the changes.
  2. choco-auto.js Script:

    • Added choco-auto.js to app/windows/chocolatey.
    • This script handles:
      • Updating the headlamp.nuspec file with the provided version number.
      • Calculating and updating the checksum in chocolateyinstall.ps1.
  3. Script Requirements:

    • The choco-auto.js script requires a version number as an argument.
    • The version number must contain only numeric characters and periods (e.g., 0.27.0).

How to Use the Script Manually

  1. Navigate to the Chocolatey directory:
    cd app/windows/chocolatey

  2. Run the script with the desired version number:
    node choco-auto.js 0.27.0

  3. Wait for the script to execute. It will:

    • Update the headlamp.nuspec file with the new version number.
    • Update the checksum in chocolateyinstall.ps1.
  4. Review the changes to ensure correctness.


Notes

  • The workflow automates the update process but the script can also be run manually for testing or one-off updates.
  • Ensure that the version number passed to the script is in the correct format (numeric only, e.g., 0.27.0).
  • This enhancement reduces manual effort and minimizes the risk of errors when updating the Chocolatey package.

@vyncent-t vyncent-t self-assigned this Dec 13, 2024
@vyncent-t vyncent-t force-pushed the automate-choco-workflow branch 4 times, most recently from 0326294 to 49cb251 Compare December 16, 2024 17:03
@vyncent-t vyncent-t changed the title WIP - workflows: Add automation for choco upgrade workflows: Add automation for choco upgrade Dec 16, 2024
@vyncent-t vyncent-t added the enhancement New feature or request label Dec 16, 2024
@vyncent-t vyncent-t marked this pull request as ready for review December 16, 2024 17:19
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 16, 2024
@vyncent-t
Copy link
Contributor Author

note if you want to test the pipeline workflow have it push to the branch, just swap these two parts here in commented out places and push to the branch, this should then kick off the build workflows to where you can click on PR for updating Chocolatey, let it finish building and click on the link for the new PR

image

Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

Thanks @vyncent-t . I left a couple of comments.

.github/workflows/pr-to-update-choco.yml Show resolved Hide resolved
.github/workflows/pr-to-update-choco.yml Outdated Show resolved Hide resolved
.github/workflows/pr-to-update-choco.yml Outdated Show resolved Hide resolved
.github/workflows/pr-to-update-choco.yml Outdated Show resolved Hide resolved
app/windows/chocolatey/choco-auto.js Outdated Show resolved Hide resolved
@vyncent-t vyncent-t force-pushed the automate-choco-workflow branch 16 times, most recently from 1e50b33 to 952bf34 Compare December 17, 2024 19:35
@vyncent-t
Copy link
Contributor Author

removed the auto script and this now runs when updating the tag

note: testing when the current main is already updated with the new nuget pkg and hash will create a PR that has no changes to add as this runs for the newest

Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

Almost there. Left a couple more comments.

.github/workflows/pr-to-update-choco.yml Show resolved Hide resolved
.github/workflows/pr-to-update-choco.yml Outdated Show resolved Hide resolved
.github/workflows/pr-to-update-choco.yml Show resolved Hide resolved
.github/workflows/pr-to-update-choco.yml Outdated Show resolved Hide resolved
@vyncent-t vyncent-t force-pushed the automate-choco-workflow branch 4 times, most recently from 1decf0b to 457fc1b Compare December 18, 2024 15:40
Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

You forgot to remove the checksums.txt file from git. I also think you should merge the steps that concern the checksums.txt: Download + Extract Data + Remove file -> All in one step.
This is because we then contain the use of the checksums file only to one step, which can be useful.

@vyncent-t vyncent-t force-pushed the automate-choco-workflow branch from 457fc1b to 338a57a Compare December 18, 2024 16:59
@vyncent-t vyncent-t force-pushed the automate-choco-workflow branch from 338a57a to b298ed3 Compare December 18, 2024 18:09
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 18, 2024
@joaquimrocha joaquimrocha merged commit e47adf1 into main Dec 18, 2024
18 checks passed
@joaquimrocha joaquimrocha deleted the automate-choco-workflow branch December 18, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants