diff --git a/.github/workflows/build.yaml b/.github/workflows/release-build.yaml similarity index 79% rename from .github/workflows/build.yaml rename to .github/workflows/release-build.yaml index 857bbb4..82448c4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/release-build.yaml @@ -17,13 +17,14 @@ jobs: with: poetry-version: "latest" - - name: install-poetry-plugins + - name: setup-pypi run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} poetry self add poetry-pyinstaller-plugin poetry self add poetry-plugin-taskipy - name: build - run: poetry build + run: poetry publish --build - name: Release uses: softprops/action-gh-release@v2 @@ -34,4 +35,4 @@ jobs: dist/*.whl generate_release_notes: true env: - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/template-python/cookiecutter.json b/template-python/cookiecutter.json index d4c123a..ffe1fd5 100644 --- a/template-python/cookiecutter.json +++ b/template-python/cookiecutter.json @@ -4,18 +4,8 @@ "email": "shawndeng1109@qq.com", "project_slug": "{{ cookiecutter.repo_name.strip().lower().replace('-', '_') }}", "description": "A short description of the project.", - "include_cli": { - "__prompt__": "Include CLI interface? (y/n)", - "__choices__": [ - "y", - "n" - ] - }, - "create_github_repo": { - "__prompt__": "Create GitHub repo? Requires ~/.github/config.json with GitHub token (y/n)", - "__choices__": [ - "y", - "n" - ] - } + "include_cli": [ + "y", + "n" + ] } diff --git a/template-python/hooks/post_gen_project.py b/template-python/hooks/post_gen_project.py index 0592af3..3edfbd2 100644 --- a/template-python/hooks/post_gen_project.py +++ b/template-python/hooks/post_gen_project.py @@ -1,5 +1,6 @@ import os import subprocess +from githubkit import GitHub def remove_cli(): diff --git a/template-python/{{cookiecutter.project_slug}}/.github/workflows/bumpversion.yaml b/template-python/{{cookiecutter.project_slug}}/.github/workflows/bumpversion.yaml new file mode 100644 index 0000000..bbc9c71 --- /dev/null +++ b/template-python/{{cookiecutter.project_slug}}/.github/workflows/bumpversion.yaml @@ -0,0 +1,24 @@ +name: Bump version + +on: + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + bump-version: + if: "!startsWith(github.event.head_commit.message, 'bump:')" + runs-on: ubuntu-latest + name: "Bump version and create changelog with commitizen" + steps: + - name: Check out + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: '${{ secrets.GITHUB_TOKEN }}' + - name: Create bump and changelog + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master diff --git a/template-python/{{cookiecutter.project_slug}}/.github/workflows/release-build.yaml b/template-python/{{cookiecutter.project_slug}}/.github/workflows/release-build.yaml new file mode 100644 index 0000000..82448c4 --- /dev/null +++ b/template-python/{{cookiecutter.project_slug}}/.github/workflows/release-build.yaml @@ -0,0 +1,38 @@ +name: release-build +on: + push: + tags: + - '*.*.*' + workflow_dispatch: + +jobs: + release-build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: abatilo/actions-poetry@v2 + with: + poetry-version: "latest" + + - name: setup-pypi + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry self add poetry-pyinstaller-plugin + poetry self add poetry-plugin-taskipy + + - name: build + run: poetry publish --build + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: | + dist/**/*.exe + dist/*.tar.gz + dist/*.whl + generate_release_notes: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}