Skip to content

Commit 2066817

Browse files
committed
Changing to open PR if candidate o.w. just push to pypi
1 parent 457d9c7 commit 2066817

File tree

3 files changed

+89
-67
lines changed

3 files changed

+89
-67
lines changed

.github/workflows/docs.yml

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
name: Release
2929

3030
on:
31+
release:
32+
types: [published]
33+
3134
workflow_dispatch:
3235
inputs:
3336
candidate:
@@ -38,15 +41,15 @@ on:
3841
test_pypi:
3942
description: 'If true, this will push to the test pypi instead of regular.'
4043
type: boolean
41-
default: false
44+
default: true
4245

4346
jobs:
4447
release:
4548
runs-on: ubuntu-latest
4649
steps:
4750
- uses: actions/checkout@v4
4851
with:
49-
ref: main-clone
52+
ref: ${{ inputs.candidate && 'main-clone' || 'stable' }}
5053

5154
- name: Set up Python
5255
uses: actions/setup-python@v5
@@ -58,24 +61,6 @@ jobs:
5861
python -m pip install --upgrade pip
5962
python -m pip install .[dev]
6063
61-
- name: Configure Git user
62-
run: |
63-
git config user.name "SDV Team"
64-
git config user.email "[email protected]"
65-
git remote set-url origin https://x-access-token:${{ secrets.GH_ACCESS_TOKEN }}@github.com/${{ github.repository }}
66-
67-
- name: Merge main to stable and push tags
68-
# if: ${{ !inputs.candidate && !inputs.test_pypi }}
69-
if: ${{ !inputs.candidate }}
70-
run: |
71-
make check-clean
72-
make check-candidate
73-
make check-history
74-
git checkout stable-clone || git checkout -b stable-clone
75-
git merge --no-ff main-clone -m"make release-tag: Merge branch 'main' into stable"
76-
make bumpversion-release
77-
git push --tags origin stable-clone
78-
7964
- name: Create wheel
8065
run: |
8166
make dist
@@ -90,13 +75,35 @@ jobs:
9075
if: ${{ inputs.candidate && !inputs.test_pypi }}
9176
run: |
9277
make bumpversion-candidate
93-
make git-push
94-
95-
- name: Merge to main and bump to next patch
96-
# if: ${{ !inputs.candidate && !inputs.test_pypi }}
97-
if: ${{ !inputs.candidate }}
78+
79+
- name: Get last commit message
80+
if: ${{ inputs.candidate && !inputs.test_pypi }}
81+
id: get_message
9882
run: |
99-
git checkout main-clone
100-
git merge stable-clone
101-
make bumpversion-patch
102-
make git-push
83+
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
84+
echo "commit_message<<EOF" >> $GITHUB_ENV
85+
echo "$COMMIT_MESSAGE" >> $GITHUB_ENV
86+
echo "EOF" >> $GITHUB_ENV
87+
88+
- name: Create PR for candidate
89+
if: ${{ inputs.candidate && !inputs.test_pypi }}
90+
id: bump-candidate-pr
91+
uses: peter-evans/create-pull-request@v4
92+
with:
93+
token: ${{ secrets.GH_ACCESS_TOKEN }}
94+
commit-message: ${{ env.commit_message }}
95+
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
96+
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
97+
title: ${{ env.commit_message }}
98+
body: "This is an auto-generated PR to bump the version to the next release candidate."
99+
branch: bump-release-candidate
100+
branch-suffix: short-commit-hash
101+
base: main
102+
103+
- name: Enable Pull Request Automerge
104+
if: steps.bump-candidate-pr.outputs.pull-request-operation == 'created'
105+
uses: peter-evans/enable-pull-request-automerge@v3
106+
with:
107+
token: ${{ secrets.GH_ACCESS_TOKEN }}
108+
pull-request-number: ${{ steps.bump-candidate-pr.outputs.pull-request-number }}
109+
merge-method: squash

.github/workflows/release.yml

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Release
22

33
on:
4+
release:
5+
types: [published]
6+
47
workflow_dispatch:
58
inputs:
69
candidate:
@@ -11,13 +14,16 @@ on:
1114
test_pypi:
1215
description: 'If true, this will push to the test pypi instead of regular.'
1316
type: boolean
14-
default: false
17+
default: true
1518

