From 509f913ce6d4d7b5b1583f3ca53dc7de6ba131a4 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 8 Nov 2024 13:57:42 +0100 Subject: [PATCH 1/2] feat: Separate the Build and Deploy job --- .github/workflows/deploy.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 41c804d..7eda907 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ on: jobs: test: - name: Test and build django-saml2-auth + name: Test django-saml2-auth runs-on: ubuntu-latest strategy: matrix: @@ -55,17 +55,40 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage.lcov + build: + name: Build and Push django-saml2-auth to PyPI + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' }} && ${{ startsWith(github.ref, 'refs/tags') }} + needs: test + env: + python-version: "3.10" + poetry-version: "1.8.3" + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + - name: Set up Python 🐍 + uses: actions/setup-python@v5 + with: + python-version: ${{ env.python-version }} + - name: Install Poetry + uses: abatilo/actions-poetry@v3.0.0 + with: + poetry-version: ${{ env.poetry-version }} + - name: Install xmlsec1 📦 + run: sudo apt-get install xmlsec1 + - name: Install dependencies 📦 + run: | + python -m pip install poetry + poetry install --with dev + poetry self add "poetry-dynamic-versioning[plugin]" - name: Generate CycloneDX SBOM artifacts 📃 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' run: | poetry run cyclonedx-py poetry --all-extras --of JSON -o django-saml2-auth-${{ github.ref_name }}.cyclonedx.json - name: Build and publish package to PyPI 🎉 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' run: | poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} poetry publish --build --skip-existing - name: Create release and add artifacts 🚀 - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && ${{ matrix.versions.pythonVersion }} == '3.10' && ${{ matrix.versions.djangoVersion }} == '4.2.16' uses: softprops/action-gh-release@v2 with: files: | From f7fec20a06f9348f35fe28ba37f2103d5289a44a Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 8 Nov 2024 15:36:01 +0100 Subject: [PATCH 2/2] Change syntax --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7eda907..afee7e2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -58,7 +58,7 @@ jobs: build: name: Build and Push django-saml2-auth to PyPI runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} && ${{ startsWith(github.ref, 'refs/tags') }} + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} needs: test env: python-version: "3.10"