CP-Pipeline #20
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
name: Python CI/CD Workflow | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
lint: | |
name: Lint Code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.13.0rc2 | |
- name: Install Dependencies | |
run: pip install -r requirements-dev.txt | |
- name: Install Linter | |
run: pre-commit install | |
- name: Lint Code | |
run: pre-commit run --all-files | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.13.0rc2 | |
- name: Install Dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install -r requirements-dev.txt | |
- name: Run Tests | |
run: python -m unittest ntp_amplification_test.py | |
publish: | |
name: Check Version and Publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.13.0rc2 | |
- name: Install Dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install -r requirements-dev.txt | |
- name: Get Current Version | |
id: current_version | |
run: | | |
version=$(python -c "exec(open('version.py').read()); print(__version__)") | |
echo "Current version: $version" | |
echo "::set-output name=VERSION::$version" | |
- name: Check if Version is Incremented | |
id: version_check | |
run: | | |
git fetch origin master | |
git checkout master | |
cur_version=$(python -c "exec(open('ntp_amplification/version.py').read()); print(__version__)") | |
echo "Main branch version: $cur_version" | |
if [ "$cur_version" = "$version" ]; then | |
echo "Version has not been incremented, exiting..." | |
exit 1 | |
else | |
echo "Version is incremented, proceeding..." | |
fi | |
- name: Push Changes to Repository | |
if: success() | |
env: | |
TOKEN: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git checkout -b release | |
git add . | |
git commit -m "Release version ${{ steps.current_version.outputs.VERSION }}" | |
git push origin master |