Skip to content

Commit 97b2b3e

Browse files
authored
Merge pull request #3 from kcelebi/main_dev
Updates to Package, adding Actions to Publish Package
2 parents 79f4a18 + 7328540 commit 97b2b3e

File tree

13 files changed

+538
-13
lines changed

13 files changed

+538
-13
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ jobs:
2222
# Change the version below to your required version of python
2323
docker:
2424
- image: cimg/python:3.10.2
25+
2526
# Checkout the code as the first step. This is a dedicated CircleCI step.
2627
# The python orb's install-packages step will install the dependencies from a Pipfile via Pipenv by default.
2728
# Here we're making sure we use just use the system-wide pip. By default it uses the project root's requirements.txt.
2829
# Then run your tests!
2930
# CircleCI will report the results back to your VCS provider.
3031
steps:
3132
- checkout
33+
# DO OUR STUFF
3234
- python/install-packages:
3335
pkg-manager: pip
3436
# app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory.

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish to PyPI.org
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
pypi:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- run: python3 -m pip install --upgrade build && python3 -m build
14+
- name: Publish package
15+
uses: pypa/gh-action-pypi-publish@release/v1
16+
with:
17+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Create a new patch release
2+
on: workflow_dispatch
3+
jobs:
4+
github:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v3
9+
- name: Create new patch release
10+
run: .github/workflows/scripts/release.py
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
import json
3+
import subprocess
4+
5+
6+
def get_last_version() -> str:
7+
"""Return the version number of the last release."""
8+
json_string = (
9+
subprocess.run(
10+
["gh", "release", "view", "--json", "tagName"],
11+
check=True,
12+
stdout=subprocess.PIPE,
13+
stderr=subprocess.PIPE,
14+
)
15+
.stdout.decode("utf8")
16+
.strip()
17+
)
18+
19+
return json.loads(json_string)["tagName"]
20+
21+
22+
def bump_patch_number(version_number: str) -> str:
23+
"""Return a copy of `version_number` with the patch number incremented."""
24+
major, minor, patch = version_number.split(".")
25+
return f"{major}.{minor}.{int(patch) + 1}"
26+
27+
28+
def create_new_patch_release():
29+
"""Create a new patch release on GitHub."""
30+
try:
31+
last_version_number = get_last_version()
32+
except subprocess.CalledProcessError as err:
33+
if err.stderr.decode("utf8").startswith("HTTP 404:"):
34+
# The project doesn't have any releases yet.
35+
new_version_number = "0.0.1"
36+
else:
37+
raise
38+
else:
39+
new_version_number = bump_patch_number(last_version_number)
40+
41+
subprocess.run(
42+
["gh", "release", "create", "--generate-notes", new_version_number],
43+
check=True,
44+
)
45+
46+
47+
if __name__ == "__main__":
48+
create_new_patch_release()

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ cached/
1111

1212
flight_analysis_app/
1313
docs/
14+
15+
.pytest_cache/

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]

setup.cfg

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[metadata]
2+
name = gha-python-packaging-demo
3+
description = Demo of a simple way to use GitHub Actions to build your Python package, bump the version number, and publish it to GitHub releases and PyPI.org all with a single click of a button in the web interface.
4+
long_description_content_type = text/markdown
5+
url = https://github.com/kcelebi/flight_analysis
6+
project_urls =
7+
Bug Tracker = https://github.com/kcelebi/flight_analysis/issues
8+
Changelog = https://github.com/kcelebi/flight_analysis/releases
9+
classifiers =
10+
Programming Language :: Python :: 3
11+
License :: OSI Approved :: BSD License
12+
Intended Audience :: Developers
13+
14+
[options]
15+
package_dir =
16+
= src
17+
packages = find:
18+
python_requires = >=3.6
19+
20+
[options.packages.find]
21+
where = src
22+
23+
[options.entry_points]
24+
console_scripts =
25+
gha_python_packaging_demo = gha_python_packaging_demo.app:entry_point

src/cache_dev.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'''/****************************************************************************************************************************************************************
2+
Written by Kaya Celebi, April 2023
3+
****************************************************************************************************************************************************************/'''
4+
5+
from selenium import webdriver
6+
from selenium.webdriver.support.ui import WebDriverWait
7+
from selenium.webdriver.common.by import By
8+
from datetime import date, datetime, timedelta
9+
import numpy as np
10+
import pandas as pd
11+
from tqdm import tqdm
12+
import json
13+
import os
14+
15+
__all__ = ['CacheControl']
16+
17+
class _CacheControl:
18+
19+
def __init__(self):
20+
...
21+
22+
def __call__(self):
23+
...
24+
25+
def __str__(self):
26+
...
27+
28+
def __repr__(self):
29+
...
30+
31+
CacheControl = _CacheControl()

0 commit comments

Comments
 (0)