Skip to content

Merge pull request #7 from itomek/testing-updats #17

Merge pull request #7 from itomek/testing-updats

Merge pull request #7 from itomek/testing-updats #17

Workflow file for this run

name: Test, Publish, Release
on:
push:
branches: [main]
tags:
- 'v*'
workflow_dispatch: # Manual trigger
pull_request:
branches: [main]
permissions:
contents: write
env:
REGISTRY: docker.io
IMAGE_NAME: itomek/gaia-linux
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install test dependencies
run: uv sync --extra dev
- name: Run Dockerfile build tests
run: |
uv run pytest tests/test_dockerfile.py -v --tb=short
- name: Run entrypoint tests
run: |
uv run pytest tests/test_entrypoint.py -v --tb=short
- name: Run Dockerfile.dev build tests
run: |
uv run pytest tests/test_dockerfile_dev.py -v --tb=short
- name: Run entrypoint-dev tests
run: |
uv run pytest tests/test_entrypoint_dev.py -v --tb=short
- name: Run integration tests
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
uv run pytest tests/test_container.py -v --tb=short -m integration
build-and-push:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Read VERSION file
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "GAIA version: $VERSION"
- 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: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.version.outputs.version }}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: gaia-linux/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GAIA_VERSION=${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
update-description:
runs-on: ubuntu-latest
needs: build-and-push
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.IMAGE_NAME }}
short-description: "GAIA Linux runtime container"
readme-filepath: ./README.md
build-dev:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
env:
IMAGE_NAME: itomek/gaia-dev
steps:
- uses: actions/checkout@v4
- name: Read VERSION file
id: version
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "GAIA version: $VERSION"
- 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: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.version.outputs.version }}
type=sha
- name: Build and push gaia-dev
uses: docker/build-push-action@v5
with:
context: .
file: gaia-dev/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GAIA_VERSION=${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
create-release:
runs-on: ubuntu-latest
needs: [build-and-push, build-dev, update-description]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
VERSION="v${{ needs.build-and-push.outputs.version }}"
if gh release view "$VERSION" --repo "$GH_REPO" >/dev/null 2>&1; then
echo "Release $VERSION exists, deleting to overwrite."
gh release delete "$VERSION" --yes --repo "$GH_REPO"
fi
gh release create "$VERSION" \
--title "$VERSION" \
--notes "Docker images published:
- itomek/gaia-linux:${{ needs.build-and-push.outputs.version }}
- itomek/gaia-dev:${{ needs.build-dev.outputs.version }}" \
--target "${{ github.sha }}" \
--repo "$GH_REPO"