Skip to content

Commit 949f7e8

Browse files
Merge pull request #9 from brainelectronics/feature/automate-tagging
Automate tagging
2 parents 84990f9 + 3b5830a commit 949f7e8

File tree

6 files changed

+95
-6
lines changed

6 files changed

+95
-6
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ exclude =
4040
__init__.py
4141
# example testing folder before going live
4242
thinking
43+
.idea
4344
# custom scripts, not being part of the distribution
4445
libs_external
4546
sdist_upip.py

.github/workflows/release.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ on:
99
- main
1010

1111
permissions:
12-
contents: read
12+
contents: write
1313

1414
jobs:
1515
deploy:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020
- name: Set up Python
2121
uses: actions/setup-python@v3
2222
with:
@@ -41,3 +41,16 @@ jobs:
4141
skip_existing: true
4242
verbose: true
4343
print_hash: true
44+
- name: 'Create changelog based release'
45+
uses: brainelectronics/changelog-based-release@v1
46+
with:
47+
# note you'll typically need to create a personal access token
48+
# with permissions to create releases in the other repo
49+
# or you set the "contents" permissions to "write" as in this example
50+
changelog-path: changelog.md
51+
tag-name-prefix: ''
52+
tag-name-extension: ''
53+
release-name-prefix: ''
54+
release-name-extension: ''
55+
draft-release: true
56+
prerelease: false

.github/workflows/test-release.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ name: Upload Python Package to test.pypi.org
66
on: [pull_request]
77

88
permissions:
9-
contents: read
9+
contents: write
1010

1111
jobs:
1212
test-deploy:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717
- name: Set up Python
1818
uses: actions/setup-python@v3
1919
with:
@@ -51,3 +51,16 @@ jobs:
5151
skip_existing: true
5252
verbose: true
5353
print_hash: true
54+
- name: 'Create changelog based prerelease'
55+
uses: brainelectronics/changelog-based-release@v1
56+
with:
57+
# note you'll typically need to create a personal access token
58+
# with permissions to create releases in the other repo
59+
# or you set the "contents" permissions to "write" as in this example
60+
changelog-path: changelog.md
61+
tag-name-prefix: ''
62+
tag-name-extension: '-rc${{ github.run_number }}.dev${{ github.event.number }}'
63+
release-name-prefix: ''
64+
release-name-extension: '-rc${{ github.run_number }}.dev${{ github.event.number }}'
65+
draft-release: true
66+
prerelease: true

.github/workflows/unittest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
test-and-coverage:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616
- uses: actions/setup-python@v3
1717
with:
1818
python-version: '3.9'

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ MicroPython PyPi package template with GitHub Action based testing and deploy
2727
- [Manually](#manually)
2828
- [Upload files to board](#upload-files-to-board)
2929
- [Usage](#usage)
30+
- [Create a PyPi \(micropython\) package](#create-a-pypi-micropython-package)
31+
- [Setup](#setup-1)
32+
- [Create a distribution](#create-a-distribution)
33+
- [Upload to PyPi](#upload-to-pypi)
3034
- [Contributing](#contributing)
3135
- [Unittests](#unittests)
3236
- [Credits](#credits)
@@ -142,6 +146,51 @@ flash_led(pin=led_pin, amount=3)
142146
# flash_led(pin=led_pin, amount=3, on_time=1, off_time=3)
143147
```
144148

149+
## Create a PyPi (micropython) package
150+
151+
### Setup
152+
153+
Install the required python package with the following command in a virtual
154+
environment to avoid any conflicts with other packages installed on your local
155+
system.
156+
157+
```bash
158+
python3 -m venv .venv
159+
source .venv/bin/activate
160+
161+
pip install twine
162+
```
163+
164+
### Create a distribution
165+
166+
This module overrides distutils (also compatible with setuptools) `sdist`
167+
command to perform pre- and post-processing as required for MicroPython's
168+
upip package manager. This script is taken from
169+
[pfalcon's picoweb][ref-pfalcon-picoweb-sdist-upip] and updated to be PEP8
170+
conform.
171+
172+
```bash
173+
python setup.py sdist
174+
```
175+
176+
A new folder `dist` will be created. The [`sdist_upip`](sdist_upip.py) will be
177+
used to create everything necessary.
178+
179+
### Upload to PyPi
180+
181+
**Be aware: [pypi.org][ref-pypi] and [test.pypi.org][ref-test-pypi] are different**
182+
183+
You can **NOT** login to [test.pypi.org][ref-test-pypi] with the
184+
[pypi.org][ref-pypi] account unless you created the same on the other. See
185+
[invalid auth help page of **test** pypi][ref-invalid-auth-test-pypi]
186+
187+
For testing purposes add `--repository testpypi` to
188+
upload it to [test.pypi.org][ref-test-pypi]
189+
190+
```bash
191+
twine upload dist/micropython-package-template-*.tar.gz -u PYPI_USERNAME -p PYPI_PASSWORD
192+
```
193+
145194
## Contributing
146195

147196
### Unittests
@@ -174,3 +223,7 @@ Based on the [PyPa sample project][ref-pypa-sample].
174223
[ref-remote-upy-shell]: https://github.com/dhylands/rshell
175224
[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver
176225
[ref-pypa-sample]: https://github.com/pypa/sampleproject
226+
[ref-pfalcon-picoweb-sdist-upip]: https://github.com/pfalcon/picoweb/blob/b74428ebdde97ed1795338c13a3bdf05d71366a0/sdist_upip.py
227+
[ref-test-pypi]: https://test.pypi.org/
228+
[ref-pypi]: https://pypi.org/
229+
[ref-invalid-auth-test-pypi]: https://test.pypi.org/help/#invalid-auth

changelog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
1717
-->
1818

1919
## Released
20+
## [0.4.0] - 2023-02-20
21+
### Added
22+
- `test-release` and `release` workflows create changelog based (pre-)releases
23+
- Documentation for manually creating a package and uploading it to PyPi in root README
24+
25+
### Fixed
26+
- All workflows use checkout v3 instead of v2
27+
2028
## [0.3.0] - 2022-11-03
2129
### Added
2230
- Lint package with `flake8` with [test workflow](.github/workflows/test.yaml)
@@ -65,8 +73,9 @@ r"^\#\# \[\d{1,}[.]\d{1,}[.]\d{1,}\] \- \d{4}\-\d{2}-\d{2}$"
6573
- [`setup.py`](setup.py) and [`sdist_upip.py`](sdist_upip.py) file
6674

6775
<!-- Links -->
68-
[Unreleased]: https://github.com/brainelectronics/micropython-package-template/compare/0.3.0...main
76+
[Unreleased]: https://github.com/brainelectronics/micropython-package-template/compare/0.4.0...main
6977

78+
[0.4.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.4.0
7079
[0.3.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.3.0
7180
[0.2.0]: https://github.com/brainelectronics/micropython-package-template/tree/0.2.0
7281
[0.1.1]: https://github.com/brainelectronics/micropython-package-template/tree/0.1.1

0 commit comments

Comments
 (0)