From 7cebd9fe61f6dbb76e9f78fcbcd3514d68204c87 Mon Sep 17 00:00:00 2001 From: Olivier Cervello Date: Mon, 8 Apr 2024 19:01:34 -0400 Subject: [PATCH] fix: docker build & push (#250) --- .github/workflows/publish.yml | 36 ++++++++++++++++++++++++++++++++++- secator/cli.py | 26 +++++++++++++------------ 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e340fd26..5b459d1e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.11"] steps: - name: Checkout repository uses: actions/checkout@v3 @@ -32,3 +32,37 @@ jobs: env: HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }} + publish-docker: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install secator + uses: ./.github/actions/install + with: + python-version: ${{ matrix.python-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: Build Docker image + run: secator u build docker + + - name: Publish Docker image + run: secator u publish docker + + diff --git a/secator/cli.py b/secator/cli.py index d0bf68a5..d37b3c4a 100644 --- a/secator/cli.py +++ b/secator/cli.py @@ -840,17 +840,18 @@ def record(record_name, script, interactive, width, height, output_dir): @utils.group('build') def build(): """Build secator.""" - if not DEV_PACKAGE: - console.print('[bold red]You MUST use a development version of secator to make builds.[/]') - sys.exit(1) - if not BUILD_ADDON_ENABLED: - console.print('[bold red]Missing dev addon: please run `secator install addons dev`') - sys.exit(1) + pass @build.command('pypi') def build_pypi(): """Build secator PyPI package.""" + if not DEV_PACKAGE: + console.print('[bold red]You MUST use a development version of secator to make builds.[/]') + sys.exit(1) + if not BUILD_ADDON_ENABLED: + console.print('[bold red]Missing build addon: please run `secator install addons build`') + sys.exit(1) with console.status('[bold gold3]Building PyPI package...[/]'): ret = Command.execute(f'{sys.executable} -m hatch build', name='hatch build', cwd=ROOT_FOLDER) sys.exit(ret.return_code) @@ -869,17 +870,18 @@ def build_docker(dev): @utils.group('publish') def publish(): """Publish secator.""" - if not DEV_PACKAGE: - console.print('[bold red]You MUST use a development version of secator to make releases.[/]') - sys.exit(1) - if not BUILD_ADDON_ENABLED: - console.print('[bold red]Missing dev addon: please run `secator install addons dev`') - sys.exit(1) + pass @publish.command('pypi') def publish_pypi(): """Publish secator PyPI package.""" + if not DEV_PACKAGE: + console.print('[bold red]You MUST use a development version of secator to make builds.[/]') + sys.exit(1) + if not BUILD_ADDON_ENABLED: + console.print('[bold red]Missing build addon: please run `secator install addons build`') + sys.exit(1) os.environ['HATCH_INDEX_USER'] = '__token__' hatch_token = os.environ.get('HATCH_INDEX_AUTH') if not hatch_token: