Add Homebrew, vim, and developer environment to containers #30
This file contains hidden or 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: 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=$(jq -r '."gaia-linux"' VERSION.json) | |
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | |
| echo "ERROR: gaia-linux version not found in VERSION.json" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "gaia-linux version: $VERSION" | |
| - name: Check if image tag already exists | |
| id: check_exists | |
| run: | | |
| if docker manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} > /dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Image tag ${{ steps.version.outputs.version }} already exists, skipping build." | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Image tag ${{ steps.version.outputs.version }} not found, will build." | |
| fi | |
| - name: Set up QEMU | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata | |
| if: steps.check_exists.outputs.exists != 'true' | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=${{ steps.version.outputs.version }} | |
| - name: Build and push | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: gaia-linux/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| update-description: | |
| runs-on: ubuntu-latest | |
| needs: [build-and-push, build-dev] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update version references in docs | |
| run: | | |
| LINUX_VERSION="${{ needs.build-and-push.outputs.version }}" | |
| DEV_VERSION="${{ needs.build-dev.outputs.version }}" | |
| # Update gaia-linux README image tags | |
| sed -i "s/gaia-linux:[0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?/gaia-linux:${LINUX_VERSION}/g" docs/gaia-linux/README.md | |
| sed -i "s/Current Image Version\*\*: [0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?/Current Image Version**: ${LINUX_VERSION}/g" docs/gaia-linux/README.md | |
| # Update gaia-dev README | |
| sed -i "s/gaia-dev:[0-9]\+\.[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?/gaia-dev:${DEV_VERSION}/g" docs/gaia-dev/README.md | |
| echo "Updated docs/gaia-linux/README.md with version ${LINUX_VERSION}" | |
| echo "Updated docs/gaia-dev/README.md with version ${DEV_VERSION}" | |
| - name: Update gaia-linux Docker Hub description | |
| uses: peter-evans/dockerhub-description@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: itomek/gaia-linux | |
| short-description: "AMD GAIA runtime container - GAIA installed from PyPI" | |
| readme-filepath: ./docs/gaia-linux/README.md | |
| - name: Update gaia-dev Docker Hub description | |
| uses: peter-evans/dockerhub-description@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: itomek/gaia-dev | |
| short-description: "AMD GAIA development container with Claude Code" | |
| readme-filepath: ./docs/gaia-dev/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=$(jq -r '."gaia-dev"' VERSION.json) | |
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | |
| echo "ERROR: gaia-dev version not found in VERSION.json" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "gaia-dev version: $VERSION" | |
| - name: Check if image tag already exists | |
| id: check_exists | |
| run: | | |
| if docker manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }} > /dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Image tag ${{ steps.version.outputs.version }} already exists, skipping build." | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Image tag ${{ steps.version.outputs.version }} not found, will build." | |
| fi | |
| - name: Set up QEMU | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata | |
| if: steps.check_exists.outputs.exists != 'true' | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=${{ steps.version.outputs.version }} | |
| - name: Build and push gaia-dev | |
| if: steps.check_exists.outputs.exists != 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: gaia-dev/Dockerfile | |
| platforms: linux/amd64 | |
| 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" |