From 92dd52874093ab364d42fb023b0671f73405e980 Mon Sep 17 00:00:00 2001 From: Ferdinand Hoffmann Date: Wed, 6 Dec 2023 09:26:22 +0100 Subject: [PATCH] Switch to simplified release workflow --- .github/workflows/create_release.yml | 59 ------------------- .github/workflows/publish_release_on_pypi.yml | 30 ---------- .../workflows/publish_release_packages.yml | 44 ++++++++++++++ pyproject.toml | 2 +- 4 files changed, 45 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/create_release.yml delete mode 100644 .github/workflows/publish_release_on_pypi.yml create mode 100644 .github/workflows/publish_release_packages.yml diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml deleted file mode 100644 index e0153d8..0000000 --- a/.github/workflows/create_release.yml +++ /dev/null @@ -1,59 +0,0 @@ -on: - push: - # Sequence of patterns matched against refs/tags - tags: - - '*' - -name: Create release and attach sdist - -jobs: - build: - name: Build sdist and create release draft - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install build - - name: Build sdist - run: | - python -m build --sdist - - name: Get version from tag - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - - name: Check package version (compare package version with tag) - id: check_package_version - shell: python - run: | - from packaging.version import parse - from setuptools.config import read_configuration - package_version = read_configuration('setup.cfg')['metadata']['version'] - if parse(package_version) != parse('${{ steps.get_version.outputs.VERSION }}'): - print(f'version mismatch: {package_version} (package) vs ${{ steps.get_version.outputs.VERSION }} (tag)') - exit(1) - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: true - prerelease: false - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./dist/django-ses-sns-tracker-${{ steps.get_version.outputs.VERSION }}.tar.gz - asset_name: django-ses-sns-tracker-${{ steps.get_version.outputs.VERSION }}.tar.gz - asset_content_type: application/tar+gzip diff --git a/.github/workflows/publish_release_on_pypi.yml b/.github/workflows/publish_release_on_pypi.yml deleted file mode 100644 index 49c6394..0000000 --- a/.github/workflows/publish_release_on_pypi.yml +++ /dev/null @@ -1,30 +0,0 @@ -on: - release: - types: [published] - -name: Upload release to PyPI -jobs: - generate: - name: Create release-artifacts - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install build dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build sdist & wheel - run: | - python -m build --sdist --wheel - - name: Publish a Python distribution to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} - # password: ${{ secrets.TEST_PYPI_API_TOKEN }} - # repository_url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/publish_release_packages.yml b/.github/workflows/publish_release_packages.yml new file mode 100644 index 0000000..e57f880 --- /dev/null +++ b/.github/workflows/publish_release_packages.yml @@ -0,0 +1,44 @@ +on: + release: + types: [published] + +name: Upload packages to PyPI and GitHub release on release publish +jobs: + upload-packages: + name: Create release-artifacts + runs-on: ubuntu-latest + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + # required by ncipollo/release-action@v1 + contents: write + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: '3.12' + - name: Install build dependencies + run: | + pipx install poetry + - name: Check package version (compare package version with tag) + run: | + if [[ ! "$(poetry version -s)" = "${{ github.event.release.tag_name}}" ]]; then + echo "version mismatch: $(poetry version -s) (package) vs ${{ github.event.release.tag_name }} (tag)" + exit 1 + fi + - name: Build sdist & wheel + run: | + poetry build + - name: Update release + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + omitPrereleaseDuringUpdate: true + artifacts: "dist/*" + - name: Publish python distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + # uses trusted publishing (no username & password required) diff --git a/pyproject.toml b/pyproject.toml index bb03d8a..1dc4d28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-ses-sns-tracker" -version = "3.0.0" +version = "4.0.0.dev5" description = "Simple wrapper around django-ses to receive and persist sns event data" authors = ["anfema GmbH "] license = "MIT"