Skip to content

releasing 0.2.25 (#146) #26

releasing 0.2.25 (#146)

releasing 0.2.25 (#146) #26

Workflow file for this run

name: Main - build image and push
# This workflow builds, tests, and pushes a Docker image to GitHub Container Registry.
# It is triggered on push and manual workflow_dispatch events for the "main" branch.
# The image is tagged with a release version and "latest".
# For pull requests, the Docker image is uploaded as an artifact instead of being pushed to the registry.
# The repository owner is converted to lowercase for consistent tagging.
# The workflow uses the GITHUB_TOKEN secret for authentication with GitHub Container Registry.
# Uncomment the Docker Hub section if you want to push to Docker Hub as well.
# The Docker Hub credentials should be stored in the repository secrets as DOCKER_USERNAME and DOCKER_PASSWORD.
# Jobs:
# - pytest: Runs unit and regression tests using pytest.
# - build_image: Builds the Docker image, tags it, and uploads it as an artifact for PRs.
# - publish_image: Downloads the image artifact and pushes it to GitHub Container Registry (on push events).
on:
push:
branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
workflow_dispatch: # allows manual triggering of the workflow
env:
VERSION_PREFIX: 0.2.
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
- name: Run unit and regression tests
run: python -m pytest -v tests/
publish_image:
runs-on: ubuntu-latest
needs: pytest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pull latest changes
run: git pull origin main --rebase
- name: Set version string
run: echo "VERSION=${{ env.VERSION_PREFIX }}${{ github.run_number }}" >> $GITHUB_ENV
- name: Write version to file
run: echo "__version__ = '${{ env.VERSION }}'" > src/version.py
- name: Commit version file and push changes
if: github.event_name == 'push'
uses: devops-infra/action-commit-push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_prefix: "[AUTO] "
commit_message: "Update version to ${{ env.VERSION }}"
- name: Convert repository owner to lowercase
run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# 1. Setup QEMU for ARM64 emulation
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
# 2. Setup Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 3. Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 4. Build & Push Multi-Arch Image
- name: Build and push multi-platform Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ env.owner }}/eos_connect:release
ghcr.io/${{ env.owner }}/eos_connect:${{ env.VERSION }}
ghcr.io/${{ env.owner }}/eos_connect:latest
push: ${{ github.event_name == 'push' }}
# Only upload the image artifact for pull_request events
- name: Upload Docker image as artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: eos_connect_image-${{ env.VERSION }}
path: eos_connect_${{ env.VERSION }}.tar.gz
# Only run tagging and pushing tasks for "push" events
- name: Log in to GitHub Container Registry
if: github.event_name == 'push'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Tag image with release version
if: github.event_name == 'push'
run: docker tag ghcr.io/${{ env.owner }}/eos_connect:release ghcr.io/${{ env.owner }}/eos_connect:${{ env.VERSION }}
- name: Tag image with latest
if: github.event_name == 'push'
run: docker tag ghcr.io/${{ env.owner }}/eos_connect:release ghcr.io/${{ env.owner }}/eos_connect:latest
- name: Push Docker image to GitHub Container Registry
if: github.event_name == 'push'
run: |
docker push ghcr.io/${{ env.owner }}/eos_connect:${{ env.VERSION }}
docker push ghcr.io/${{ env.owner }}/eos_connect:latest