Skip to content

v1.0.4

v1.0.4 #54

Workflow file for this run

# Copyright (C) 2025 demigodmode
# SPDX-License-Identifier: AGPL-3.0-only
name: Release Docker Image and CLI Package
on:
release:
types: [published]
workflow_dispatch:
env:
REGISTRY_GHCR: ghcr.io
REGISTRY_DOCKER: docker.io
IMAGE_NAME: ${{ github.repository_owner }}/onesearch
jobs:
build-and-push:
runs-on: [self-hosted, linux, multiarch]
permissions:
contents: read
packages: write
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
- name: Build onesearch-cli package
run: |
uv run --with build python -m build cli
- name: Upload onesearch-cli artifacts
uses: actions/upload-artifact@v7
with:
name: onesearch-cli-release-dist
path: cli/dist/*
- name: Publish onesearch-cli to PyPI
if: github.event_name == 'release' && env.PYPI_API_TOKEN != ''
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ env.PYPI_API_TOKEN }}
run: |
uv run --with twine python -m twine upload cli/dist/*
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY_GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY_DOCKER }}
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Extract GHCR metadata (tags, labels)
id: meta-ghcr
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ github.event_name == 'release' }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=raw,value=manual,enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Extract Docker Hub metadata (tags, labels)
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
id: meta-dockerhub
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY_DOCKER }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ github.event_name == 'release' }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=raw,value=manual,enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Collect image tags
id: image-tags
shell: bash
run: |
{
echo 'tags<<EOF'
printf '%s\n' "${{ steps.meta-ghcr.outputs.tags }}"
if [ -n "${{ steps.meta-dockerhub.outputs.tags }}" ]; then
printf '%s\n' "${{ steps.meta-dockerhub.outputs.tags }}"
fi
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.image-tags.outputs.tags }}
labels: ${{ steps.meta-ghcr.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
platforms: linux/amd64,linux/arm64
# Temp fix for growing cache - move new cache to old location
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache