Skip to content

Commit

Permalink
Test workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
sohma440 committed May 20, 2024
1 parent 05f35b3 commit 1c97f5b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 20 deletions.
79 changes: 73 additions & 6 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Upload Python Package

on:
push:
release:
types: [published]

env:
REGISTRY: ghcr.io
DOCKER_REGISTRY: docker.io
DOCKER_REGISTRY_USER: pinto0309
DOCKER_REGISTRY_USER: sohma440
IMAGE_NAME: ${{ github.repository }}

jobs:
pypi-deploy:
# todo
if: ${{ false }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -32,16 +35,19 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

docker-deploy:
build:
runs-on: ubuntu-latest
needs: pypi-deploy
# todo
# needs: pypi-deploy
permissions:
contents: read
packages: write
strategy:
fail-fast: false # do not cancel even if any platform fails.
matrix:
platform: [linux/amd64,linux/arm64]
platform:
- linux/amd64
- linux/arm64
steps:
- name: Git checkout
uses: actions/checkout@v3
Expand All @@ -50,6 +56,11 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Log in to the GitHub Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
Expand All @@ -61,6 +72,7 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
Expand All @@ -81,11 +93,66 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc

- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta_dh.outputs.tags }}
labels: ${{ steps.meta_dh.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Log in to the Docker Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DH_ACCESS_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
29 changes: 15 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ RUN pip install pip -U \
# Re-release flatc with some customizations of our own to address
# the lack of arithmetic precision of the quantization parameters
# https://github.com/PINTO0309/onnx2tf/issues/196
RUN wget https://github.com/PINTO0309/onnx2tf/releases/download/1.16.31/flatc.tar.gz \
&& tar -zxvf flatc.tar.gz \
&& chmod +x flatc \
&& mv flatc /usr/bin/
# todo
# RUN wget https://github.com/PINTO0309/onnx2tf/releases/download/1.16.31/flatc.tar.gz \
# && tar -zxvf flatc.tar.gz \
# && chmod +x flatc \
# && mv flatc /usr/bin/

ENV USERNAME=user
RUN echo "root:root" | chpasswd \
&& adduser --disabled-password --gecos "" "${USERNAME}" \
&& echo "${USERNAME}:${USERNAME}" | chpasswd \
&& echo "%${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME}
USER ${USERNAME}
ARG WKDIR=/workdir
WORKDIR ${WKDIR}
RUN sudo chown ${USERNAME}:${USERNAME} ${WKDIR}
# ENV USERNAME=user
# RUN echo "root:root" | chpasswd \
# && adduser --disabled-password --gecos "" "${USERNAME}" \
# && echo "${USERNAME}:${USERNAME}" | chpasswd \
# && echo "%${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/${USERNAME} \
# && chmod 0440 /etc/sudoers.d/${USERNAME}
# USER ${USERNAME}
# ARG WKDIR=/workdir
# WORKDIR ${WKDIR}
# RUN sudo chown ${USERNAME}:${USERNAME} ${WKDIR}

RUN echo 'export CUDA_VISIBLE_DEVICES=-1' >> ${HOME}/.bashrc \
&& echo 'export TF_CPP_MIN_LOG_LEVEL=3' >> ${HOME}/.bashrc

0 comments on commit 1c97f5b

Please sign in to comment.