{"id":28741081,"url":"https://github.com/cleder/python-repository-template","last_synced_at":"2026-01-30T08:03:47.043Z","repository":{"id":266671162,"uuid":"898994508","full_name":"cleder/python-repository-template","owner":"cleder","description":"A Template repository for python projects, with testing and publishing","archived":false,"fork":false,"pushed_at":"2025-08-18T15:34:43.000Z","size":12,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-18T17:35:41.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cleder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-05T12:28:44.000Z","updated_at":"2025-08-18T15:34:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce6584f3-7952-4ed6-be41-72a42c82ca49","html_url":"https://github.com/cleder/python-repository-template","commit_stats":null,"previous_names":["cleder/python-repository-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/cleder/python-repository-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fpython-repository-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fpython-repository-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fpython-repository-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fpython-repository-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleder","download_url":"https://codeload.github.com/cleder/python-repository-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fpython-repository-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28908851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T06:42:00.998Z","status":"ssl_error","status_checked_at":"2026-01-30T06:41:58.659Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-16T07:10:40.729Z","updated_at":"2026-01-30T08:03:47.036Z","avatar_url":"https://github.com/cleder.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-repository-template\nA Template repository for python projects, with testing and publishing.\n\n## How to Publish Your Python Package with Trusted Publishing\n\nThis Repository provides a workflow that will publish your package to TestPyPi when a tag is created (on the `development` branch), or to PyPi when you merge to the `main` branch.\n\n### Prepare Your Package for Publishing\n\nEnsure your Python package follows PyPI’s packaging guidelines. At a minimum, you’ll need:\n\n- A [~~setup.py or~~ pyproject.toml](https://dev.to/ldrscke/hypermodernize-your-python-package-3d9m \"How to convert from setup.py to pyproject.toml\") file defining your package metadata.\n- Properly structured code with a clear directory layout.\n- A README file to showcase your project on PyPI.\n\nFor a detailed checklist, refer to the [Python Packaging User Guide](https://packaging.python.org/).\n\n### Configure GitHub Actions in Your Repository\n\nLet's start by creating a new GitHub action `.github/workflows/test-build-publish.yml`.\n\n```yaml\nname: test-build-publish\n\non: [push, pull_request]\n\npermissions:\n  contents: read\n\njobs:\n\n  build-and-check-package:\n    name: Build \u0026 inspect our package.\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v4\n      - uses: hynek/build-and-inspect-python-package@v2\n```\n\nThis [action](https://github.com/hynek/build-and-inspect-python-package) will build your package and uploads the built wheel and the source distribution (`SDist`) as GitHub Actions artefacts.\n\nNext, we add a step to publish to [TestPyPI](https://test.pypi.org/). This step will run whenever a tag is created, ensuring that the build from the previous step has completed successfully. Replace PROJECT_OWNER and PROJECT_NAME with the appropriate values for your repository.\n\n```yaml\n  test-publish:\n    if: \u003e-\n        github.event_name == 'push' \u0026\u0026\n        github.repository == 'PROJECT_OWNER/PROJECT_NAME' \u0026\u0026\n        startsWith(github.ref, 'refs/tags')\n    needs: build-and-check-package\n    name: Test publish on TestPyPI\n    runs-on: ubuntu-latest\n    environment: test-release\n    permissions:\n      id-token: write\n    steps:\n      - name: Download packages built by build-and-check-package\n        uses: actions/download-artifact@v4\n        with:\n          name: Packages\n          path: dist\n\n      - name: Upload package to Test PyPI\n        uses: pypa/gh-action-pypi-publish@release/v1\n        with:\n          repository-url: https://test.pypi.org/legacy/\n```\n\nThis step downloads the artefacts created during the build process and uploads them to TestPyPI for testing.\n\nIn the last step, we will upload the package to PyPI when a pull request is merged into the `main` branch.\n\n```yaml\n  publish:\n    if: \u003e-\n      github.event_name == 'push' \u0026\u0026\n      github.repository == 'PROJECT_OWNER/PROJECT_NAME' \u0026\u0026\n      github.ref == 'refs/heads/main'\n    needs: build-and-check-package\n    name: Publish to PyPI\n    runs-on: ubuntu-latest\n    environment: release\n    permissions:\n      id-token: write\n    steps:\n      - name: Download packages built by build-and-check-package\n        uses: actions/download-artifact@v4\n        with:\n          name: Packages\n          path: dist\n\n      - name: Publish distribution 📦 to PyPI for push to main\n        uses: pypa/gh-action-pypi-publish@release/v1\n```\n\n### Configure GitHub Environments\n\nTo ensure that only specific tags trigger the publishing workflow and maintain control over your release process.\nCreate a new environment `test-release` by navigating to Settings -\u003e Environments in your GitHub repository.\n\nSet up the environment and add a deployment tag rule.\n\n![Add a new environment](https://github.com/cleder/talks/blob/main/images/pypi-publish/github-environments.png)\n\n![Create test environment](https://github.com/cleder/talks/blob/main/images/pypi-publish/github-environment-test-release.png)\n\nLimit which branches and tags can deploy to this environment based on rules or naming patterns.\n\n![Add deployment tag rule](https://github.com/cleder/talks/blob/main/images/pypi-publish/github-environment--add-tag-ruleset-target-pattern.png)\n\nLimit which branches and tags can deploy to this environment based on naming patterns.\n\n![Add target tags](https://github.com/cleder/talks/blob/main/images/pypi-publish/github-environment--tag-ruleset-target.png)\n\nConfigure the target tags.\n\n![Configure target tags](https://github.com/cleder/talks/blob/main/images/pypi-publish/github-environment--add-deployment-tag-pattern.png)\n\nThe pattern `[0-9]*.[0-9]*.[0-9]*` matches semantic versioning tags such as `1.2.3`, `0.1.0`, or `2.5.1b3`, but it excludes arbitrary tags like `bugfix-567` or `feature-update`.\n\nRepeat this for the `release` environment to protect the `main` branch in the same way for the `release` environment, but this time targeting the `main` branch.\n\n![Configure target branch](https://github.com/cleder/talks/blob/main/images/pypi-publish/github-environment--add-deployment-branch-pattern.png)\n\n\n\n### Set Up a PyPI Project and Link Your GitHub Repository\n\nCreate an account on [TestPyPI](https://test.pypi.org/) if you don’t have one.\nNavigate to your account, [Publishing](https://test.pypi.org/manage/account/publishing/) and add a new pending publisher.\nLink your GitHub repository to the PyPI project by providing its name, your GitHub username, the repository name, the workflow name (`test-build-publish.yml`) and the environment name (`test-release`).\n\n![Configure PyPI trusted publisher](https://github.com/cleder/talks/blob/main/images/pypi-publish/test-pypi-publishing.png)\n\nRepeat the above on PyPI with the environment name set to `release`.\n\n## Start Your Own Project\n\nJust delete this README and use `uv init` to create a new python package.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleder%2Fpython-repository-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleder%2Fpython-repository-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleder%2Fpython-repository-template/lists"}