From 3bca05825a43ce12e69bbdf1dd88773ece4c74ee Mon Sep 17 00:00:00 2001 From: Kristjan Eimre Date: Tue, 30 Jul 2024 17:28:50 +0300 Subject: [PATCH] github action: release_and_publish --- .github/workflows/release_and_publish.yml | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/release_and_publish.yml diff --git a/.github/workflows/release_and_publish.yml b/.github/workflows/release_and_publish.yml new file mode 100644 index 0000000..bd1823b --- /dev/null +++ b/.github/workflows/release_and_publish.yml @@ -0,0 +1,42 @@ +--- +name: Release on Github and publish on PyPI + +on: + push: + tags: + # After vMajor.Minor.Patch + - v[0-9]+.[0-9]+.[0-9]+* + +jobs: + release_and_publish: + runs-on: ubuntu-latest + if: github.repository == 'materialscloud-org/optimade-maker' && startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install pypa/build + run: | + python -m pip install build + + - name: Build source distribution + run: python -m build . --wheel --sdist + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + files: | + dist/* + generate_release_notes: true + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }}