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

build: tag version commit with version tag #203

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

tristanls
Copy link
Contributor

This pull request introduces a tag_version_monty_publish job to the Monty Publish workflow.

The job is only triggered when Monty workflow on the main branch succeeds, which is after a commit is merged to main.

  tag_version_monty_publish:
    name: tag-version-monty-publish
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    ...

The version is tagged only when that commit contains a version change in src/tbp/monty/__init__.py.

      ...
      - name: Tag version
        if: ${{ steps.version_updated.outputs.version_updated == 'true' }}
        working-directory: tbp.monty
        run: |
          git tag v${{ steps.version_updated.outputs.version }}
          git push origin v${{ steps.version_updated.outputs.version }}

The Version updated action now additionally returns version from src/tbp/monty/__init__.py (in addition to currently returning the version_updated boolean). This version is used in the tag name. For example, if the version is 0.0.7 then the tag will be v0.0.7

There are fewer if: conditionals in this job because it only triggers on the conclusion of Monty workflow and will not run on the manual trigger.

@tristanls tristanls added infrastructure Changes to infrastructure triaged This issue or pull request was triaged labels Feb 28, 2025
Copy link
Contributor

@codeallthethingz codeallthethingz left a comment

Choose a reason for hiding this comment

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

LGTM. One comment around the use of the print_version tool.

# grep finds the version line. It will only have two quotes. Then awk uses
# the quotes as separators and prints the middle value, which corresponds to
# the version inside the quotes.
version=$(grep '__version__\s*=\s*' src/tbp/monty/__init__.py | awk -F'"' '{print $2}')
Copy link
Contributor

Choose a reason for hiding this comment

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

you could use the tools/print_version command here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I considered it. I believe that in order to use the print_version tool, I need to create the conda environment, install the tool, and invoke it. Is that correct?

Copy link
Contributor

@codeallthethingz codeallthethingz Mar 1, 2025

Choose a reason for hiding this comment

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

Yes. Though you don't have install anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Though you don't have install anything.

What do you mean?

When I run the tool without installing via python -m tools.print_version.cli -h I get an error:

(tbp.monty) me@not_invented_here tbp.monty % python -m tools.print_version.cli -h 
Traceback (most recent call last):
  File "/opt/anaconda3/envs/tbp.monty/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/anaconda3/envs/tbp.monty/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/me/tbp/tbp.monty/tools/print_version/cli.py", line 15, in <module>
    import semver
ModuleNotFoundError: No module named 'semver'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to merge this as is for now and we can revisit in the future.

@tristanls tristanls enabled auto-merge (squash) March 4, 2025 16:53
@tristanls tristanls merged commit d53d8ed into thousandbrainsproject:main Mar 4, 2025
13 checks passed
@tristanls tristanls deleted the tag_version_commits branch March 4, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Changes to infrastructure triaged This issue or pull request was triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants