Build, Test & Publush #920
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a basic workflow to help you get started with Actions | |
| name: Build, Test & Publush | |
| # Controls when the action will run. | |
| on: | |
| # Triggers the workflow on all push or pull request events | |
| push: | |
| pull_request: | |
| release: | |
| types: [published] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| # added using https://github.com/step-security/secure-repo | |
| permissions: | |
| contents: read | |
| # Cancels previous runs of this workflow for the same PR | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' || startsWith(github.ref_name, 'codex/') || github.ref_name == 'wip' }} | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| build_test: | |
| name: 'Build&Test: C' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos, ubuntu] | |
| runs-on: ${{ matrix.os }}-latest | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v4 | |
| - name: Install Dependencies (Ubuntu) | |
| if: matrix.os == 'ubuntu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y bmake cmake | |
| - name: Install Dependencies (macOS) | |
| if: matrix.os == 'macos' | |
| run: | | |
| brew update | |
| brew install bmake cmake | |
| - name: Build with GNU Make | |
| run: make clean all | |
| - name: Test with GNU Make | |
| run: make test | |
| - name: Build with BSD Make | |
| run: bmake clean all | |
| - name: Test with BSD Make | |
| run: bmake test | |
| - name: Build with CMake | |
| run: | | |
| cmake -B build | |
| make -C build clean all | |
| - name: Test with CMake | |
| run: bmake -C build test | |
| - name: Build iOS Framework (macos) | |
| if: matrix.os == 'macos' | |
| run: ONLY_BUILD=yes sh -x scripts/build/build_ios.sh | |
| - name: Setup GitHub Actions artifact client | |
| if: matrix.os == 'macos' | |
| uses: lhotari/gh-actions-artifact-client@v2 | |
| - name: Upload Artifacts | |
| if: matrix.os == 'macos' | |
| run: | | |
| set -euo pipefail | |
| name="g722.xcframework" | |
| file="${name}.zip" | |
| echo "Uploading ${name}, file: ${file}" | |
| zip - "${file}" | gh-actions-artifact-client.js upload "${name}" --retentionDays=7 | |
| build_test_python: | |
| name: 'Build&Test: Python' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14-dev'] | |
| compiler: ['gcc', 'clang'] | |
| os: [macos, ubuntu] | |
| include: | |
| - python-version: '3.10' | |
| compiler: microsoft | |
| os: windows | |
| - python-version: '3.11' | |
| compiler: microsoft | |
| os: windows | |
| - python-version: '3.12' | |
| compiler: microsoft | |
| os: windows | |
| - python-version: '3.13' | |
| compiler: microsoft | |
| os: windows | |
| - python-version: '3.14-dev' | |
| compiler: microsoft | |
| os: windows | |
| runs-on: ${{ matrix.os }}-latest | |
| env: | |
| COMPILER: ${{ matrix.compiler }} | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install --upgrade setuptools wheel | |
| shell: bash | |
| - name: build core | |
| run: | | |
| rm -rf dist build | |
| CC=${COMPILER} python setup.py sdist build | |
| shell: bash | |
| - name: install core | |
| run: pip install --force-reinstall dist/[Gg]722-*.gz | |
| shell: bash | |
| - name: test core | |
| if: matrix.os != 'windows' | |
| run: ./scripts/do-test.sh "python test.py" | |
| shell: bash | |
| - name: unit tests (core smoke) | |
| run: python -m unittest discover tests 'test_decode.py' | |
| shell: bash | |
| - name: build numpy addon | |
| run: | | |
| rm -rf build | |
| LIBG722_PACKAGE_VARIANT=numpy-addon CC=${COMPILER} python setup.py sdist build | |
| shell: bash | |
| - name: install numpy addon | |
| run: LIBG722_PACKAGE_VARIANT=numpy-addon pip install --force-reinstall --find-links dist dist/*numpy*.gz | |
| shell: bash | |
| - name: test with numpy addon | |
| if: matrix.os != 'windows' | |
| run: ./scripts/do-test.sh "python test.py" | |
| shell: bash | |
| - name: unit tests | |
| run: python -m unittest discover tests '*.py' | |
| shell: bash | |
| build_wheels: | |
| name: Build Python Wheels | |
| permissions: | |
| packages: write | |
| needs: [build_test_python] | |
| uses: sippy/cimagic/.github/workflows/BuildPythonWheels.yml@v2 | |
| with: | |
| maximize_space: true | |
| publish_all_wheels: | |
| name: Publish Python Wheels | |
| needs: [build_wheels, build_in_docker] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/G722 | |
| permissions: | |
| actions: read | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: 'dist-*' | |
| merge-multiple: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools wheel | |
| - name: Build SDist | |
| run: | | |
| rm -rf dist | |
| python setup.py sdist | |
| LIBG722_PACKAGE_VARIANT=numpy-addon python setup.py sdist | |
| - name: Show context tree | |
| run: ls -lR dist | |
| - name: Check release version number | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| run: | | |
| GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | |
| GIT_BRANCH="${GIT_BRANCH#refs/tags/}" | |
| python setup.py checkversion --tag="${GIT_BRANCH}" | |
| LIBG722_PACKAGE_VARIANT=numpy-addon python setup.py checkversion --tag="${GIT_BRANCH}" | |
| - name: Publish package distributions to PyPI | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| build_in_docker: | |
| name: Build in Docker | |
| needs: [build_test] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| base_image: ['debian:sid-slim', 'debian:12-slim', 'debian:13-slim', 'ubuntu:latest'] | |
| env: | |
| DOCKER_REPO: sippylabs/libg722 | |
| BASE_IMAGE: ${{ matrix.base_image }} | |
| DOCKER_RW: ${{ ( github.repository == 'sippy/libg722' && github.event_name != 'pull_request' ) && 'true' || 'false' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| id: qemu | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to Docker Hub | |
| if: env.DOCKER_RW == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Set environments | |
| run: | | |
| # mips64 seems to be broken at the moment... | |
| if [ "${{ env.BASE_IMAGE }}" = "debian:sid-slim" ] | |
| then | |
| FILT="grep -v mips64le" | |
| else | |
| FILT="cat" | |
| fi | |
| PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \ | |
| jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \ | |
| sort -u | grep -v unknown | ${FILT} | paste -sd ','`" | |
| echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV | |
| GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | |
| GIT_BRANCH="${GIT_BRANCH#refs/tags/}" | |
| echo "GIT_BRANCH=${GIT_BRANCH}" >> $GITHUB_ENV | |
| OS_TAG="`echo ${BASE_IMAGE} | sed 's|:|_|g'`" | |
| echo "OS_TAG=${OS_TAG}" >> $GITHUB_ENV | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_REPO }} | |
| tags: | | |
| type=schedule,suffix=-${{ env.OS_TAG}} | |
| type=ref,event=branch,suffix=-${{ env.OS_TAG }} | |
| type=ref,event=tag,suffix=-${{ env.OS_TAG }} | |
| type=ref,event=pr,suffix=-${{ env.OS_TAG }} | |
| type=raw,value=latest-${{ env.OS_TAG }},enable={{is_default_branch}} | |
| type=sha,suffix=-${{ env.OS_TAG }} | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v6 | |
| env: | |
| CACHE_SPEC: "type=registry,ref=${{ env.DOCKER_REPO }}:${{ env.GIT_BRANCH }}-${{ env.OS_TAG}}-buildcache" | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile.build | |
| build-args: | | |
| BASE_IMAGE=${{ env.BASE_IMAGE }} | |
| platforms: ${{ env.PLATFORMS }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| push: ${{ env.DOCKER_RW }} | |
| cache-from: ${{ env.CACHE_SPEC }} | |
| cache-to: ${{ env.CACHE_SPEC }},mode=max | |
| build_packages: | |
| name: Build Packages | |
| needs: [build_test] | |
| uses: sippy/cimagic/.github/workflows/BuildDPKGs.yml@v2 | |
| with: | |
| apt_depends: pkg-config cmake ninja-build | |
| roll_release: | |
| name: Release | |
| needs: [publish_all_wheels, build_packages] | |
| permissions: | |
| contents: write | |
| uses: sippy/cimagic/.github/workflows/RollReleaseDraft.yml@v2 | |
| with: | |
| release_files_artifacts: | | |
| g722.xcframework | |
| ${{ needs.build_packages.outputs.dpkgs_artifacts }} |