ci: Minor adjustment to test automated releases #2
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: Publish Release | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| UV_VERSION: "0.7.13" | |
| AUTO_VERSION: "11.3.6" | |
| GH_ACTIONS_BOT_NAME: "github-actions[bot]" | |
| GH_ACTIONS_BOT_EMAIL: "github-actions[bot]@users.noreply.github.com" | |
| jobs: | |
| canary-build: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'auto:release') | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Install Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: ${{ env.UV_VERSION }} | |
| enable-cache: true | |
| python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON | |
| cache-dependency-glob: | | |
| pyproject.toml | |
| uv.lock | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen | |
| - name: Check that package can be built | |
| run: uv build | |
| release: | |
| needs: canary-build | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'auto:release') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Download and install auto | |
| run: | | |
| curl -L https://github.com/intuit/auto/releases/download/v${{ env.AUTO_VERSION }}/auto-linux.gz -o auto-linux.gz | |
| gunzip auto-linux.gz | |
| chmod +x auto-linux | |
| sudo mv auto-linux /usr/local/bin/auto | |
| auto --version | |
| - name: Resolve release version | |
| id: latest_release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| RAW_VERSION="$(auto latest --name "${GH_ACTIONS_BOT_NAME}" --email "${GH_ACTIONS_BOT_EMAIL}" --dry-run --quiet | tail -n1 | tr -d '\r')" | |
| VERSION="${RAW_VERSION#v}" | |
| if [ -z "$VERSION" ]; then | |
| echo "Could not resolve release version" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Resolved version: $VERSION" | |
| - name: Apply release version to pyproject.toml | |
| run: | | |
| VERSION="${{ steps.latest_release.outputs.version }}" | |
| sed -i "s/^version = \".*\"$/version = \"${VERSION}\"/" pyproject.toml | |
| grep '^version = ' pyproject.toml | |
| - name: Commit and push pyproject version update | |
| run: | | |
| if git diff --quiet -- pyproject.toml; then | |
| echo "No pyproject version change to commit." | |
| exit 0 | |
| fi | |
| git config user.name "${GH_ACTIONS_BOT_NAME}" | |
| git config user.email "${GH_ACTIONS_BOT_EMAIL}" | |
| git add pyproject.toml | |
| git commit -m "chore(release): set pyproject version to ${{ steps.latest_release.outputs.version }}" | |
| # git push origin HEAD:main | |
| - name: Create Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| auto create-labels | |
| auto latest --name "${GH_ACTIONS_BOT_NAME}" --email "${GH_ACTIONS_BOT_EMAIL}" --dry-run | |
| build-and-publish: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'auto:release') | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Install Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: ${{ env.UV_VERSION }} | |
| enable-cache: true | |
| python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON | |
| cache-dependency-glob: | | |
| pyproject.toml | |
| uv.lock | |
| - name: Install dependencies | |
| run: | | |
| uv sync --frozen | |
| - name: Build package | |
| run: uv build | |
| - name: Publish to PyPI | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI }} | |
| run: echo "uv publish" # TODO: call uv publish when ready |