Skip to content

Commit 0743fde

Browse files
gshenirwedge
andauthored
Add workflow to release DeepEcho on PyPI (#157)
Co-authored-by: Roy Wedge <[email protected]>
1 parent 9292b9c commit 0743fde

File tree

9 files changed

+303
-51
lines changed

9 files changed

+303
-51
lines changed

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
types: [opened, reopened]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
lint:
1014
runs-on: ubuntu-latest

.github/workflows/readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
types: [opened, reopened]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
readme:
1014
runs-on: ${{ matrix.os }}

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [published]
5+
branches:
6+
- main
7+
- stable
8+
9+
workflow_dispatch:
10+
inputs:
11+
candidate:
12+
description: 'Release candidate.'
13+
required: true
14+
type: boolean
15+
default: true
16+
test_pypi:
17+
description: 'Test PyPI.'
18+
type: boolean
19+
default: false
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
id-token: write
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
ref: ${{ inputs.candidate && 'main' || 'stable' }}
29+
30+
- name: Set up latest Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version-file: 'pyproject.toml'
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
python -m pip install .[dev]
39+
40+
- name: Create wheel
41+
run: |
42+
make dist
43+
44+
- name: Publish a Python distribution to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
repository-url: ${{ inputs.test_pypi && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
48+
49+
- name: Bump version to next candidate
50+
if: ${{ inputs.candidate && !inputs.test_pypi }}
51+
run: |
52+
git config user.name "github-actions[bot]"
53+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
54+
bump-my-version bump candidate --no-tag --no-commit
55+
56+
- name: Create pull request
57+
if: ${{ inputs.candidate && !inputs.test_pypi }}
58+
id: cpr
59+
uses: peter-evans/create-pull-request@v4
60+
with:
61+
token: ${{ secrets.GH_ACCESS_TOKEN }}
62+
commit-message: bumpversion-candidate
63+
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
64+
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
65+
signoff: false
66+
delete-branch: true
67+
title: Automated Bump Version Candidate
68+
body: "This is an auto-generated PR that bumps the version to the next candidate."
69+
branch: bumpversion-candidate-update
70+
branch-suffix: short-commit-hash
71+
add-paths: |
72+
deepecho/__init__.py
73+
pyproject.toml
74+
draft: false
75+
base: main
76+
77+
- name: Enable Pull Request Automerge
78+
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
79+
run: gh pr merge "${{ steps.cpr.outputs.pull-request-number }}" --squash --auto
80+
env:
81+
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}

.github/workflows/unit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request:
66
types: [opened, reopened]
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
unit:
1014
runs-on: ${{ matrix.os }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
tests/readme_test/README.md
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]

Makefile

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ clean-coverage: ## remove coverage artifacts
5555

5656
.PHONY: clean-test
5757
clean-test: ## remove test artifacts
58-
rm -fr .tox/
5958
rm -fr .pytest_cache
6059

6160
.PHONY: clean
@@ -76,6 +75,9 @@ install-test: clean-build clean-pyc ## install the package and test dependencies
7675
install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development
7776
pip install -e .[dev]
7877

78+
.PHONY: install-readme
79+
install-readme: clean-build clean-pyc ## install the package in editable mode and readme dependencies for developement
80+
pip install -e .[readme]
7981

8082
# LINT TARGETS
8183

@@ -116,10 +118,6 @@ test: test-unit test-integration test-readme test-tutorials ## test everything t
116118
.PHONY: test-devel
117119
test-devel: lint ## test everything that needs development dependencies
118120

119-
.PHONY: test-all
120-
test-all: ## run tests on every Python version with tox
121-
tox -r
122-
123121
.PHONY: coverage
124122
coverage: ## check code coverage quickly with the default Python
125123
coverage run --source deepecho -m pytest
@@ -129,11 +127,6 @@ coverage: ## check code coverage quickly with the default Python
129127

130128

131129
# RELEASE TARGETS
132-
133-
.PHONY: git-push
134-
git-push: ## Simply push the repository to github
135-
git push
136-
137130
.PHONY: dist
138131
dist: clean ## builds source and wheel package
139132
python -m build --wheel --sdist
@@ -154,41 +147,47 @@ publish-test: dist publish-confirm ## package and upload a release on TestPyPI
154147
publish: dist publish-confirm ## package and upload a release
155148
twine upload dist/*
156149

157-
.PHONY: bumpversion-release
158-
bumpversion-release: ## Merge main to stable and bumpversion release
150+
.PHONY: git-merge-main-stable
151+
git-merge-main-stable: ## Merge main into stable
159152
git checkout stable || git checkout -b stable
160153
git merge --no-ff main -m"make release-tag: Merge branch 'main' into stable"
161-
bump-my-version bump release
154+
155+
.PHONY: git-merge-stable-main
156+
git-merge-stable-main: ## Merge stable into main
157+
git checkout main
158+
git merge stable
159+
160+
.PHONY: git-push
161+
git-push: ## Simply push the repository to github
162+
git push
163+
164+
.PHONY: git-push-tags-stable
165+
git-push-tags-stable: ## Push tags and stable to github
162166
git push --tags origin stable
163167

164-
.PHONY: bumpversion-release-test
165-
bumpversion-release-test: ## Merge main to stable and bumpversion release
166-
git checkout stable || git checkout -b stable
167-
git merge --no-ff main -m"make release-tag: Merge branch 'main' into stable"
168+
.PHONY: bumpversion-release
169+
bumpversion-release: ## Bump the version to the next release
168170
bump-my-version bump release --no-tag
169-
@echo git push --tags origin stable
170171

171172
.PHONY: bumpversion-patch
172-
bumpversion-patch: ## Merge stable to main and bumpversion patch
173-
git checkout main
174-
git merge stable
175-
bump-my-version bump patch --no-tag
176-
git push
173+
bumpversion-patch: ## Bump the version to the next patch
174+
bump-my-version bump --no-tag patch
177175

178176
.PHONY: bumpversion-candidate
179177
bumpversion-candidate: ## Bump the version to the next candidate
180178
bump-my-version bump candidate --no-tag
181179

182180
.PHONY: bumpversion-minor
183181
bumpversion-minor: ## Bump the version the next minor skipping the release
184-
bump-my-version bump minor --no-tag
182+
bump-my-version bump --no-tag minor
185183

186184
.PHONY: bumpversion-major
187185
bumpversion-major: ## Bump the version the next major skipping the release
188-
bump-my-version bump major --no-tag
186+
bump-my-version bump --no-tag major
189187

190188
.PHONY: bumpversion-revert
191189
bumpversion-revert: ## Undo a previous bumpversion-release
190+
git tag --delete $(shell git tag --points-at HEAD)
192191
git checkout main
193192
git branch -D stable
194193

@@ -231,13 +230,20 @@ check-release: check-clean check-candidate check-main check-history ## Check if
231230
@echo "A new release can be made"
232231

233232
.PHONY: release
234-
release: check-release bumpversion-release publish bumpversion-patch
233+
release: check-release git-merge-main-stable bumpversion-release git-push-tags-stable \
234+
git-merge-stable-main bumpversion-patch git-push
235235

236236
.PHONY: release-test
237-
release-test: check-release bumpversion-release-test publish-test bumpversion-revert
237+
release-test: check-release git-merge-main-stable bumpversion-release bumpversion-revert
238238

239239
.PHONY: release-candidate
240240
release-candidate: check-main publish bumpversion-candidate git-push
241241

242242
.PHONY: release-candidate-test
243243
release-candidate-test: check-clean check-main publish-test
244+
245+
.PHONY: release-minor
246+
release-minor: check-release bumpversion-minor release
247+
248+
.PHONY: release-major
249+
release-major: check-release bumpversion-major release

0 commit comments

Comments
 (0)