From 57b9de60004474c7cb046ef83e97d5e4fa2ca564 Mon Sep 17 00:00:00 2001 From: Tom Holland Date: Wed, 1 Jan 2025 19:27:02 +0000 Subject: [PATCH] chore: replace auto publishing with workflow to create an rc PR --- .../workflows/create-release-candidate.yml | 52 +++++++++++++ .github/workflows/publish-to-testpypi.yml | 73 ------------------- 2 files changed, 52 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/create-release-candidate.yml delete mode 100644 .github/workflows/publish-to-testpypi.yml diff --git a/.github/workflows/create-release-candidate.yml b/.github/workflows/create-release-candidate.yml new file mode 100644 index 00000000..1126a15c --- /dev/null +++ b/.github/workflows/create-release-candidate.yml @@ -0,0 +1,52 @@ +name: "Create Release Candidate" + +on: + push: + branches: + - main + +jobs: + create-rc: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history + fetch-tags: true # Fetch all tags + ref: ${{ github.head_ref || github.ref_name }} # Correct branch reference + + - name: Install uv & dependencies + uses: astral-sh/setup-uv@v5 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version-file: "pyproject.toml" + + - name: Install project + run: | + uv sync --all-extras --group format --group test --group docs --group external-integration + + - name: Bump version + id: bump + run: | + uv run semantic-release version --no-commit --no-tag --skip-build + VERSION=$(grep -o '".*"' pyprobe/_version.py | sed 's/"//g') + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Update uv lockfile + run: uv lock --upgrade-package pyprobe-data + + - name: Open Pull Request + uses: peter-evans/create-pull-request@v4 + with: + branch: release-candidates/rc-${{ steps.bump.outputs.version }} + title: "Release Candidate ${{ steps.bump.outputs.version }}" + commit-message: "chore: release candidate ${{ steps.bump.outputs.version }} [skip ci]" + base: main + body: "This PR is the release candidate for version ${{ steps.bump.outputs.version }}." \ No newline at end of file diff --git a/.github/workflows/publish-to-testpypi.yml b/.github/workflows/publish-to-testpypi.yml deleted file mode 100644 index 3381b8d8..00000000 --- a/.github/workflows/publish-to-testpypi.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: "Publish to TestPyPI" - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - Build: - runs-on: ubuntu-latest - - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing - contents: write # for git operations - - environment: - name: testpypi - url: https://test.pypi.org/p/PyProBE-Data - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Fetch all history - fetch-tags: true # Fetch all tags - ref: ${{ github.head_ref || github.ref_name }} # Correct branch reference - - - name: Install uv - uses: astral-sh/setup-uv@v5 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version-file: "pyproject.toml" - - - name: Install the project - run: uv sync --all-extras --group format --group test --group docs --group external-integration - - - name: Run semantic-release - id: semrel - run: | - uv run semantic-release version \ - --prerelease \ - --no-commit \ - --no-tag \ - --skip-build - - - name: Update uv lockfile - run: uv lock --upgrade-package pyprobe-data - - - name: Get version - id: version - run: | - VERSION=$(grep -o '".*"' pyprobe/_version.py | sed 's/"//g') - echo "version=$VERSION" >> $GITHUB_OUTPUT - - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: Update version [skip ci] - tagging_message: "v${{ steps.version.outputs.version }}" - - - name: Build - run: uv build - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: dist - path: dist/ - retention-days: 5 # Keep artifacts for 5 days - - - name: Publish - run: uv publish --publish-url https://test.pypi.org/legacy/ --trusted-publishing always \ No newline at end of file