Title: Release automatically when the version changes by jonathan-kosgei · Pull Request #37 · ipdata/python · GitHub
Open Graph Title: Release automatically when the version changes by jonathan-kosgei · Pull Request #37 · ipdata/python
X Title: Release automatically when the version changes by jonathan-kosgei · Pull Request #37 · ipdata/python
Description: Summary Add a release job to .github/workflows/python-publish.yml that runs after the test matrix on every push to master, reads the version from setup.cfg and, when no tag of that name exists yet, creates the tag and the GitHub release (with generated notes) in one step. Make build-n-publish wait for that job and upload to PyPI when the tag was created in the same run; a tag pushed by hand still publishes as before. Add a maintainer-facing "Releasing" section to the README. How it works release is guarded by github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch), needs test, runs with permissions: contents: write and in the release concurrency group without cancellation, so two merges in a row release one after the other. It reads the version with sed -nE 's/^version *= *([^[:space:]]+).*/\1/p' setup.cfg | head -1 (tags carry no v prefix, matching the existing tags) and checks git ls-remote --exit-code --tags origin "refs/tags/$TAG": exit 0 means the tag exists and the job reports that there is nothing to release (created=false); exit 2 means it is missing, so gh release create "$TAG" --target "$GITHUB_SHA" --title "$TAG" --generate-notes creates the tag and the release with the workflow's own GITHUB_TOKEN (created=true); any other exit code fails the job. A tag created with GITHUB_TOKEN does not start another workflow run, so publishing happens in the same run: build-n-publish now has needs: [test, release] and its "Publish to PyPI" step runs when needs.release.outputs.created == 'true' or, as before, when the run was started by a tag push (startsWith(github.ref, 'refs/tags')). The job itself still runs for every push (full test suite with the API key, then the build), and its condition tolerates the release job being skipped on tag pushes. Nothing else changes: the pull_request test matrix, the full-suite run on master, the publish steps and the secrets they use are as before. The version currently in setup.cfg (4.1.0) is already tagged, so merging this pull request releases nothing by itself. Verification python3 -c 'import yaml,sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]' .github/workflows/*.yml passes. actionlint .github/workflows/*.yml (v1.7.12) reports nothing. The version command prints 4.1.0 for the checked-out setup.cfg. The test matrix runs on this pull request; the push-only release job can only be exercised by a merge. 🤖 Generated with Claude Code
Open Graph Description: Summary Add a release job to .github/workflows/python-publish.yml that runs after the test matrix on every push to master, reads the version from setup.cfg and, when no tag of that name exists yet...
X Description: Summary Add a release job to .github/workflows/python-publish.yml that runs after the test matrix on every push to master, reads the version from setup.cfg and, when no tag of that name exists yet...
Opengraph URL: https://github.com/ipdata/python/pull/37
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9254a17c-08f7-a062-2f2b-7ea675050c98 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8F22:B1B84:2921BAB:34599F6:6B01DB97 |
| html-safe-nonce | d426ca2ab87123008afd5c07ccfef4007223c9b9d843bef134b850cf5971bab8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RjIyOkIxQjg0OjI5MjFCQUI6MzQ1OTlGNjo2QjAxREI5NyIsInZpc2l0b3JfaWQiOiI2Mzc4MTUyNTI4MDA1MTU5ODMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f82961a6c31b3c7953261569a8b835b2ce013d627017f586dce9cd1938318499 |
| hovercard-subject-tag | pull_request:5142487854 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/ipdata/python/pull/37/files |
| twitter:image | https://avatars.githubusercontent.com/u/6712914?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/6712914?s=400&v=4 |
| og:image:alt | Summary Add a release job to .github/workflows/python-publish.yml that runs after the test matrix on every push to master, reads the version from setup.cfg and, when no tag of that name exists yet... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/ipdata/python git https://github.com/ipdata/python.git |
| octolytics-dimension-user_id | 33085067 |
| octolytics-dimension-user_login | ipdata |
| octolytics-dimension-repository_id | 108238848 |
| octolytics-dimension-repository_nwo | ipdata/python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 108238848 |
| octolytics-dimension-repository_network_root_nwo | ipdata/python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width