Skip to content

Commit

Permalink
Ci/deploy on release (#14)
Browse files Browse the repository at this point in the history
* deploy-on-release github action added

* mergify ci tool added
  • Loading branch information
bagxi authored Aug 5, 2021
1 parent e70c1e4 commit d85ce4d
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 60 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: catalyst_team
open_collective: catalyst
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
18 changes: 18 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# https://github.com/marketplace/stale
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 14
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
31 changes: 31 additions & 0 deletions .github/workflows/deploy_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: deploy-on-release

on:
release:
types: [published]

jobs:

build-pypi:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6]

steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Generating distribution archives
run: |
pip install --upgrade setuptools wheel
python setup.py sdist bdist_wheel --universal
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
31 changes: 31 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pull_request_rules:
# removes reviews done by collaborators when the pull request is updated
- name: remove outdated reviews
conditions:
- base=master
actions:
dismiss_reviews:

# automatic merge for master when required CI passes
- name: automatic merge for master when CI passes and 2 review
conditions:
- "#approved-reviews-by>=2"
- label!=WIP
actions:
merge:
method: squash

# deletes the head branch of the pull request, that is the branch which hosts the commits
- name: delete head branch after merge
conditions:
- merged
actions:
delete_head_branch: {}

# ask author of PR to resolve conflict
- name: ask to resolve conflict
conditions:
- conflict
actions:
comment:
message: "This pull request is now in conflicts. @{{ author }}, could you fix it? 🙏"
72 changes: 12 additions & 60 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Note: To use the "upload" functionality of this file, you must:
# $ pip install twine
from typing import Iterable, Union
from pathlib import Path

import io
import os
from shutil import rmtree
import sys

from setuptools import Command, find_packages, setup
from setuptools import find_packages, setup

# Package meta-data.
NAME = "catalyst-codestyle"
Expand All @@ -20,62 +15,21 @@
AUTHOR = "Sergey Kolesnikov"
REQUIRES_PYTHON = ">=3.6.0"

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
PROJECT_ROOT = Path(__file__).parent.resolve()


def load_requirements(filename):
def load_requirements(filename: Union[Path, str] = "requirements.txt") -> Iterable[str]:
"""Load package requirements."""
with open(os.path.join(PROJECT_ROOT, filename), "r") as f:
with open(PROJECT_ROOT / filename) as f:
return f.read().splitlines()


def load_readme():
def load_readme(filename: Union[Path, str] = "README.md") -> str:
"""Load package readme."""
readme_path = os.path.join(PROJECT_ROOT, "README.md")
with io.open(readme_path, encoding="utf-8") as f:
with open(PROJECT_ROOT / filename, encoding="utf-8") as f:
return f"\n{f.read()}"


class UploadCommand(Command):
"""Support setup.py upload."""

description = "Build and publish the package."
user_options = []

@staticmethod
def status(s):
"""Prints things in bold."""
print(f"\033[1m{s}\033[0m")

def initialize_options(self):
"""@TODO: Docs. Contribution is welcome"""
pass

def finalize_options(self):
"""@TODO: Docs. Contribution is welcome"""
pass

def run(self):
"""Run upload command."""
try:
self.status("Removing previous builds…")
rmtree(os.path.join(PROJECT_ROOT, "dist"))
except OSError:
pass

self.status("Building Source and Wheel (universal) distribution…")
os.system(f"{sys.executable} setup.py sdist bdist_wheel --universal") # noqa: E501, S605

self.status("Uploading the package to PyPI via Twine…")
os.system("twine upload dist/*") # noqa: S605, S607

self.status("Pushing git tags…")
os.system(f"git tag v{VERSION}") # noqa: S605
os.system("git push --tags") # noqa: S605, S607

sys.exit()


setup(
name=NAME,
version=VERSION,
Expand All @@ -92,14 +46,14 @@ def run(self):
"Documentation": "https://catalyst-team.github.io/catalyst",
"Source Code": "https://github.com/catalyst-team/codestyle",
},
packages=find_packages(exclude=("tests", )),
packages=find_packages(exclude=("tests",)),
scripts=[
"bin/catalyst-check-codestyle",
"bin/catalyst-make-codestyle",
"bin/catalyst-codestyle-flake8",
"bin/catalyst-codestyle-isort",
],
install_requires=load_requirements("requirements.txt"),
install_requires=load_requirements(),
include_package_data=True,
license="Apache License 2.0",
classifiers=[
Expand All @@ -115,10 +69,8 @@ def run(self):
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
],
# $ setup.py publish support.
cmdclass={
"upload": UploadCommand,
},
)

0 comments on commit d85ce4d

Please sign in to comment.