diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d30f5081..6111ae1d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,33 +1,47 @@ name: deploy on: - push: - tags: - - "v*" + workflow_dispatch: + inputs: + version: + description: 'Release version' + required: true + default: '1.2.3' jobs: - deploy: + package: runs-on: ubuntu-latest + env: + SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }} steps: - uses: actions/checkout@v3 + + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@v1.5 + + deploy: + needs: package + runs-on: ubuntu-latest + environment: deploy + permissions: + id-token: write # For PyPI trusted publishers. + contents: write # For tag. + + steps: + - uses: actions/checkout@v3 + + - name: Download Package + uses: actions/download-artifact@v3 with: - # Needed to fetch tags, which are required by setuptools-scm. - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - name: Install build - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: | - python -m build + name: Packages + path: dist + - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.pypi_token }} + uses: pypa/gh-action-pypi-publish@v1.8.5 + + - name: Push tag + run: | + git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }} + git push origin v${{ github.event.inputs.version }} diff --git a/RELEASING.rst b/RELEASING.rst index 5cfd7c01..62ce0030 100644 --- a/RELEASING.rst +++ b/RELEASING.rst @@ -32,14 +32,8 @@ To publish a new release ``X.Y.Z``, the steps are as follows: $ tox -e release -- X.Y.Z -#. Commit and push the branch for review. +#. Commit and push the branch to ``upstream`` and open a PR. -#. Once PR is **green** and **approved**, create and push a tag:: +#. Once the PR is **green** and **approved**, start the ``deploy`` workflow manually from the branch ``release-VERSION``, passing ``VERSION`` as parameter. - $ export VERSION=X.Y.Z - $ git tag v$VERSION release-$VERSION - $ git push git@github.com:pytest-dev/pytest-xdist.git v$VERSION - -That will build the package and publish it on ``PyPI`` automatically. - -#. Merge the release PR to `master`. +#. Merge the release PR to ``master``.