django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
34 stars 30 forks source link

feat: Add pypi actions #335

Closed fsbraun closed 1 year ago

fsbraun commented 1 year ago

Description

Adds actions for pypi publication.

Related resources

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #335 (19d40ff) into master (3df6225) will not change coverage. The diff coverage is 100.00%.

:exclamation: Current head 19d40ff differs from pull request most recent head 1b248a7. Consider uploading reports for the commit 1b248a7 to get more accurate results

@@           Coverage Diff           @@
##           master     #335   +/-   ##
=======================================
  Coverage   90.93%   90.93%           
=======================================
  Files          72       72           
  Lines        2536     2536           
  Branches      358      358           
=======================================
  Hits         2306     2306           
  Misses        170      170           
  Partials       60       60           
Impacted Files Coverage Δ
djangocms_versioning/__init__.py 100.00% <100.00%> (ø)
marksweb commented 1 year ago

To fix the ruff error, the pyupgrade part of the config needs removing

marksweb commented 1 year ago

@fsbraun because this is going to be new to pypi, I'd need a generic token so this has got me thinking about this new trusted publishing method of deployment.

Looking at the action repo, it's actually a simpler workflow to work this way so I'd like to swap to this style.

https://github.com/pypa/gh-action-pypi-publish#trusted-publishing

It looks like the setup is this simple for live;

name: Publish Python 🐍 distributions 📦 to pypi

on:
  release:
    types:
      - published

jobs:
  build-n-publish:
    name: Build and publish Python 🐍 distributions 📦 to pypi
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/djangocms-versioning
    permissions:
      id-token: write
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.10
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'

    - name: Install pypa/build
      run: >-
        python -m
        pip install
        build
        --user
    - name: Build a binary wheel and a source tarball
      run: >-
        python -m
        build
        --sdist
        --wheel
        --outdir dist/
        .

    - name: Publish distribution 📦 to PyPI
      if: startsWith(github.ref, 'refs/tags')
      uses: pypa/gh-action-pypi-publish@release/v1

And the test release...

name: Publish Python 🐍 distributions 📦 to TestPyPI

on:
  push:
    branches:
      - master

jobs:
  build-n-publish:
    name: Build and publish Python 🐍 distributions 📦 to TestPyPI
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/djangocms-versioning
    permissions:
      id-token: write
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.10
      uses: actions/setup-python@v4
      with:
        python-version: '3.10'

    - name: Install pypa/build
      run: >-
        python -m
        pip install
        build
        --user
    - name: Build a binary wheel and a source tarball
      run: >-
        python -m
        build
        --sdist
        --wheel
        --outdir dist/
        .

    - name: Publish distribution 📦 to Test PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        repository-url: https://test.pypi.org/legacy/
        skip_existing: true
fsbraun commented 1 year ago

@marksweb Done!

fsbraun commented 1 year ago

@marksweb Can you mark your comment as resolved so that I can merge it?