diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 102ada3..88123b8 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -97,6 +97,8 @@ jobs: python-checks: name: Python checks runs-on: ubuntu-latest + outputs: + deploy_env: ${{ steps.detect-deploy-env.outputs.deploy_env }} needs: - pre-commit steps: @@ -148,39 +150,38 @@ jobs: make dist echo "::endgroup::" + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + if: ${{ github.event_name == 'push' || inputs.force_release }} + with: + name: python-package-distributions + path: dist/ + + - name: Detect environment + if: ${{ github.event_name == 'push' || inputs.force_release }} + id: detect-deploy-env + run: | + echo "deploy_env=${{ startsWith(github.ref, 'refs/tags') && 'pypi' || 'testpypi' }}" >> "${GITHUB_OUTPUT}" + deploy-release: name: Deploy Release runs-on: ubuntu-latest - if: github.event_name == 'push' || inputs.force_release + if: ${{ github.event_name == 'push' || inputs.force_release }} + environment: + name: ${{ needs.python-checks.outputs.deploy_env }} + url: ${{ needs.python-checks.outputs.deploy_env == 'pypi' && 'https://pypi.org/project/yamkix/' || 'https://test.pypi.org/project/yamkix/' }} + permissions: + id-token: write needs: - python-checks steps: - - name: Checkout Code - uses: actions/checkout@v4 + - name: Download the distribution packages + uses: actions/download-artifact@v4 with: - fetch-depth: 0 + name: python-package-distributions + path: dist/ - - uses: jdx/mise-action@v2 + - name: Publish package distributions to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - install: true - cache: true - - - name: Restore uv cache - uses: actions/cache@v4 - with: - path: /tmp/.uv-cache - key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} - restore-keys: | - uv-${{ runner.os }}-${{ hashFiles('uv.lock') }} - uv-${{ runner.os }} - - - name: Setup venv - run: | - uv python install - make setup-venv - - - name: Build the distribution - run: | - echo "::group::make dist" - make dist - echo "::endgroup::" + repository-url: ${{ needs.python-checks.outputs.deploy_env == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }}