release 21.2.0 #42
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: ["*.*.*"] | |
| env: | |
| dists-artifact-name: python-package-distributions | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install the latest version of uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| run: uv python install 3.14 | |
| - name: Build sdist and wheel | |
| run: uv build --python 3.14 --python-preference only-managed --sdist --wheel . --out-dir dist | |
| - name: Build zipapp | |
| run: uv tool run --with tox-uv tox r -e zipapp | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ env.dists-artifact-name }} | |
| path: dist/* | |
| - name: Store the zipapp | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: virtualenv-zipapp | |
| path: virtualenv.pyz | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-24.04 | |
| environment: | |
| name: release | |
| url: https://pypi.org/project/virtualenv/${{ github.ref_name }} | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ${{ env.dists-artifact-name }} | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@v1.13.0 | |
| with: | |
| attestations: true | |
| - name: Download the zipapp | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: virtualenv-zipapp | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| generate_release_notes: true | |
| files: virtualenv.pyz | |
| - name: Update get-virtualenv | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} | |
| run: | | |
| git clone https://x-access-token:${GH_TOKEN}@github.com/pypa/get-virtualenv.git | |
| cp virtualenv.pyz get-virtualenv/public/virtualenv.pyz | |
| echo -n "${{ github.ref_name }}" > get-virtualenv/public/version.txt | |
| cd get-virtualenv | |
| user_info=$(gh api /user) | |
| git config user.name "$(echo "$user_info" | jq -r '.name // .login')" | |
| git config user.email "$(echo "$user_info" | jq -r '.id')+$(echo "$user_info" | jq -r '.login')@users.noreply.github.com" | |
| git add public/virtualenv.pyz public/version.txt | |
| git commit -m "update virtualenv to ${{ github.ref_name }}" | |
| git push origin main | |
| rollback: | |
| if: ${{ always() && needs.build.result == 'success' && needs.publish.result == 'failure' }} | |
| needs: | |
| - build | |
| - publish | |
| runs-on: ubuntu-24.04 | |
| environment: release | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GH_RELEASE_TOKEN }} | |
| - name: Delete GitHub Release if created | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} | |
| run: gh release delete "${{ github.ref_name }}" --yes --cleanup-tag || true | |
| - name: Delete remote tag | |
| run: git push origin --delete "${{ github.ref_name }}" || true | |
| - name: Reset release commit on main | |
| run: | | |
| git checkout main | |
| git reset --hard HEAD~1 | |
| git push origin main --force | |
| - name: Rollback get-virtualenv if updated | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} | |
| run: | | |
| git clone https://x-access-token:${GH_TOKEN}@github.com/pypa/get-virtualenv.git | |
| cd get-virtualenv | |
| current_version=$(cat public/version.txt) | |
| if [ "$current_version" = "${{ github.ref_name }}" ]; then | |
| gh release delete "$current_version" --yes --cleanup-tag || true | |
| git reset --hard HEAD~1 | |
| git push origin main --force | |
| fi |