-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add semver-compliant CI-CD and poetry dependency management (#127)
* feat: Add semver-compliant CI-CD and poetry dependency management * feat(qa): add quality assurance job to ci * ci: Add CI badge to README * ci: Remove docs from patch tags * ci: Use 'semantic-version --noop --strict version' to check release status * ci: fix deprecated ::set-output method * ci: refine bash code and add github-actions[bot] as author of ci commits * ci: add step to publish to test.pypi, temporarily disable publishing to pypi
- Loading branch information
1 parent
8a8ee99
commit c25ee40
Showing
8 changed files
with
159 additions
and
482 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
|
||
jobs: | ||
Quality: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{matrix.python-version}} | ||
|
||
- name: Install Python Poetry | ||
uses: abatilo/actions-poetry@v2.3.0 | ||
|
||
- name: Configure poetry | ||
shell: bash | ||
run: python -m poetry config virtualenvs.in-project true | ||
|
||
- name: View poetry version | ||
run: poetry --version | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m poetry install | ||
- name: Test | ||
run: poetry run python3 -m unittest discover | ||
|
||
Release: | ||
needs: Quality | ||
if: | | ||
github.event_name == 'push' && | ||
github.ref == 'refs/heads/master' && | ||
!contains ( github.event.head_commit.message, 'chore(release)' ) | ||
runs-on: ubuntu-latest | ||
concurrency: release | ||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.8 | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check release status | ||
id: release-status | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
pip install python-semantic-release | ||
if semantic-release --noop --strict version | ||
then | ||
echo "Releasing new version." | ||
else | ||
echo "Skipping release steps." | ||
fi | ||
- if: steps.release-status.outputs.released == 'true' | ||
name: Release to GitHub | ||
id: github-release | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
semantic-release version | ||
git fetch --tags | ||
for file in ./dist/** | ||
do gh release upload "${{steps.release-status.outputs.tag}}" $file | ||
done | ||
- if: steps.release-status.outputs.released == 'true' | ||
name: Release to Test PyPI | ||
id: test-pypi-release | ||
env: | ||
TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} | ||
run: | | ||
poetry config repositories.test-pypi https://test.pypi.org/legacy/ | ||
poetry config pypi-token.test-pypi $TEST_PYPI_TOKEN | ||
poetry publish -r test-pypi -u __token__ | ||
- if: false && steps.release-status.outputs.released == 'true' | ||
name: Release to PyPI | ||
id: pypi-release | ||
env: | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
run: | | ||
poetry config pypi-token.pypi $PYPI_TOKEN | ||
poetry publish |
Oops, something went wrong.