From a1eed8fcf7ad090024931dfcdfaf0b35dfdef2a7 Mon Sep 17 00:00:00 2001 From: Johannes Laurin Hoermann Date: Tue, 9 Jul 2024 23:33:47 +0200 Subject: [PATCH] DOC, CI: citation.cff, changelog, modernized publication workflow --- .github/workflows/publish.yml | 107 +++++++++++++++++++++++++++++++--- CHANGELOG.rst | 11 ++++ CITATION.cff | 9 +++ 3 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 CITATION.cff diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c0ab3f7..9b0e19e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,8 +8,9 @@ on: - '*' jobs: - build: + build: + name: Build runs-on: ubuntu-latest steps: @@ -17,10 +18,10 @@ jobs: with: fetch-depth: 0 - - name: Set up Python 3.8 + - name: Set up Python 3.12 uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.12 - name: Install requirements run: | @@ -33,19 +34,107 @@ jobs: run: | python -m build - - name: Publish distribution to Test PyPI + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + + publish-to-testpypi: + name: Publish to TestPyPI + needs: + - build + runs-on: ubuntu-latest + + environment: + name: testpypi + url: https://test.pypi.org/p/dserver-retrieve-plugin-mongo + + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Publish distribution 📦 to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.test_pypi_password }} repository-url: https://test.pypi.org/legacy/ verbose: true skip-existing: true + + publish-to-pypi: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/dserver-retrieve-plugin-mongo # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.pypi_password }} verbose: true + + + github-release: + name: >- + Make github release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Sign with Sigstore + uses: sigstore/gh-action-sigstore-python@v2.1.1 + with: + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' \ No newline at end of file diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a0d451c..8931b40 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,17 @@ CHANGELOG This project uses `semantic versioning `_. This change log uses principles from `keep a changelog `_. +[0.4.2] +------- + +Added +^^^^^ + +- Automated github release +- Zenodo integration +- Trusted publishing on PyPI + + [0.4.1] ------- diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..92328e8 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,9 @@ +cff-version: 1.2.0 +authors: +- family-names: Hörmann + given-names: Johannes L. + orcid: 0000-0001-5867-695X +- family-names: Olsson + given-names: Tjelvar S. G. + orcid: 0000-0001-8791-4531 +title: dserver-retrieve-plugin-mongo