-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from brainelectronics/feature/automatic-release
implement automatic releases and testing
- Loading branch information
Showing
11 changed files
with
356 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
|
||
# this file is *not* meant to cover or endorse the use of GitHub Actions, but | ||
# rather to help make automated releases for this project | ||
|
||
name: Upload Python Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.11' | ||
- name: Install build and deploy dependencies | ||
run: | | ||
python -m pip install -U poetry twine | ||
poetry self add "poetry-dynamic-versioning[plugin]" | ||
poetry install | ||
- name: Parse changelog | ||
id: parse_changelog | ||
run: | | ||
poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt | ||
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT | ||
cat latest_description.txt >> $GITHUB_OUTPUT | ||
echo '"EOT"' >> $GITHUB_OUTPUT | ||
latest_version=$(poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])") | ||
echo "latest_version=$latest_version" >> $GITHUB_ENV | ||
- name: Build package | ||
run: | | ||
poetry run changelog2version \ | ||
--changelog_file changelog.md \ | ||
--version_file snippets2changelog/version.py \ | ||
--version_file_type py \ | ||
--debug | ||
poetry build | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@release/v1.5 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
skip_existing: true | ||
verbose: true | ||
print_hash: true | ||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.latest_version }} | ||
release_name: ${{ env.latest_version }} | ||
body: ${{ steps.parse_changelog.outputs.LATEST_DESCRIPTION }} | ||
draft: false | ||
prerelease: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
|
||
# this file is *not* meant to cover or endorse the use of GitHub Actions, but | ||
# rather to help make automated releases for this project | ||
|
||
name: Upload Python Package to test.pypi.org | ||
|
||
on: [pull_request] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
test-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.11' | ||
- name: Install deploy dependencies | ||
run: | | ||
python -m pip install -U poetry twine | ||
poetry self add "poetry-dynamic-versioning[plugin]" | ||
poetry install | ||
- name: Parse changelog | ||
id: parse_changelog | ||
run: | | ||
poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt | ||
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT | ||
cat latest_description.txt >> $GITHUB_OUTPUT | ||
echo '"EOT"' >> $GITHUB_OUTPUT | ||
latest_version=$(poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])") | ||
echo "latest_version=$latest_version" >> $GITHUB_ENV | ||
- name: Build package | ||
run: | | ||
poetry run changelog2version \ | ||
--changelog_file changelog.md \ | ||
--version_file snippets2changelog/version.py \ | ||
--version_file_type py \ | ||
--additional_version_info="-rc${{ github.run_number }}.dev${{ github.event.number }}" \ | ||
--debug | ||
poetry build | ||
- name: Test built package | ||
run: | | ||
twine check dist/*.tar.gz | ||
- name: Archive build package artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | ||
# ${{ github.repository }} and ${{ github.ref_name }} can't be used for artifact name due to unallowed '/' | ||
name: dist_py.${{ github.event.repository.name }}_sha.${{ github.sha }}_build.${{ github.run_number }} | ||
path: dist/*.tar.gz | ||
retention-days: 14 | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@release/v1.5 | ||
with: | ||
repository_url: https://test.pypi.org/legacy/ | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
skip_existing: true | ||
verbose: true | ||
print_hash: true | ||
- name: Create Prerelease | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.latest_version }}-rc${{ github.run_number }}.dev${{ github.event.number }} | ||
release_name: ${{ env.latest_version }}-rc${{ github.run_number }}.dev${{ github.event.number }} | ||
body: ${{ steps.parse_changelog.outputs.LATEST_DESCRIPTION }} | ||
draft: false | ||
prerelease: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
|
||
# This workflow will install Python dependencies, run tests and lint with a | ||
# specific Python version | ||
# For more information see: | ||
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Test Python package | ||
|
||
on: | ||
push: | ||
# branches: [ $default-branch ] | ||
branches-ignore: | ||
- 'main' | ||
- 'develop' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
# runs-on: ${{ matrix.os }} | ||
# strategy: | ||
# matrix: | ||
# python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
# # os: [ubuntu-latest, macos-latest, windows-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.11' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install -U poetry | ||
poetry install | ||
- name: Test with pytest | ||
run: | | ||
poetry run pytest -v | ||
- name: Install deploy dependencies | ||
run: | | ||
python -m pip install -U twine | ||
poetry self add "poetry-dynamic-versioning[plugin]" | ||
- name: Build package | ||
run: | | ||
poetry run changelog2version \ | ||
--changelog_file changelog.md \ | ||
--version_file snippets2changelog/version.py \ | ||
--version_file_type py \ | ||
--debug | ||
poetry build | ||
- name: Test built package | ||
run: | | ||
twine check dist/*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
|
||
# this file is *not* meant to cover or endorse the use of GitHub Actions, but | ||
# rather to help make automated releases for this project | ||
|
||
name: Unittest Python Package | ||
|
||
on: [push, pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test-and-coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.11' | ||
- name: Execute tests | ||
run: | | ||
python -m pip install -U poetry | ||
poetry install | ||
python create_report_dirs.py | ||
poetry run coverage run -m pytest -v | ||
- name: Create coverage report | ||
run: | | ||
poetry run coverage xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./reports/coverage/coverage.xml | ||
flags: unittests | ||
fail_ci_if_error: true | ||
# path_to_write_report: ./reports/coverage/codecov_report.txt | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "snippets2changelog" | ||
version = "0.0.0+will-be-updated-automatically" | ||
version = "0.0.0" # will-be-updated-automatically | ||
description = "Generate a changelog from individual snippets" | ||
authors = ["brainelectronics <[email protected]>"] | ||
repository = "https://github.com/brainelectronics/snippets2changelog" | ||
|
@@ -10,7 +10,7 @@ packages = [ | |
{ include = "snippets2changelog/**/*.py" } | ||
] | ||
include = [ | ||
{ path = 'snippets2changelog/templates/snippet.md.template', format = 'sdist' } | ||
{ path = "snippets2changelog/templates/snippet.md.template", format = ["sdist", "wheel"] } | ||
] | ||
exclude = ["snippets2changelog/out"] | ||
classifiers = [ | ||
|
@@ -33,7 +33,7 @@ enable = true | |
format-jinja-imports = [ | ||
{ module = "subprocess", item = "check_output" }, | ||
] | ||
format-jinja = """{{ check_output(["python", "-c", "from pathlib import Path; exec(Path('snippets2changelog/version.py').read_text()); print(__version__)"]).decode().strip() }}""" | ||
format-jinja = """{{ check_output(["python3", "-c", "from pathlib import Path; exec(Path('snippets2changelog/version.py').read_text()); print(__version__)"]).decode().strip() }}""" | ||
# format-jinja = "{{ env.get('PROJECT_VERSION') }}" | ||
|
||
[tool.poetry.scripts] | ||
|
@@ -43,9 +43,11 @@ changelog-generator = 'snippets2changelog.cli:main' | |
python = "^3.11" | ||
pyyaml = "~6.0" | ||
GitPython = "~3.1.43" | ||
jinja2 = "^3.1.4" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
black = "*" | ||
changelog2version = "^0.10" | ||
flake8 = "*" | ||
isort = "*" | ||
mypy = "*" | ||
|
Empty file.
Oops, something went wrong.