Skip to content

Commit 2ff40cf

Browse files
authored
add workflow for release + release v0.0.1 (#1)
* add workflow for release * add ci * fix release * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * readme * clean * clean * clean * clean * add example * clean * clean * clean * clean * clean
1 parent 0ff3e27 commit 2ff40cf

22 files changed

Lines changed: 791 additions & 63 deletions

.cpa/flake8.cfg

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ exclude =
4141
build,
4242
dist,
4343
htmlcov.*,
44-
45-
application-import-names = flake8 # List of application-specific import names.
46-
import-order-style = google # Import statement format style.
47-
max-complexity = 18 # The maximum McCabe complexity allowed.
48-
max-line-length = 120 # The maximum allowed line length.
44+
# List of application-specific import names.
45+
application-import-names = flake8
46+
# Import statement format style.
47+
import-order-style = google
48+
# The maximum McCabe complexity allowed.
49+
max-complexity = 18
50+
# The maximum allowed line length.
51+
max-line-length = 120
4952
# per-file-ignores = # Per-file-ignores setting can be used to ignore specific errors in specific files.

.github/workflows/ci.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: CI
2+
3+
####################################
4+
# Start the job on all push and PR #
5+
####################################
6+
on:
7+
pull_request:
8+
branches: [master, main]
9+
types: [synchronize, opened, reopened, ready_for_review]
10+
# push:
11+
# branches: [master, main]
12+
13+
jobs:
14+
precommits:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.10"
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install pre-commit
29+
pre-commit install
30+
31+
- name: Install shfmt
32+
run: |
33+
SHFMT_VERSION="v3.7.0"
34+
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
35+
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
36+
chmod +x shfmt
37+
sudo mv shfmt /usr/local/bin/
38+
39+
- name: Run pre-commits
40+
run: |
41+
pre-commit run --all-files
42+
# pre-commit run --from-ref origin/main --to-ref HEAD
43+
# run: |
44+
# BASE_COMMIT_ID=$(git rev-parse origin/main)
45+
# pre-commit run --from-ref ${{ env.BASE_COMMIT_ID }} --to-ref HEAD

.github/workflows/release.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
# pull_request:
8+
# branches: [master, main]
9+
# types: [synchronize, opened, reopened, ready_for_review]
10+
11+
jobs:
12+
create-release:
13+
name: Create Release
14+
permissions:
15+
contents: write
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Create release
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: gh release create ${{ github.ref_name }} --generate-notes --title "Version ${{ github.ref_name }}"
24+
25+
upload-release:
26+
name: Build and Release
27+
permissions:
28+
contents: write
29+
strategy:
30+
matrix:
31+
os: [ubuntu-latest, macos-latest, windows-latest]
32+
runs-on: ${{ matrix.os }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Install Rust Toolchain
37+
uses: dtolnay/rust-toolchain@stable
38+
39+
- name: Print Runner OS
40+
run: echo "Runner OS is ${{ runner.os }}"
41+
42+
- name: Build Release
43+
run: cargo build --release
44+
45+
- name: Archive Release Binary (Windows)
46+
if: runner.os == 'Windows'
47+
run: Compress-Archive -Path ./target/release/cpa.exe -DestinationPath cpa-Windows.zip
48+
shell: pwsh
49+
50+
- name: Archive Release Binary (MacOS, Linux)
51+
if: runner.os != 'Windows'
52+
run: zip -j cpa-${{ runner.os }}.zip ./target/release/cpa
53+
54+
- name: Release
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: gh release upload ${{ github.ref_name }} "cpa-${{ runner.os }}.zip" --clobber

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ repos:
1313
- id: check-merge-conflict # Searches for merge conflict markers within files.
1414
- id: check-symlinks # Detects broken symlinks.
1515
- id: check-added-large-files # Blocks commits that add large files. Default limit is 500kB.
16+
args: ["--maxkb=1300"]
1617
# Can be configured with args, e.g., '--maxkb=1000' to change the limit.
1718
# Files in 'your_dir/' can be excluded.
1819
# exclude: 'your_dir/.*'
19-
# args: ['--maxkb=5000']
2020
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.
2121
- id: trailing-whitespace # Removes any trailing whitespace at the end of lines.
2222

@@ -59,7 +59,7 @@ repos:
5959
- id: isort # Sorts Python imports into sections and by alphabetical order
6060
args:
6161
- --settings-path
62-
- .cpa/pyproject.toml
62+
- pyproject.toml
6363
types:
6464
- python
6565

@@ -69,7 +69,7 @@ repos:
6969
- id: black # Formats Python code to conform to the Black code style
7070
args:
7171
- --config
72-
- .cpa/pyproject.toml
72+
- pyproject.toml
7373
types:
7474
- python
7575

@@ -116,9 +116,9 @@ repos:
116116
- markdown
117117
exclude: templates/.pre-commit-config.yaml
118118

119-
##
119+
#############################################################################
120120
# Rust
121-
##
121+
#############################################################################
122122
- repo: https://github.com/doublify/pre-commit-rust
123123
rev: v1.0
124124
hooks:

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
# CPA: Create-Python-App
22

3-
## Overview
4-
5-
`cpa` is a cli tool designed to streamline the setup of new Python projects. It automates the creation of Python projects with commonly used configs and boilerplate.
6-
7-
## Goals
8-
9-
- **Speed up Project Creation**: Reduce the time spent on repetitive setup tasks
10-
- **Best Practices**: Encourage best practices for code quality, formatting, and style by including configs for tools like `black`, `isort`, and `flake8`.
11-
- **Automation**: Automate tasks such as generating `.gitignore` files, setting up pre-commit hooks, and configuring code linters and formatters.
3+
![CPA Logo](cpa.png)
124

13-
## Features
5+
## Overview
146

15-
- Provides pre-commit hook setup with hooks for checking merge conflicts, large files, and code styling.
7+
`cpa` is a cli tool for ultra fast setup of new Python projects. It automates the creation of config files for style & lint checks, gitignore, a basic Dockerfile and dependency management configuration. An opinionated set of pre-commit hooks are included for enforcing best practices and reducing setup time.
168

179
## Installation
1810

19-
Download binary from Github
11+
### MacOS, Linux
2012

21-
```bash
13+
Download latest binary and install via provided `install.sh` script or get it from [Releases](https://github.com/ysawa0/create-python-app/releases)
2214

2315
```
16+
sh install.sh
17+
```
18+
19+
### Windows
20+
21+
Download latest binary from [Releases](https://github.com/ysawa0/create-python-app/releases) page
2422

25-
Building from source
23+
### Building from source
2624

2725
```bash
2826
# cd to project
@@ -34,19 +32,26 @@ cargo install --path .
3432
To create a new project:
3533

3634
```bash
37-
cpa create --name <project_name>
35+
cpa create --name myproject
3836
```
3937

4038
Optional params:
4139

42-
- `--preset`: Specifies a Python version for the project. Defaults to "python" which is mapped internally to "python3.10".
40+
- `--preset`: Specifies a Python version for the project. Defaults to "python3.10"
4341

4442
Example:
4543

4644
```bash
47-
cpa create --name my_project --preset python3.10
45+
cpa create --name myproject --preset python3.10
4846
```
4947

48+
## Goals
49+
50+
- **Speed up Project Creation**: Reduce the time spent on repetitive setup tasks
51+
- **Best Practices**: Encourage best practices for code quality, formatting, and style by including configs for tools like `black`, `isort`, and `flake8`.
52+
- **Automation**: Automate tasks such as generating `.gitignore` files, setting up pre-commit hooks, and configuring code linters and formatters.
53+
- Golang, Rust support planned
54+
5055
## Contributions and Feedback
5156

5257
Users are welcome to contribute to the project by submitting pull requests or opening issues for bugs and feature requests. Feedback is also greatly appreciated to help improve the tool.

cpa.png

69.8 KB
Loading

example/.cpa/flake8.cfg

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[flake8]
2+
ignore =
3+
# C901, # function is too complex. Ignored because max-complexity is set.
4+
D100, # Missing docstring in public module.
5+
D101, # Missing docstring in public class.
6+
D102, # Missing docstring in public method.
7+
D103, # Missing docstring in public function.
8+
D104, # Missing docstring in public package.
9+
D105, # Missing docstring in magic method.
10+
D107, # Missing docstring in __init__.
11+
D205, # 1 blank line required between summary line and description.
12+
D400, # First line should end with a period.
13+
E203, # whitespace before ':'. Conflicts with how Black formats slicing.
14+
E231, # missing whitespace after ',', ';', or ':'. Conflicts with Black.
15+
E266, # too many leading '#' for block comment.
16+
E402, # module level import not at top of file.
17+
E501, # line too long (82 > 79 characters). Ignored because max-line-length is set.
18+
F841, # local variable is assigned to but never used.
19+
I100, # Import statements are in the wrong order.
20+
I201, # Missing newline between import groups.
21+
I202, # Additional newline in a group of imports.
22+
W503 # line break before binary operator. This is no longer PEP 8 compliant.
23+
24+
exclude =
25+
.cache,
26+
.coverage.*,
27+
.env, # Environment directory used by some tools
28+
.git, # Version control directory
29+
.github, # GitHub metadata directory
30+
.gradle,
31+
.hg, # Mercurial directory
32+
.mypy_cache, # MyPy cache directory
33+
.pytest_cache, # PyTest cache directory
34+
.svn, # Subversion directory
35+
.tox,
36+
.venv, # Common virtual environment directory
37+
.vscode, # VS Code configuration directory
38+
*__pycache__, # Python cache directory
39+
*.egg-info,
40+
*.pyc,
41+
build,
42+
dist,
43+
htmlcov.*,
44+
45+
application-import-names = flake8 # List of application-specific import names.
46+
import-order-style = google # Import statement format style.
47+
max-complexity = 18 # The maximum McCabe complexity allowed.
48+
max-line-length = 120 # The maximum allowed line length.
49+
# per-file-ignores = # Per-file-ignores setting can be used to ignore specific errors in specific files.

example/.cpa/prettier.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"bracketSpacing": true,
3+
"singleQuote": false,
4+
"useTabs": false,
5+
"tabWidth": 2,
6+
"trailingComma": "all"
7+
}

0 commit comments

Comments
 (0)