-
Notifications
You must be signed in to change notification settings - Fork 332
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
use the library version number to publish to pypi, create a git tag and define a github release #688
base: master
Are you sure you want to change the base?
use the library version number to publish to pypi, create a git tag and define a github release #688
Changes from 1 commit
4d185cb
b36b572
07cedd2
bf98923
77f1a80
0e5f6d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,11 +15,6 @@ jobs: | |||||
with: | ||||||
python-version: '3.10' | ||||||
|
||||||
- name: Gets the tag version | ||||||
id: context | ||||||
run: | | ||||||
echo ::set-output name=TAG_VERSION::${GITHUB_REF#refs/tags/} | ||||||
|
||||||
- name: Setup the Python Environment by installing Poetry | ||||||
uses: ./.github/actions/setup-python-build-env | ||||||
|
||||||
|
@@ -28,12 +23,51 @@ jobs: | |||||
run: make install && make tests | ||||||
|
||||||
- name: Poetry bump version, build and publish | ||||||
id: build | ||||||
shell: bash | ||||||
run: | | ||||||
proj_version=$(poetry version -s) | ||||||
if [ $proj_version != $TAG_VERSION ]; then echo "Version $proj_version, defined in pyproject.toml, does not match TAG $TAG_VERSION of this release"; exit 3; fi | ||||||
echo ::set-output name=PROJ_VERSION::$proj_version | ||||||
poetry update | ||||||
poetry publish --build -u __token__ -p $PYPI_TOKEN | ||||||
env: | ||||||
TAG_VERSION: ${{ steps.context.outputs.TAG_VERSION }} | ||||||
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | ||||||
|
||||||
- name: Check if Tag exists 🔍 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the workflow is triggered at tag push, the tag is always here. Why do you want to add these 2 steps? The sanity check should be that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of triggering on tag push, I just changed it to triggering on workflow_dispatch; this should allow the releaser to trigger the workflow from the UI or github cli and it will generate and apply the tags all based on the version in pyproject.toml. This should make sure that the tag, the github release and pypi release all use the same version number. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then if a tag already exists, the release workflow must fail hard at the beginning: version not bumped correctly and version already released. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||||
id: check_tag | ||||||
run: | | ||||||
echo "Checking for tag: $PROJ_TAG" | ||||||
if git rev-parse "refs/tags/$PROJ_TAG" >/dev/null 2>&1 | ||||||
then | ||||||
echo "Tag $PROJ_TAG already exists." | ||||||
echo "tag_exists=true" >> $GITHUB_OUTPUT | ||||||
exit 0 | ||||||
else | ||||||
echo "Tag $PROJ_TAG does not exist." | ||||||
echo "tag_exists=false" >> $GITHUB_OUTPUT | ||||||
fi | ||||||
env: | ||||||
PROJ_TAG: v${{ steps.build.outputs.PROJ_VERSION }} | ||||||
|
||||||
- name: Create and Push Tag 🏷️ | ||||||
if: steps.check_tag.outputs.tag_exists == 'false' | ||||||
run: | | ||||||
TAG="v${{ steps.extract_version.outputs.version }}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||||||
git tag $TAG | ||||||
git config user.name "GitHub Actions" | ||||||
git config user.email "actions@github.com" | ||||||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} | ||||||
git push origin $TAG | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Write permission with the default GH token will also need to be set in the workflow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||||
echo "tag_created=true" >> $GITHUB_OUTPUT | ||||||
env: | ||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
PROJ_TAG: v${{ steps.build.outputs.PROJ_VERSION }} | ||||||
|
||||||
- name: Create a GitHub Release | ||||||
uses: softprops/action-gh-release@v1 | ||||||
env: | ||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
PROJ_TAG: v${{ steps.build.outputs.PROJ_VERSION }} | ||||||
with: | ||||||
generate_release_notes: true | ||||||
tag_name: $PROJ_TAG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependencies should not be updated blindly at release without testing ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the code quality checks being run on every pull request, it is run as the second step in the release process:
make install && make tests
ocpp/.github/workflows/publish-to-pypi.yml
Line 18 in b36b572
Or is there a different set of testing that you think should occur before release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running
poetry update
at release is a never ever do that thing. The dependencies version lock file must not differ from the one in the repo ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the careful review! i misread your comment originally.
I had reused that section from the current one on master; I should have scrutinized it better. now updated.