V1.0.5 try it out #52
Workflow file for this run
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: CI/CD | |
on: | |
push: | |
branches: [ master, pre-release ] | |
pull_request: | |
branches: [ master, pre-release ] | |
jobs: | |
test: | |
name: Run tests and collect coverage and linting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check version for pre-release | |
if: github.base_ref == 'pre-release' | |
run: | | |
validState=$(grep -oP 'version=\"\K[0-9.]+-\K['-']+' app/main.py || echo "valid") | |
if [ "$validState" != "valid" ]; then | |
echo "Fail: invalid development state (missing)" | |
exit 1 | |
fi | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run tests | |
run: pytest --cov=app tests/ --cov-report=xml --junitxml=junit.xml -o junit_family=legacy --cov-report=term-missing | |
- name: Upload test results to Codecov | |
if: ${{ !cancelled() }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload results to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
deploy: | |
needs: test | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/pre-release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get version | |
id: get_version | |
run: | | |
version=$(grep -oP "version=\"\K[0-9.]+" app/main.py || echo "0.0.0") | |
versionState=$(grep -oP 'version=\"\K[0-9.]+-\K[a-zA-Z]+' app/main.py || echo "dev") | |
versionSub=$(grep -oP 'version=\"\K[0-9.]+-\K[a-zA-Z]+-\K[a-zA-Z0-9.]+' app/main.py || echo "missing") | |
echo "version=$version" >> $GITHUB_OUTPUT | |
echo "versionState=$versionState" >> $GITHUB_OUTPUT | |
echo "versionSub=$versionSub" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push Docker images (master) | |
if: github.ref == 'refs/heads/master' | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: | | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:latest | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:${{ steps.get_version.outputs.version }} | |
- name: Build and push Docker images (pre-release with subversion) | |
if: github.ref == 'refs/heads/pre-release' && steps.get_version.outputs.versionSub != 'missing' | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: | | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:dev-latest | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:latest-${{ steps.get_version.outputs.versionState }}-latest | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:latest-${{ steps.get_version.outputs.versionState }}-${{ steps.get_version.outputs.versionSub }} | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:${{ steps.get_version.outputs.version }}-${{ steps.get_version.outputs.versionState }}-latest | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:${{ steps.get_version.outputs.version }}-${{ steps.get_version.outputs.versionState }}-${{ steps.get_version.outputs.versionSub }} | |
- name: Build and push Docker images (pre-release without subversion) | |
if: github.ref == 'refs/heads/pre-release' && steps.get_version.outputs.versionSub == 'missing' | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: | | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:dev-latest | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:latest-${{ steps.get_version.outputs.versionState }} | |
${{ secrets.DOCKER_USERNAME }}/kofi-websocket:${{ steps.get_version.outputs.version }}-${{ steps.get_version.outputs.versionState }} |