1619
jobs:
1720
release:
1821
runs-on: ubuntu-latest
1922
steps:
2023
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ inputs.candidate && 'main-clone' || 'stable' }}
26+
2127
- name: Set up Python
2228
uses: actions/setup-python@v5
2329
with:
@@ -28,40 +34,49 @@ jobs:
2834
python -m pip install --upgrade pip
2935
python -m pip install .[dev]
3036
31-
- name: Configure Git user
32-
run: |
33-
git config user.name "SDV Team"
34-
git config user.email "[email protected]"
35-
git remote set-url origin https://x-access-token:${{ secrets.GH_ACCESS_TOKEN }}@github.com/${{ github.repository }}
36-
37-
- name: Merge main to stable and push tags
38-
if: ${{ !inputs.candidate && !inputs.test_pypi }}
39-
run: |
40-
make check-release
41-
make git-merge-main-stable
42-
make bumpversion-release
43-
make git-push-tags-stable
44-
4537
- name: Create wheel
4638
run: |
47-
make check-main
4839
make dist
4940
5041
- name: Publish a Python distribution to PyPI
5142
uses: pypa/gh-action-pypi-publish@release/v1
5243
with:
5344
password: ${{ inputs.test_pypi && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
54-
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://pypi.org' }}
45+
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
5546

5647
- name: Bump to next candidate
5748
if: ${{ inputs.candidate && !inputs.test_pypi }}
5849
run: |
5950
make bumpversion-candidate
60-
make git-push
61-
62-
- name: Merge to main and bump to next patch
63-
if: ${{ !inputs.candidate && !inputs.test_pypi}}
51+
52+
- name: Get last commit message
53+
if: ${{ inputs.candidate && !inputs.test_pypi }}
54+
id: get_message
6455
run: |
65-
make git-merge-stable-main
66-
make bumpversion-patch
67-
make git-push
56+
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
57+
echo "commit_message<<EOF" >> $GITHUB_ENV
58+
echo "$COMMIT_MESSAGE" >> $GITHUB_ENV
59+
echo "EOF" >> $GITHUB_ENV
60+
61+
- name: Create PR for candidate
62+
if: ${{ inputs.candidate && !inputs.test_pypi }}
63+
id: bump-candidate-pr
64+
uses: peter-evans/create-pull-request@v4
65+
with:
66+
token: ${{ secrets.GH_ACCESS_TOKEN }}
67+
commit-message: ${{ env.commit_message }}
68+
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
69+
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
70+
title: ${{ env.commit_message }}
71+
body: "This is an auto-generated PR to bump the version to the next release candidate."
72+
branch: bump-release-candidate
73+
branch-suffix: short-commit-hash
74+
base: main
75+
76+
- name: Enable Pull Request Automerge
77+
if: steps.bump-candidate-pr.outputs.pull-request-operation == 'created'
78+
uses: peter-evans/enable-pull-request-automerge@v3
79+
with:
80+
token: ${{ secrets.GH_ACCESS_TOKEN }}
81+
pull-request-number: ${{ steps.bump-candidate-pr.outputs.pull-request-number }}
82+
merge-method: squash

Makefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,21 @@ publish: dist publish-confirm ## package and upload a release
170170

171171
.PHONY: git-merge-main-stable
172172
git-merge-main-stable: ## Merge main into stable
173-
git checkout stable-clone || git checkout -b stable-clone
174-
git merge --no-ff main-clone -m"make release-tag: Merge branch 'main' into stable"
173+
git checkout stable || git checkout -b stable
174+
git merge --no-ff main -m"make release-tag: Merge branch 'main' into stable"
175175

176176
.PHONY: git-merge-stable-main
177177
git-merge-stable-main: ## Merge stable into main
178-
git checkout main-clone
179-
git merge stable-clone
178+
git checkout main
179+
git merge stable
180180

181181
.PHONY: git-push
182182
git-push: ## Simply push the repository to github
183183
git push
184184

185185
.PHONY: git-push-tags-stable
186186
git-push-tags-stable: ## Push tags and stable to github
187-
git push --tags origin stable-clone
187+
git push --tags origin stable
188188

189189
.PHONY: bumpversion-release
190190
bumpversion-release: ## Bump the version to the next release
@@ -225,21 +225,21 @@ endif
225225

226226
.PHONY: check-main
227227
check-main: ## Check if we are in main branch
228-
ifneq ($(CURRENT_BRANCH),main-clone)
229-
$(error Please make the release from main branch\n)
230-
endif
228+
ifneq ($(CURRENT_BRANCH),main)
229+
$(error Please make the release from main branch\n)
230+
endif
231231

232232
.PHONY: check-candidate
233233
check-candidate: ## Check if a release candidate has been made
234-
ifeq ($(CURRENT_VERSION),dev0)
235-
$(error Please make a release candidate and test it before atempting a release)
236-
endif
234+
ifeq ($(CURRENT_VERSION),dev0)
235+
$(error Please make a release candidate and test it before atempting a release)
236+
endif
237237

238238
.PHONY: check-history
239239
check-history: ## Check if HISTORY.md has been modified
240-
ifeq ($(CHANGELOG_LINES),0)
241-
$(error Please insert the release notes in HISTORY.md before releasing)
242-
endif
240+
ifeq ($(CHANGELOG_LINES),0)
241+
$(error Please insert the release notes in HISTORY.md before releasing)
242+
endif
243243

244244
.PHONY: check-deps
245245
check-deps: # Dependency targets

0 commit comments

Comments
 (0)