From c080baad43f4bd6fd36379b89a560f10be77ac28 Mon Sep 17 00:00:00 2001 From: HUANG SIZHE Date: Mon, 26 Jul 2021 19:25:44 +0800 Subject: [PATCH] update --- .github/workflows/python-package-master.yml | 80 ------------------- ...hon-package-dev.yml => python-package.yml} | 6 +- .github/workflows/python-publish.yml | 47 ++++++++++- 3 files changed, 47 insertions(+), 86 deletions(-) delete mode 100644 .github/workflows/python-package-master.yml rename .github/workflows/{python-package-dev.yml => python-package.yml} (92%) diff --git a/.github/workflows/python-package-master.yml b/.github/workflows/python-package-master.yml deleted file mode 100644 index 3f32c23..0000000 --- a/.github/workflows/python-package-master.yml +++ /dev/null @@ -1,80 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - check: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.6, 3.7, 3.8, 3.9] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install devDependence - run: | - python -m pip install --upgrade pip - pip install mypy pycodestyle coverage lxml - - name: Install dependencies - run: | - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with pep8 - run: | - pycodestyle --max-line-length=140 --ignore=E501 --first --statistics portainer_deploy_tool - - name: Type Hint Check - run: | - mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --follow-imports=silent --check-untyped-defs --disallow-untyped-defs --no-implicit-optional --warn-unused-ignores portainer_deploy_tool - - docker-build: - needs: check - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=${{ secrets.DOCKER_HUB_USER }}/${GITHUB_REPOSITORY#*/} - VERSION=0.0.1 - SHORTREF=${GITHUB_SHA::8} - TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest" - # Set output parameters. - echo ::set-output name=tags::${TAGS} - echo ::set-output name=docker_image::${DOCKER_IMAGE} - - name: Set up QEMU - uses: docker/setup-qemu-action@master - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@master - - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_PWD }} - - - name: Build - uses: docker/build-push-action@v2 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.prep.outputs.tags }} \ No newline at end of file diff --git a/.github/workflows/python-package-dev.yml b/.github/workflows/python-package.yml similarity index 92% rename from .github/workflows/python-package-dev.yml rename to .github/workflows/python-package.yml index d7242f4..4969e4f 100644 --- a/.github/workflows/python-package-dev.yml +++ b/.github/workflows/python-package.yml @@ -5,7 +5,9 @@ name: Python package on: push: - branches: [dev] + branches: [master,dev] + pull_request: + branches: [master] jobs: check: @@ -32,4 +34,4 @@ jobs: pycodestyle --max-line-length=140 --ignore=E501 --first --statistics portainer_deploy_tool - name: Type Hint Check run: | - mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --follow-imports=silent --check-untyped-defs --disallow-untyped-defs --no-implicit-optional --warn-unused-ignores portainer_deploy_tool + mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --follow-imports=silent --check-untyped-defs --disallow-untyped-defs --no-implicit-optional --warn-unused-ignores portainer_deploy_tool \ No newline at end of file diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 07453be..bd8c0b3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -8,10 +8,8 @@ on: types: [created] jobs: - deploy: - + build_and_pub_to_pypi: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - name: Set up Python @@ -37,4 +35,45 @@ jobs: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: - twine upload dist/* \ No newline at end of file + twine upload dist/* + docker-build: + needs: build_and_pub_to_pypi + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=${{ secrets.DOCKER_HUB_USER }}/${GITHUB_REPOSITORY#*/} + VERSION=${GITHUB_REF/refs\/tags\//} + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest" + # Set output parameters. + echo ::set-output name=tags::${TAGS} + echo ::set-output name=docker_image::${DOCKER_IMAGE} + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_PWD }} + + - name: Build + uses: docker/build-push-action@v2 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.prep.outputs.tags }} \ No newline at end of file