Skip to content

feat: Add automatic release #11

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

Merged
merged 3 commits into from
Mar 28, 2023

Conversation

Lash-L
Copy link
Collaborator

@Lash-L Lash-L commented Mar 28, 2023

So - this is something I've done for a few other pypi projects, but I've never done it in the middle of the project like this. So it may take some testing/ tuning.

You'll have to get an access token for pypi https://test.pypi.org/help/#apitoken

and a github token. And allow actions permissions to write on the repository.

This will when you merge into main, automatically create a changelog, bump the version, put out a release on github, and then put out a pypi release.

We need a changelog for HA core.

It means we should tag our commits with chore: (something small, doesn't need a version bump)

fix: Fixes an existing bump, needs a small version bump

feat: A new feature

If you don't want to do this, that is fine, but we do need to create a changelog at some point for HA if nothing else.

I'd add this one before the other PR as I manually set the version to catch up with the last one.

Copy link
Collaborator

@humbertogontijo humbertogontijo left a comment

Choose a reason for hiding this comment

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

I was about to reject this PR but found out that GH have scoped tokens now.

A few changes are needed:

  1. GITHUB_TOKEN is not a valid secret name. Can you change it to GH_TOKEN?
  2. Can you change it to deploy to test pypi first? And we change it to main pypi if everything works

@Lash-L
Copy link
Collaborator Author

Lash-L commented Mar 28, 2023

I was about to reject this PR but found out that GH have scoped tokens now.

Yep - that's what is nice about it, you're in full control and it can only affect this project.

A few changes are needed:

  1. GITHUB_TOKEN is not a valid secret name. Can you change it to GH_TOKEN?

Done

  1. Can you change it to deploy to test pypi first? And we change it to main pypi if everything works

To be honest with you, I'm not sure how. python-semantic-release technically has an option for repository url - so potentially that? I didn't even know test.pypi existed
https://python-semantic-release.readthedocs.io/en/latest/#distributing-release-on-pypi-or-custom-repository

@humbertogontijo
Copy link
Collaborator

@humbertogontijo
Copy link
Collaborator

F**k, lets yolo it

@humbertogontijo humbertogontijo merged commit ab2942c into Python-roborock:main Mar 28, 2023
@Lash-L
Copy link
Collaborator Author

Lash-L commented Mar 28, 2023

F**k, lets yolo it

haha, my kind of guy

I think it may be failing because there is no current github release/ no previous "version" it sees in the commits? So it thinks it is 0.0.0 Try creating a tag and a release and see if that works.

@humbertogontijo
Copy link
Collaborator

humbertogontijo commented Mar 28, 2023

I added the tag and release and re ran it. No success
Maybe it is related to version_variable and version_toml variables in toml file. Are these supposed to be used together?

@Lash-L
Copy link
Collaborator Author

Lash-L commented Mar 28, 2023

They should be able to - I do something similar in another project.

I think it needs https://python-semantic-release.readthedocs.io/en/latest/configuration.html#version-source to be tag so that it is looking at tags for the release version instead ofthe commits.

            uses: relekang/[email protected]
            with:
                github_token: ${{ secrets.GH_TOKEN }}
                pypi_token: ${{ secrets.PYPI_TOKEN }}
                version_source: tag

@humbertogontijo
Copy link
Collaborator

Lets try it. Create a PR with it and I'll approve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants