diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e043b89 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +on: + push: +name: Release +jobs: + linting: + name: Linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install black ruff + - name: Autoformat with black + run: | + black . + - name: Lint with ruff + run: | + ruff check . --fix + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "style: style fixes by ruff and autoformatting by black" + make_sdist: + needs: ["linting"] + name: Make SDist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build SDist + run: | + pip install build + python -m build + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + release-please: + runs-on: ubuntu-latest + needs: ["linting", "make_sdist"] + if: github.ref == 'refs/heads/main' + steps: + - uses: GoogleCloudPlatform/release-please-action@v4 + id: release + with: + release-type: python + package-name: loopsolver + version-file: loopsolver/version.py + outputs: + release_created: ${{ steps.release.outputs.release_created }} + + upload_to_pypi: + runs-on: "ubuntu-latest" + needs: release-please + if: ${{ needs.release-please.outputs.release_created }} + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip_existing: true + verbose: true