From 6e7a285ee96bd574582fe393967ef7560a9e55ee Mon Sep 17 00:00:00 2001 From: collijk Date: Tue, 26 Dec 2023 16:54:25 -0800 Subject: [PATCH] Swap to GITHUB_TOKEN and update readme --- README.md | 36 +++++++++++-------- .../.github/workflows/cookiecutter.yml | 2 +- .../.github/workflows/dependencies.yml | 2 +- .../.github/workflows/draft_release.yml | 4 ++- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 18d1734..0e334df 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Python Package Cookiecutter -A [cookiecutter](https://cookiecutter.readthedocs.io/en/latest/README.html) (project template) for rapidly developing new open source Python packages. Best practices with all the modern bells and whistles included. +A [cookiecutter](https://cookiecutter.readthedocs.io/en/latest/README.html) (project template) for rapidly developing new open source Python +packages. Best practices with all the modern bells and whistles included. ## Features @@ -60,8 +61,8 @@ Create a new project: cruft create https://github.com/collijk/python-package-cookiecutter ``` -The CLI interface will ask some basic questions, such the name of the project, and then generate all the goodies - automatically. +The CLI interface will ask some basic questions, such the name of the project, and then +generate all the goodies automatically. After that you can make it a proper git repo: @@ -72,8 +73,8 @@ git add . git commit -m "Initial project structure from Python Package cookiecutter" ``` -We update this cookiecutter template regularly to keep it up-to-date with the best practices of the Python world. You - can get the updates into your project with: +We update this cookiecutter template regularly to keep it up-to-date with the best +practices of the Python world. You can get the updates into your project with: ```sh cruft update @@ -83,22 +84,27 @@ cruft update #### `PYPI_TOKEN` -Required for publishing the package to [PyPI](https://pypi.org/). You can generate a token by logging into PyPI and - navigating to _Add API token_ in your [account settings](https://pypi.org/manage/account/). +Required for publishing the package to [PyPI](https://pypi.org/). You can generate a token by logging +into PyPI and navigating to _Add API token_ in your [account settings](https://pypi.org/manage/account/). -#### `AUTO_UPDATE_GITHUB_TOKEN` +#### `GITHUB_TOKEN` -This cookiecutter template comes with an auto update feature if the project was created using cruft. -A GitHub action automatically checks for updates and creates a pull request. +This cookiecutter template needs repository access for the following operations: -Generate [personal access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) -and use it as the value for `AUTO_UPDATE_GITHUB_TOKEN` secret. When creating the access token, the following - permissions have to be granted +* Automatically updating the infrastructure files when the template is updated (via [cruft](https://cruft.github.io/cruft/)) +* Automatically updating the dependencies. +* Automatically updating the changelog and version for draft releases. + +To enable these features, you need to create a +[personal access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) +and use it as the value for `GITHUB_TOKEN` secret. When creating the access token, the +following permissions have to be granted: * repo * workflow ### After the first release -The first release will create `gh-pages` branch which will contain the static files for the documentation. Enable GitHub - Pages in the _Pages_ section of the repository settings. +The first release will create `gh-pages` branch which will contain the static files for +the documentation. Enable GitHub Pages in the _Pages_ section of the repository +settings. diff --git a/{{cookiecutter.project_slug}}/.github/workflows/cookiecutter.yml b/{{cookiecutter.project_slug}}/.github/workflows/cookiecutter.yml index 7b9805f..a10ec60 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/cookiecutter.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/cookiecutter.yml @@ -74,7 +74,7 @@ jobs: - name: Create Pull Request env: # a PAT is required to be able to update workflows - GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ steps.changes.outputs.changed > 0 && env.GITHUB_TOKEN != 0 }} uses: peter-evans/create-pull-request@v5 with: diff --git a/{{cookiecutter.project_slug}}/.github/workflows/dependencies.yml b/{{cookiecutter.project_slug}}/.github/workflows/dependencies.yml index 72e688f..945b018 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/dependencies.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/dependencies.yml @@ -56,7 +56,7 @@ jobs: # behaviour if PR already exists: https://github.com/marketplace/actions/create-pull-request#action-behaviour - name: Create Pull Request env: - GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ steps.check_for_outdated_dependencies.outputs.body != 0 && env.GITHUB_TOKEN != 0 }} uses: peter-evans/create-pull-request@v5 with: diff --git a/{{cookiecutter.project_slug}}/.github/workflows/draft_release.yml b/{{cookiecutter.project_slug}}/.github/workflows/draft_release.yml index e1f0412..c5e2150 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/draft_release.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/draft_release.yml @@ -13,6 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} - uses: ./.github/actions/python-poetry-env - name: Update version id: updated_version @@ -37,7 +39,7 @@ jobs: } >> "$GITHUB_OUTPUT" echo "$body" - name: Commit changes - uses: EndBug/add-and-commit@v7 + uses: EndBug/add-and-commit@v9 with: add: 'CHANGELOG.md pyproject.toml' message: 'Release ${{ steps.updated_version.outputs.version }}'