From ced299046b5af008f213f98c9667a4bae1833621 Mon Sep 17 00:00:00 2001 From: Austin Macdonald Date: Tue, 7 May 2024 13:48:57 -0500 Subject: [PATCH] Auto releases with `auto` (#28) * Auto releases with `auto` Fixes: https://github.com/con/duct/issues/7 * Add configfiles --- .autorc | 16 +++++++++++++ .bumpversion.cfg | 7 ++++++ .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ CONTRIBUTING.rst | 21 ++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 .autorc create mode 100644 .bumpversion.cfg create mode 100644 .github/workflows/release.yml create mode 100644 CONTRIBUTING.rst diff --git a/.autorc b/.autorc new file mode 100644 index 00000000..90794c94 --- /dev/null +++ b/.autorc @@ -0,0 +1,16 @@ +{ + "onlyPublishWithReleaseLabel": true, + "baseBranch": "master", + "author": "auto ", + "noVersionPrefix": false, + "plugins": [ + "git-tag", + [ + "exec", + { + "afterChangelog": "bump2version \"$(printf '%s\n' \"$ARG_0\" | jq -r .bump)\"", + "afterRelease": "python -m build && twine upload dist/*" + } + ] + ] +} diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 00000000..72bf568c --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,7 @@ +[bumpversion] +current_version = 0.0.1 +commit = True +message = [skip ci] Bump version: {current_version} → {new_version} +tag = False + +[bumpversion:file:src/duct.py] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..6a91f942 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Auto-release on PR merge + +on: + # ATM, this is the closest trigger to a PR merging + push: + branches: + - master + +jobs: + auto-release: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download auto + run: | + #curl -vL -o - "$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/latest | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')" | gunzip > ~/auto + # Initially pin to 10.16.1 so we don't break if & when + # is fixed. + # Needed to progress to 11.1.6 (current release) to have + # a fix for https://github.com/intuit/auto/issues/2432, + # while 1778 was still open/left without comment. + wget -O- https://github.com/intuit/auto/releases/download/v11.1.6/auto-linux.gz | gunzip > ~/auto + chmod a+x ~/auto + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '^3.8' + + - name: Install Python dependencies + run: python -m pip install build bump2version twine + + - name: Create release + run: ~/auto shipit + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + +# vim:set sts=2: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 00000000..620a395b --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,21 @@ +Releases and Changelog +---------------------- + +We use the `auto `_ tool to generate the changelog and automatically release the project. + +`auto` is used in by GitHub actions, which monitors the labels on the pull request. +This automation can add entries to the changelog, cut releases, and +push new images to `dockerhub `_. + +The following pull request labels are respected: + + * major: Increment the major version when merged + * minor: Increment the minor version when merged + * patch: Increment the patch version when merged + * skip-release: Preserve the current version when merged + * release: Create a release when this pr is merged + * internal: Changes only affect the internal API + * documentation: Changes only affect the documentation + * tests: Add or improve existing tests + * dependencies: Update one or more dependencies version + * performance: Improve performance of an existing feature