From b1b821d7cc0151635a0787ac26254f92a3b422b2 Mon Sep 17 00:00:00 2001 From: Phuong Nguyen Date: Wed, 20 Nov 2024 10:20:59 +0200 Subject: [PATCH] ci: Use common CI/CD pipeline --- .github/workflows/cicd.yml | 108 ++++--------------------------------- 1 file changed, 10 insertions(+), 98 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index efd9116..443d258 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -7,113 +7,25 @@ on: jobs: tests: - name: Run tests and checks - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Build Docker image - run: | - docker build -t django2pydantic . - - - name: Run tests - run: | - docker run --volume $(pwd):/app --workdir /app --rm django2pydantic nox -s noop - + uses: NextGenContributions/cicd-pipeline/.github/workflows/test.yml@main + with: + project_name: django2pydantic release: - # If main branch is updated, we want to release the package. - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - needs: - - tests - concurrency: release - runs-on: ubuntu-latest - + uses: NextGenContributions/cicd-pipeline/.github/workflows/release.yml@main + with: + release_branch: main + needs: tests permissions: id-token: write contents: write - continue-on-error: true - - outputs: - released: ${{ steps.release.outputs.released }} - - steps: - # Note: we need to checkout the repository at the workflow sha in case during the workflow - # the branch was updated. To keep PSR working with the configured release branches, - # we force a checkout of the desired release branch but at the workflow sha HEAD. - - name: Setup | Checkout Repository at workflow sha - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.sha }} - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - - name: Setup | Force correct release branch on workflow sha - run: | - git checkout -B ${{ github.ref_name }} ${{ github.sha }} - - - name: Action | Semantic Version Release - id: release - # Adjust tag with desired version if applicable. - uses: python-semantic-release/python-semantic-release@v9.14.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - git_committer_name: "github-actions" - git_committer_email: "actions@users.noreply.github.com" - root_options: "--strict" - - - name: Build | Build the distribution packages - run: >- - python3 -m build - - - name: Store the distribution packages - uses: actions/upload-artifact@v4 - with: - path: dist/ - name: python-package-distributions - - - name: Publish | Upload to GitHub Release Assets - uses: python-semantic-release/publish-action@v9.14.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ steps.release.outputs.tag }} - - publish-to-testpypi: - name: Publish Python 🐍 distribution 📦 to TestPyPI + uses: NextGenContributions/cicd-pipeline/.github/workflows/publish-pypi.yml@main + with: + project_name: django2pydantic if: ${{ needs.release.outputs.released == 'true' }} needs: - release - runs-on: ubuntu-latest - - environment: - name: testpypi - url: https://test.pypi.org/p/django2pydantic - permissions: id-token: write # IMPORTANT: mandatory for trusted publishing - - steps: - - name: Download all the dists - uses: actions/download-artifact@v4 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/