diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..8118693 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,45 @@ +name-template: '$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: 'Bug Fixes' + labels: + - 'P: bug' + - 'V: patch' + - title: '🚀Features' + labels: + - 'P: enhancement' + - 'V: minor' + - title: 'Maintenance' + labels: + - 'chore' +change-template: '- [#$NUMBER] $TITLE (@$AUTHOR)' +change-title-escapes: '\<*_&' +version-resolver: + major: + labels: + - 'V: major' + minor: + labels: + - 'V: minor' + patch: + labels: + - 'V: patch' + default: patch +exclude-labels: + - 'dependencies' + - 'fresh' + - 'help wanted' + - 'question' + - 'release' + - 'C: convention' + - 'C: stakeholder' + - 'C: style' + - 'S: duplicate' + - 'S: feedback' + - 'S: invalid' + - 'S: merged' + - 'S: wontfix' +template: | + ## What Changed + + $CHANGES diff --git a/.github/workflows/do-release.yml b/.github/workflows/do-release.yml new file mode 100644 index 0000000..98aa8fa --- /dev/null +++ b/.github/workflows/do-release.yml @@ -0,0 +1,144 @@ +# This workflow runs when a pull request is closed. +# +# - Gets list of PR labels. +# - If 'release' label: +# - Get release version using Poetry. +# - Generate new CHANGELOG. +# - Tag repository with new version tag. +# - Build the release. +# - Draft a new GitHub release. +# - Upload the wheel to the new GitHub release. +# - Upload wheel to Test PyPi if build succeeds. (Future) +# - Test install from Test PyPi. (Future) +# - Upload wheel to PyPi if test install succeeds. (Future) +name: Do Release Workflow + +on: + pull_request: + branches: + - master + types: + - closed + +jobs: + create_new_release: + name: Create New Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get PR labels + id: prlabels + uses: joerick/pr-labels-action@v1.0.8 + + - name: Get release version + id: relversion + if: contains(steps.prlabels.outputs.labels, ' release ') + run: | + pip install poetry + echo "version=$(echo $(poetry version | cut -d' ' -f2))" >> $GITHUB_OUTPUT + echo "do_release=1" >> $GITHUB_ENV + + - name: Generate release changelog + uses: heinrichreimer/github-changelog-generator-action@master + if: ${{ env.do_release == 1 }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + sinceTag: "v1.3.1" + excludeTags: "latest" + breakingLabel: "Breaking Changes" + breakingLabels: "V: major" + enhancementLabel: "New Features" + enhancementLabels: "P: enhancement" + bugsLabel: "Bug Fixes" + bugLabels: "P: bug" + excludeLabels: "release" + issues: false + issuesWoLabels: false + maxIssues: 100 + pullRequests: true + prWoLabels: false + author: true + unreleased: true + compareLink: true + stripGeneratorNotice: true + verbose: true + + - name: Check if diff + continue-on-error: true + run: > + git diff --exit-code CHANGELOG.md && + (echo "### No update" && exit 1) || (echo "### Commit update") + + - uses: EndBug/add-and-commit@v9 + name: Commit and push if diff + if: success() + with: + add: CHANGELOG.md + message: 'chore: update CHANGELOG.md for new release' + author_name: GitHub Actions + author_email: action@github.com + committer_name: GitHub Actions + committer_email: actions@github.com + push: true + + - name: Build release + id: build + if: ${{ env.do_release == 1 }} + run: | + pip install -U pip poetry twine + poetry build && twine check dist/* && echo "build_ok=1" >> $GITHUB_ENV + + - name: Cut the release + id: cutrelease + if: ${{ env.build_ok == 1 }} + uses: release-drafter/release-drafter@v5 + with: + name: "${{ steps.newversion.outputs.new_tag }}" + tag: "${{ steps.newversion.outputs.new_tag }}" + version: "${{ steps.newversion.outputs.new_tag }}" + prerelease: false + publish: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Print release info + run: | + echo ${{ steps.cutrelease.outputs.id }} + echo ${{ steps.cutrelease.outputs.name }} + echo ${{ steps.cutrelease.outputs.tag_name }} + echo ${{ steps.cutrelease.outputs.html_url }} + echo ${{ steps.cutrelease.outputs.upload_url }} + + - name: Upload wheel to GitHub release + id: upload-wheel + if: ${{ env.build_ok == 1 }} + uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ steps.cutrelease.outputs.upload_url }} + +# - name: Publish to Test PyPi +# if: ${{ env.build_ok == 1 }} +# uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# user: __token__ +# password: ${{ secrets.TEST_PYPI_API_TOKEN }} +# repository_url: https://test.pypi.org/legacy/ + +# - name: Test install from Test PyPI +# if: ${{ env.build_ok == 1 }} +# run: | +# sudo apt-get update +# pip install \ +# --index-url https://test.pypi.org/simple/ \ +# --extra-index-url https://pypi.org/simple \ +# docformatter==${{ steps.newversion.outputs.new_version }} && echo "install_ok=1" >> $GITHUB_ENV + +# - name: Publish to PyPi +# if: ${{ env.install_ok == 1 }} +# uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# user: __token__ +# password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/do-update-authors.yml b/.github/workflows/do-update-authors.yml index 440ce33..4c4c67d 100644 --- a/.github/workflows/do-update-authors.yml +++ b/.github/workflows/do-update-authors.yml @@ -50,8 +50,8 @@ jobs: file_head = ( ".. This file is automatically generated/updated by a github actions workflow.\n" - ".. Every manual change will be overwritten on push to main.\n" - ".. You can find it here: ``.github/workflows/do-update-authors.yaml``\n\n" + ".. Every manual change will be overwritten on push to master.\n" + ".. You can find it here: ``.github/workflows/do-update-authors.yml``\n\n" "Author\n" "------\n" "Steven Myint \n\n" diff --git a/.github/workflows/on-push-tag.yml b/.github/workflows/on-push-tag.yml index e4d0198..4a7969d 100644 --- a/.github/workflows/on-push-tag.yml +++ b/.github/workflows/on-push-tag.yml @@ -1,15 +1,12 @@ # This workflow runs when a version tag is pushed. # # - Get new tag. -# - Build new release. # - If release tag: -# - Build release. -# - Generate GitHub release if build succeeds. -# - Upload wheel to GitHub release if build succeeds. -# - Upload wheel to Test PyPi if build succeeds. (Future) -# - Test install from Test PyPi. (Future) -# - Upload wheel to PyPi if test install succeeds. (Future) -name: Push Version Tag Workflow +# - Get next semantic version. +# - Close old milestones. +# - Create new minor version milestone. +# - Create new major version milestone. +name: Version Tag Workflow on: push: @@ -17,8 +14,8 @@ on: - 'v*' jobs: - request-release: - name: Request Release PR + manage_milestones: + name: Manage Milestones runs-on: ubuntu-latest steps: - name: Checkout repository @@ -30,68 +27,42 @@ jobs: - name: Get new tag id: newversion run: | - new_tag=${GITHUB_REF/refs\/tags\//} - new_version=$(echo $new_tag | sed 's/.rc[0-9]*//') - echo "new_tag=$(echo $new_tag)" >> $GITHUB_OUTPUT - echo "new_version=$(echo $new_version)" >> $GITHUB_OUTPUT - echo "New tag is: $new_tag" - echo "New version is: $new_version" + tag=${GITHUB_REF/refs\/tags\//} + version=$(echo $new_tag | sed 's/.rc[0-9]*//') + if [[ $tag != *"-rc"* ]]; then + echo "do_milestones=1" >> $GITHUB_ENV + echo "tag=$(echo $tag)" >> $GITHUB_OUTPUT + echo "version=$(echo $version)" >> $GITHUB_OUTPUT + fi + echo "New tag is: $tag" + echo "New version is: $version" echo "GitHub ref: ${{ github.ref }}" - - name: Build release - id: build - run: | - pip install -U pip poetry twine - poetry build && twine check dist/* && echo "build_ok=1" >> $GITHUB_ENV + - name: Get next semantic version + id: nextversion + if: ${{ env.do_milestones == 1 }} + uses: WyriHaximus/github-action-next-semvers@v1.2.1 + with: + version: ${{ steps.newversion.outputs.version }} + + - name: Close old milestone + if: ${{ env.do_milestones == 1 }} + uses: WyriHaximus/github-action-close-milestone@master + with: + number: ${{ steps.relversion.outputs.version }} - - name: Cut the release - id: cutrelease - if: ${{ !contains( steps.newversion.output.new_tag, 'rc' ) && env.build_ok == 1 }} - uses: release-drafter/release-drafter@v5 + - name: Create new minor release milestone + if: ${{ env.do_milestones == 1 }} + uses: WyriHaximus/github-action-create-milestone@v1.2.0 with: - name: "v${{ steps.newversion.outputs.new_tag }}" - tag: "v${{ steps.newversion.outputs.new_tag }}" - version: "${{ steps.newversion.outputs.new_tag }}" - prerelease: false - publish: true + title: "${{ steps.nextversion.outputs.v_minor }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Print release info - run: | - echo ${{ steps.cutrelease.outputs.id }} - echo ${{ steps.cutrelease.outputs.name }} - echo ${{ steps.cutrelease.outputs.tag_name }} - echo ${{ steps.cutrelease.outputs.html_url }} - echo ${{ steps.cutrelease.outputs.upload_url }} - - - name: Upload wheel to GitHub release - id: upload-wheel - if: ${{ env.build_ok == 1 }} - uses: shogo82148/actions-upload-release-asset@v1 + - name: Create new major release milestone + if: ${{ env.do_milestones == 1 }} + uses: WyriHaximus/github-action-create-milestone@v1.2.0 with: - upload_url: ${{ steps.cutrelease.outputs.upload_url }} - -# - name: Publish to Test PyPi -# if: ${{ !contains( steps.newversion.output.new_tag, 'rc' ) && env.build_ok == 1 }} -# uses: pypa/gh-action-pypi-publish@release/v1 -# with: -# user: __token__ -# password: ${{ secrets.TEST_PYPI_API_TOKEN }} -# repository_url: https://test.pypi.org/legacy/ - -# - name: Test install from Test PyPI -# if: ${{ !contains( steps.newversion.output.new_tag, 'rc' ) && env.build_ok == 1 }} -# run: | -# sudo apt-get update -# pip install \ -# --index-url https://test.pypi.org/simple/ \ -# --extra-index-url https://pypi.org/simple \ -# docformatter==${{ steps.newversion.outputs.new_version }} && echo "install_ok=1" >> $GITHUB_ENV - -# - name: Publish to PyPi -# if: ${{ !contains( steps.newversion.output.new_tag, 'rc' ) && env.install_ok == 1 }} -# uses: pypa/gh-action-pypi-publish@release/v1 -# with: -# user: __token__ -# password: ${{ secrets.PYPI_API_TOKEN }} + title: "${{ steps.nextversion.outputs.v_major }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml deleted file mode 100644 index d8be3cb..0000000 --- a/.github/workflows/on-release.yml +++ /dev/null @@ -1,93 +0,0 @@ -# This workflow runs when a pull request is closed. -# -# - Gets list of PR labels. -# - If 'release' label: -# - Get release version using Poetry. -# - Generate new CHANGELOG. -# - Get next semantic version. -# - Close old milestones. -# - Create new minor version milestone. -# - Create new major version milestone. -name: Do Release Workflow - -on: - pull_request: - branches: - - master - types: - - closed - -jobs: - create_new_milestone: - name: Create New Milestone - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Get PR labels - id: prlabels - uses: joerick/pr-labels-action@v1.0.8 - - - name: Get release version - id: relversion - if: contains(steps.prlabels.outputs.labels, ' release ') - run: | - pip install poetry - echo "version=$(echo $(poetry version | cut -d' ' -f2))" >> $GITHUB_OUTPUT - echo "do_milestones=1" >> $GITHUB_ENV - - - name: Generate release changelog - uses: heinrichreimer/github-changelog-generator-action@master - if: ${{ env.do_milestones == 1 }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - sinceTag: "v1.3.1" - excludeTags: "latest" - breakingLabel: "Breaking Changes" - breakingLabels: "V: major" - enhancementLabel: "New Features" - enhancementLabels: "P: enhancement" - bugsLabel: "Bug Fixes" - bugLabels: "P: bug" - excludeLabels: "release" - issues: false - issuesWoLabels: false - maxIssues: 100 - pullRequests: true - prWoLabels: false - author: true - unreleased: true - compareLink: true - stripGeneratorNotice: true - verbose: true - - - name: Get next semantic version - id: nextversion - if: ${{ env.do_milestones == 1 }} - uses: WyriHaximus/github-action-next-semvers@v1.2.1 - with: - version: ${{ steps.relversion.outputs.version }} - - - name: Close old milestone - if: ${{ env.do_milestones == 1 }} - uses: WyriHaximus/github-action-close-milestone@master - with: - number: ${{ steps.relversion.outputs.version }} - - - name: Create new minor release milestone - if: ${{ env.do_milestones == 1 }} - uses: WyriHaximus/github-action-create-milestone@v1.2.0 - with: - title: "${{ steps.nextversion.outputs.v_minor }}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create new major release milestone - if: ${{ env.do_milestones == 1 }} - uses: WyriHaximus/github-action-create-milestone@v1.2.0 - with: - title: "${{ steps.nextversion.outputs.v_major }}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/source/faq.rst b/docs/source/faq.rst index 3cee74f..7d9cd0c 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -22,53 +22,3 @@ This prevents the risk of the wrapping turning things into a mess. To force even these instances to get wrapped use ``--force-wrap``. This is being addressed by the constellation of issues related to the various syntaxes used in docstrings. - -Interaction with Black ----------------------- - -Black places a space between the opening triple quotes and the first -character, but only if the first character is a quote. Thus, black turns this: - -.. code-block:: rest - - """"Good" politicians don't exist.""" - -into this: - -.. code-block:: rest - - """ "Good" politicians don't exist.""" - -``docformatter`` will then turn this: - -.. code-block:: rest - - """ "Good" politicians don't exist.""" - -into this: - -.. code-block:: rest - - """"Good" politicians don't exist.""" - -If you pass the ``--pre-summary-space`` option to ``docformatter``, this: - -.. code-block:: rest - - """Good, politicians don't exist.""" - -becomes this: - -.. code-block:: rest - - """ Good, politicians don't exist.""" - -which black will turn into this: - -.. code-block:: rest - - """Good, politicians don't exist.""" - -For now, you'll have to decide whether you like chickens or eggs and then -execute the tools in the order you prefer. This is being addressed by issue -#94.