Skip to content

docker onefile

docker onefile #65

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build
on:
push:
branches: ["master", "main"]
pull_request:
branches: ["master", "main"]
permissions:
contents: read
pull-requests: read
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- run: pip install flake8
- name: check Python syntax errors or undefined names
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: check complexity and length # the GitHub editor is 127 chars wide
run: flake8 . --count --max-complexity=12 --max-line-length=127 --statistics
pypi:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- name: Build package
run: python -m build --sdist --wheel --outdir dist/
- uses: actions/upload-artifact@v4
with:
name: pypi
path: dist/
retention-days: 5
pyinstaller:
strategy:
# fail-fast: false
matrix:
os: [windows, macos, ubuntu]
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 8
steps:
- uses: actions/checkout@v4
- name: Set up Python "3.x"
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: pip install pyinstaller
# Prepare build version and cert
- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
- name: Copy cert on ubuntu
if: runner.os == 'Linux'
run: cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem
- run: python ./run.py -h
- name: Package binary
run: python -O -m PyInstaller --noconfirm --clean .build/ddns.spec
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h
# Upload build result
- uses: actions/upload-artifact@v4
with:
name: PyInstaller-${{ matrix.os }}
path: dist/
retention-days: 3
nuitka:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
arch: x64
- os: windows-latest
arch: x86
- os: windows-11-arm
arch: arm64
- os: ubuntu-latest
arch: x64
- os: ubuntu-24.04-arm
arch: arm64
- os: macos-13
arch: x64
- os: macos-latest
arch: arm64
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: 3.x
architecture: ${{ matrix.arch }}
- name: Install dependencies
run: python3 -m pip install -U nuitka
# Prepare build version and cert
- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
- name: Set up on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y patchelf
echo " --static-libpython=yes --linux-icon=.build/icon.png" >> .build/nuitka.cmd
cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem
- name: Set up on macOS
if: runner.os == 'macOS'
run: |
python3 -m pip install imageio
echo " --macos-app-name=DDNS --macos-app-icon=.build/icon.png" >> .build/nuitka.cmd
- run: python3 ./run.py -h
- name: Package binary
run: ./.build/nuitka.cmd
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h
# Upload build result
- uses: actions/upload-artifact@v4
with:
name: ddns-${{ runner.os }}-${{ matrix.arch }}
path: dist/
retention-days: 7
docker:
if: github.event_name == 'pull_request'
strategy:
matrix:
platforms: [ linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x ]
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platforms }}
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
load: true
file: .build/Dockerfile
platforms: ${{ matrix.platforms }}
tags: ddns:test
- name: test help command
run: docker run --rm ddns:test -h
- name: test config generation
run: docker run --rm -v "$(pwd)":/ddns/ ddns:test || test -e config.json
preview-pypi:
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [lint, pypi]
timeout-minutes: 3
environment:
name: preview
url: https://test.pypi.org/project/ddns/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: pypi
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
print-hash: true
preview-docker:
runs-on: ubuntu-latest
if: github.event_name == 'push'
timeout-minutes: 120
environment:
name: preview
url: https://github.com/NewFuture/DDNS/pkgs/container/ddns/?tag=master
permissions:
packages: write
env:
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x
steps:
- uses: actions/checkout@v4
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.platforms }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/newfuture/ddns
newfuture/ddns
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- uses: docker/build-push-action@v6
with:
context: .
file: .build/Dockerfile
platforms: ${{ env.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}