more release into build #13
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: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- release/* | |
env: | |
DOCKER_IMAGE_NAME: capitec-decision-engine | |
jobs: | |
build-package: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.4' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements/dev.txt | |
pip install -r requirements/all.txt | |
- name: Format code with Black | |
run: black --check . | |
- name: Run tests | |
run: pytest | |
- name: Build Python package | |
run: python -m build | |
- name: Upload Python package | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package | |
path: dist/* | |
build-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.4' | |
- name: Install documentation dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements/all.txt | |
pip install . | |
- name: Build documentation | |
run: | | |
cd docs | |
make html | |
- name: Archive artifact | |
shell: sh | |
run: | | |
echo ::group::Archive artifact | |
tar \ | |
--dereference --hard-dereference \ | |
--directory "$INPUT_PATH" \ | |
-cvf "$RUNNER_TEMP/artifact.tar" \ | |
--exclude=.git \ | |
--exclude=.github \ | |
. | |
echo ::endgroup:: | |
env: | |
INPUT_PATH: docs/_build/html/ | |
- name: Upload docs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: 'github-pages' | |
path: ${{ runner.temp }}/artifact.tar | |
if-no-files-found: error | |
release: | |
needs: ["build-docs", "build-package"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12.4" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# - name: Login to Docker Hub | |
# uses: docker/login-action@v3 | |
# with: | |
# username: ${{ vars.DOCKERHUB_USERNAME }} | |
# password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry versioneer setuptools | |
- name: Get version | |
run: | | |
version=$(python setup.py --version) | |
echo "PACKAGE_VERSION=$(python setup.py --version)" >> $GITHUB_ENV | |
- name: Download Python Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: python | |
path: dist/py | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v6 | |
with: | |
load: true | |
tags: ${{ env.DOCKER_IMAGE_NAME }}:hold | |
file: docker/Dockerfile | |
- name: Upload Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ env.PACKAGE_VERSION }} | |
file: docker/Dockerfile | |
# - name: Upload Latest Docker image | |
# uses: docker/build-push-action@v3 | |
# if: github.ref == 'refs/heads/main' | |
# with: | |
# push: true | |
# tags: ${{ env.DOCKER_IMAGE_NAME }}:latest | |
# - name: Publish python package | |
# env: | |
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | |
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
# run: | | |
# twine upload dist/py/* | |
- name: Deploy documentation to GitHub Pages | |
if: github.ref == 'refs/heads/main' | |
uses: actions/deploy-pages@v4 | |
- name: Tag Release | |
run: | | |
git tag -a v${{ env.PACKAGE_VERSION }} -m "Release v${{ env.PACKAGE_VERSION }}" | |
git push origin v${{ env.PACKAGE_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |