Release #32
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 | |
| permissions: | |
| contents: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: Select release type | |
| required: true | |
| type: choice | |
| options: | |
| - alpha | |
| - beta | |
| - dev | |
| - patch | |
| - minor | |
| - rc | |
| - major | |
| release_name: | |
| description: "Optional: Release Name" | |
| required: false | |
| type: string | |
| release_body: | |
| description: "Optional: Release Body" | |
| required: false | |
| type: string | |
| jobs: | |
| determine-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| RELEASE_TYPE: ${{ steps.release_type.outputs.RELEASE_TYPE }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Determine version bump | |
| if: github.event_name == 'workflow_dispatch' | |
| id: release_type | |
| run: | | |
| echo "RELEASE_TYPE=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT | |
| bumpversion: | |
| needs: determine-version | |
| runs-on: "ubuntu-latest" | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install the project | |
| run: uv sync --all-extras --dev | |
| - name: Bump version using hatch | |
| run: | | |
| uvx hatch version ${{ needs.determine-version.outputs.RELEASE_TYPE }} | |
| echo "NEW_VERSION=$(uvx hatch version)" >> $GITHUB_ENV | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v6 | |
| id: import-gpg | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASS }} | |
| git_user_signingkey: true | |
| git_commit_gpgsign: true | |
| git_tag_gpgsign: true | |
| - name: Commit new version | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add src/r2x/__version__.py | |
| git commit -S -m "Bump version to v${{ env.NEW_VERSION}}" | |
| git tag -s v${{ env.NEW_VERSION}} -m "Release version ${{ env.NEW_VERSION }}" | |
| git push origin main --tags | |
| - name: Export new version | |
| id: version | |
| run: echo "version=$(uvx hatch version)" >> $GITHUB_OUTPUT | |
| publish-testpypi: | |
| needs: bumpversion | |
| runs-on: ubuntu-latest | |
| env: | |
| python_version: 3.11 | |
| TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Set up Python ${{ env.python_version }} | |
| run: uv python install ${{ env.python_version }} | |
| - name: Build and Publish to TestPyPI | |
| run: | | |
| uv build | |
| uv publish --publish-url https://test.pypi.org/legacy/ --username __token__ --token $TEST_PYPI_TOKEN | |
| publish-pypi: | |
| needs: [bumpversion, publish-testpypi] | |
| runs-on: ubuntu-latest | |
| env: | |
| python_version: 3.11 | |
| PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| - name: Set up Python ${{ env.python_version }} | |
| run: uv python install ${{ env.python_version }} | |
| - name: Build and Publish to TestPyPI | |
| run: | | |
| uv build | |
| uv publish --token $PYPI_TOKEN | |
| - name: Create GitHub release | |
| run: | | |
| gh release create "v${needs.bumpversion.outputs.version}" -t "v${needs.bumpversion.outputs.version}" --generate-notes |