PRQL/homebrew-prql

Versioning system

roG0d opened this issue · 5 comments

roG0d commented

Through GitHub Actions, create a workflow that enables to keeps updated the formula with the latest stable release.

The solution would go as:

  1. A new release on prql/prql is made ---> Trigger a workflow on: release that sends a workflow_dispatch.
  2. on prql/homebrew-prql ---> There's a workflow listening for the workflow_dispatch event. this workflow would change the .tar URL and the version from the Formula
roG0d commented

For now, It's working just the beginning of the solution:

  • Its has been created a fork of prql/prql on rog0d/prql. This fork will serve as a testing ground for publishing releases and testing with the workflows
  • The workflow release.yml has been created. It generates a workflow_dispatch that will activate the brew workflow on prql/homebrew-prql every release.
  • The workflow update.yml has been created. It gets activated with the previous workflow_dispatch and show a simple testing echo
roG0d commented

The version and URL inputs are working fine between workflows:

  • It has been added an input parameter on the release.yml containing the version of the release and the URL of the .tar. This is obtained via the ${{ github.ref }} enviroment variable which give us the /refs/tags/tag of the release that triggers the workflow
  • In the workflow update.yml, it has been added everything needed for the inputs to get working (inputs and descriptions of the same). Lately, It is tested via some dummy echo containing the version and the URL as it can be seen on the Actions Tab
  • CAREFUL the current URL is already pointing to the original prql repo, not to the testing one, which has no .tar assets on its testing releases
roG0d commented

The version and URL tags are commited to prql.rb as expected:

  • The update.yml file has 2 jobs:
    • edit-tags: Responsible of editing the tags to match the proper syntax (ej: version "0.1.2").
    • commit-tags: Based on actions/checkout@v3. Responsible of adding double quotations to the variables, use sed for the prql.rb file to change the tags (URL and version) and to commit the propers changes

For now, there's a bug on the release.yml that triggers 4 workflows on the prql repo. Even with this bug, update.yml behaves works properly as no change is performed on the prql.rb file.

roG0d commented

The SHA256 is a field to be updated too, this has been achieved on commit c830e2a
The idea for this has been:

  • The SHA 256 contains the checksum of the .tar.gz containing the source files of the proyect. So it's needed to download those via the ${{ needs.edit-tag.outputs.url }}: wget ${{ needs.edit-tag.outputs.url }}. It's used ${{ needs.edit-tag.outputs.url }}. because it doesn´t contains double quotes (necessaries on the formulae field). If not it would result in a scheme error.
  • Now the checksum value it's needed, so the shasum function is used as it follows:export SHA=$(shasum -a 256 ${{ needs.edit-tag.outputs.tag }}.tar.gz)
  • It's needed to split the result of the shasum command, so: export SHA=$(echo $SHA | cut -f 1 -d ' ')
  • Lastly the formulae is updated via the sed command: sed -i "5 s/sha256 .*/sha256 $SHA/" "prql-compiler.rb"

Closing as completed!