Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39a8510

Browse files
authored
Merge pull request #4 from tj-python/feature/clean-up-pypi-deployment
Updated deployment.
2 parents e31629b + 8742b8d commit 39a8510

File tree

4 files changed

+125
-31
lines changed

4 files changed

+125
-31
lines changed

.github/workflows/deploy.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Run semver-diff
16+
id: semver-diff
17+
uses: tj-actions/[email protected]
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.6.x'
23+
24+
- name: Upgrade pip
25+
run: pip install -U pip
26+
27+
- name: Install dependencies
28+
run: make install-deploy
29+
30+
- name: Setup git
31+
run: |
32+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
33+
git config --local user.name "github-actions[bot]"
34+
35+
- name: bumpversion
36+
run: |
37+
make increase-version PART="${{ steps.semver-diff.outputs.release_type }}"
38+
39+
- name: Build and publish
40+
run: make release
41+
env:
42+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
43+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
44+
45+
- name: Generate CHANGELOG
46+
uses: tj-actions/[email protected]
47+
48+
- name: Create Pull Request
49+
uses: peter-evans/create-pull-request@v3
50+
with:
51+
base: "main"
52+
title: "Upgraded ${{ steps.semver-diff.outputs.old_version }} → ${{ steps.semver-diff.outputs.new_version }}"
53+
branch: "chore/upgrade-${{ steps.semver-diff.outputs.old_version }}-to-${{ steps.semver-diff.outputs.new_version }}"
54+
commit-message: "Upgraded from ${{ steps.semver-diff.outputs.old_version }} → ${{ steps.semver-diff.outputs.new_version }}"
55+
body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/${{ steps.semver-diff.outputs.old_version }}...${{ steps.semver-diff.outputs.new_version }})"
56+
token: ${{ secrets.PAT_TOKEN }}

.github/workflows/python-publish.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Self-Documented Makefile see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
2+
3+
.DEFAULT_GOAL := help
4+
PART := minor
5+
6+
# Put it first so that "make" without argument is like "make help".
7+
help:
8+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-32s-\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
9+
10+
guard-%: ## Checks that env var is set else exits with non 0 mainly used in CI;
11+
@if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi
12+
13+
# --------------------------------------------------------
14+
# ------- Python package (pip) management commands -------
15+
# --------------------------------------------------------
16+
17+
clean: clean-build clean-pyc ## remove all build and Python artifacts
18+
19+
clean-build: ## remove build artifacts
20+
@rm -fr build/
21+
@rm -fr dist/
22+
@rm -fr .eggs/
23+
@find . -name '*.egg-info' -exec rm -fr {} +
24+
@find . -name '*.egg' -exec rm -f {} +
25+
26+
clean-pyc: ## remove Python file artifacts
27+
@find . -name '*.pyc' -exec rm -f {} +
28+
@find . -name '*.pyo' -exec rm -f {} +
29+
@find . -name '*~' -exec rm -f {} +
30+
@find . -name '__pycache__' -exec rm -fr {} + || true
31+
32+
lint: ## check style with flake8
33+
@flake8 github_deploy
34+
35+
release: dist ## package and upload a release
36+
@twine upload dist/*
37+
38+
dist: clean install-deploy ## builds source and wheel package
39+
@pip install twine==3.4.1
40+
@python setup.py sdist bdist_wheel
41+
42+
increase-version: guard-PART ## Increase project version
43+
@bump2version $(PART)
44+
@git switch -c main
45+
46+
install-wheel: clean ## Install wheel
47+
@echo "Installing wheel..."
48+
@pip install wheel
49+
50+
install: install-wheel ## install the package to the active Python's site-packages
51+
@pip install .
52+
53+
install-deploy: install-wheel
54+
@pip install -e .'[deploy]'
55+
56+
migrations:
57+
@python manage.py makemigrations
58+
59+
.PHONY: clean clean-build clean-pyc dist increase-version install-wheel install install-deploy increase-version lint release migrations

setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
else:
1212
LONG_DESCRIPTION = ""
1313

14+
deploy_requires = [
15+
"bump2version",
16+
"readme_renderer[md]",
17+
]
18+
19+
extras_require = {
20+
"deploy": deploy_requires,
21+
}
22+
1423

1524
setup(
1625
name="github-deploy",
@@ -31,6 +40,7 @@
3140
license="MIT",
3241
packages=find_packages(),
3342
python_requires='>=3.6',
43+
extras_require=extras_require,
3444
install_requires=[
3545
"asyncclick",
3646
"asyncio",

0 commit comments

Comments
 (0)