From ca5b5d64236bd1bfe59337959c19a0f8974a7fd8 Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Thu, 27 Jun 2024 15:18:35 -0700 Subject: [PATCH 1/5] release a minor version with all main merges --- .github/workflows/publish.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 567cf437..88098d18 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,24 +3,40 @@ name: publish on: push: branches: [main] - jobs: publish: runs-on: ubuntu-latest environment: release permissions: id-token: write + contents: write # Add this permission to allow pushing the version bump steps: - name: Checkout code uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history for all branches and tags - name: Setup PDM uses: pdm-project/setup-pdm@v2 with: python-version: "3.10" + - name: Install bumpversion + run: pip install bumpversion + + - name: Configure Git + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Apply bumpversion minor + run: | + bumpversion minor + git push + git push --tags + - name: Build package run: pdm build - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From 73f177a877c0c5c5532896f77ec9af6a5d3827f5 Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Thu, 27 Jun 2024 15:23:08 -0700 Subject: [PATCH 2/5] precommit --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 88098d18..407f20fa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,12 +9,12 @@ jobs: environment: release permissions: id-token: write - contents: write # Add this permission to allow pushing the version bump + contents: write # Add this permission to allow pushing the version bump steps: - name: Checkout code uses: actions/checkout@v2 with: - fetch-depth: 0 # Fetch all history for all branches and tags + fetch-depth: 0 # Fetch all history for all branches and tags - name: Setup PDM uses: pdm-project/setup-pdm@v2 @@ -39,4 +39,4 @@ jobs: run: pdm build - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 From e8cda95910c0dd61dc7c4353b62047c5184193ef Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Thu, 27 Jun 2024 15:37:07 -0700 Subject: [PATCH 3/5] open pr first --- .github/workflows/publish.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 407f20fa..b8014666 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,9 +31,18 @@ jobs: - name: Apply bumpversion minor run: | + git checkout -b version-bump bumpversion minor - git push - git push --tags + git push origin version-bump + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + branch: admin/version-bump + title: admin/version-bump + body: "Automated version bump" + base: main + delete-branch: true - name: Build package run: pdm build From 93029ae1dc625044454bf91f496ac4fc2f338d1e Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Fri, 28 Jun 2024 09:52:56 -0700 Subject: [PATCH 4/5] take 2 --- .github/workflows/bump.yml | 53 +++++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 34 ++++------------------ 2 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/bump.yml diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml new file mode 100644 index 00000000..e33d3d84 --- /dev/null +++ b/.github/workflows/bump.yml @@ -0,0 +1,53 @@ +--- +name: bump +on: + pull_request: + types: [closed] + branches: [main] + +jobs: + bump: + # make sure this job runs only when the PR is not a version bump PR and the pr is merged to main (not just closed) + if: github.event.pull_request.title != 'admin/version-bump' && github.event.pull_request.merged == true + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + contents: write # Add this permission to allow pushing the version bump + pull-requests: write + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history for all branches and tags + + - name: Setup PDM + uses: pdm-project/setup-pdm@v2 + with: + python-version: "3.10" + + - name: Install bumpversion + run: pip install bumpversion + + - name: Configure Git + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Delete remote branch # delete the branch if it exists + run: | + git push origin --delete admin/version-bump || true + + - name: Apply bumpversion minor + run: | + git checkout -b admin/version-bump + bumpversion minor + git push origin admin/version-bump + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + branch: admin/version-bump + title: admin/version-bump + body: "Automated version bump" + base: main diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b8014666..51b71663 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,51 +1,29 @@ --- name: publish on: - push: + pull_request: + types: [closed] branches: [main] + jobs: publish: + # only publish when the PR is a version bump PR and the pr is merged to main + if: github.event.pull_request.title == 'admin/version-bump' && github.event.pull_request.merged == true runs-on: ubuntu-latest environment: release permissions: id-token: write - contents: write # Add this permission to allow pushing the version bump steps: - name: Checkout code uses: actions/checkout@v2 - with: - fetch-depth: 0 # Fetch all history for all branches and tags - name: Setup PDM uses: pdm-project/setup-pdm@v2 with: python-version: "3.10" - - name: Install bumpversion - run: pip install bumpversion - - - name: Configure Git - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - - name: Apply bumpversion minor - run: | - git checkout -b version-bump - bumpversion minor - git push origin version-bump - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - branch: admin/version-bump - title: admin/version-bump - body: "Automated version bump" - base: main - delete-branch: true - - name: Build package run: pdm build - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From aefd19424b5f0bed44ccf65dec2e77d114612f79 Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Fri, 28 Jun 2024 09:56:22 -0700 Subject: [PATCH 5/5] precommit --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 51b71663..80b80ef9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,4 +26,4 @@ jobs: run: pdm build - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1