From f73b2284bd1da4f2b2aa3f97cfdfa1ecc59ddb18 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Thu, 10 Aug 2023 22:29:38 +0200 Subject: [PATCH] ci: release with semantic-release --- .github/workflows/release.yml | 14 ++++++++++++++ release.config.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 release.config.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c06ca62 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,14 @@ +name: Release to PyPI + +on: + workflow_dispatch + +jobs: + release: + uses: lars-reimann/.github/.github/workflows/poetry-pypi-reusable.yml@main + with: + working-directory: . + python-version: "3.10" + secrets: + GITHUB_PAT: ${{ secrets.PAT }} + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/release.config.js b/release.config.js new file mode 100644 index 0000000..867de26 --- /dev/null +++ b/release.config.js @@ -0,0 +1,35 @@ +// Based on https://github.com/bjoluc/semantic-release-config-poetry/blob/main/release.config.js + +const PYPI_REPOSITORY = 'https://upload.pypi.org/legacy/'; + +module.exports = { + branches: ['main'], + plugins: [ + ['@semantic-release/commit-analyzer', { preset: 'conventionalcommits' }], + ['@semantic-release/release-notes-generator', { preset: 'conventionalcommits' }], + ['@semantic-release/changelog', { changelogFile: 'docs/CHANGELOG.md' }], + [ + '@semantic-release/exec', + { + verifyConditionsCmd: `if [ 403 != $(curl -X POST -F ':action=file_upload' -u __token__:$PYPI_TOKEN -s -o /dev/null -w '%{http_code}' ${PYPI_REPOSITORY}) ]; then (exit 0); else (echo 'Authentication error. Please check the PYPI_TOKEN environment variable.' && exit 1); fi`, + prepareCmd: 'poetry version ${nextRelease.version}', + publishCmd: 'poetry publish --build --username __token__ --password $PYPI_TOKEN --no-interaction -vvv', + }, + ], + [ + '@semantic-release/github', + { + assets: [ + { path: 'dist/*.tar.gz', label: 'sdist' }, + { path: 'dist/*.whl', label: 'wheel' }, + ], + }, + ], + [ + '@semantic-release/git', + { + assets: ['pyproject.toml', 'docs/CHANGELOG.md'], + }, + ], + ], +};