diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 211984f..88c679f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,9 +30,14 @@ jobs: else environment_name="" fi - timestamp="$(date -Iseconds)" - url="https://api.github.com/repos/${{ github.repository }}/deployments" - environment_url="$url?timestamp=$timestamp" + if [ "$environment_name" = "PyPI" ]; then + url="https://pypi.org/project/${GITHUB_REPOSITORY##*/}/" + environment_url="$url$GITHUB_REF_NAME/" + else + timestamp="$(date -Iseconds)" + url="https://api.github.com/repos/$GITHUB_REPOSITORY/deployments" + environment_url="$url?timestamp=$timestamp" + fi echo "environment-name=$environment_name" >>"$GITHUB_OUTPUT" echo "environment-url=$environment_url" >>"$GITHUB_OUTPUT" - name: Create annotation for deployment environment @@ -41,9 +46,6 @@ jobs: ci: runs-on: ubuntu-latest needs: [setup] - environment: - name: ${{ needs.setup.outputs.environment-name }} - url: ${{ needs.setup.outputs.environment-url }}&python=${{ matrix.python-version }} permissions: id-token: write strategy: @@ -130,15 +132,37 @@ jobs: run: hatch run ${{ env.HATCH_ENV }}:coverage report - name: Build Python package run: hatch build - - name: Publish Python package to PyPI + - name: Upload Python package artifacts if: > github.ref_type == 'tag' && matrix.python-version == '3.12' && needs.setup.outputs.environment-name == 'PyPI' + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + name: fastenv-${{ github.ref_name }} + path: dist + pypi: + environment: + name: ${{ needs.setup.outputs.environment-name }} + url: ${{ needs.setup.outputs.environment-url }} + if: github.ref_type == 'tag' && needs.setup.outputs.environment-name == 'PyPI' + needs: [setup, ci] + permissions: + id-token: write + runs-on: ubuntu-latest + steps: + - name: Download Python package artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + name: fastenv-${{ github.ref_name }} + path: dist + - name: Publish Python package to PyPI uses: pypa/gh-action-pypi-publish@release/v1.8 changelog: if: github.ref_type == 'tag' - needs: [ci] + needs: [ci, pypi] permissions: contents: write pull-requests: write