diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 15d5ac2e..619442d1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,6 +13,8 @@ on: - main - '20[1-9][0-9]_R[1-9]' - staging/* + tags: + - 'v*' pull_request: branches: - main @@ -135,14 +137,28 @@ jobs: if-no-files-found: error build_macos: - runs-on: macos-14 needs: identify_version + strategy: + fail-fast: false + matrix: + include: + - runs-on: macos-15-large + arch: x64 + - runs-on: macos-14 + arch: arm64 + runs-on: ${{ matrix.runs-on }} env: LIBIIO_VERSION: libiio-v0 GLOG_VERSION: v0.4.0 + ARTIFACTNAME: macos-${{ matrix.arch }} steps: - name: Checkout code repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 + + - name: Select Python 3.11 for main build + uses: actions/setup-python@v7 + with: + python-version: '3.11' - name: Install dependencies run: CI/macOS/install_deps @@ -150,11 +166,262 @@ jobs: - name: Build libm2k run: CI/macOS/make_macOS + - name: Use Python 3.9 + uses: actions/setup-python@v7 + with: + python-version: '3.9' + - name: Wheel Python 3.9 + run: | + python3 -m pip install wheel twine build virtualenv + cd build + mkdir -p wheelhouse + COMPILE_BINDINGS=True python3 -m build + cp dist/*.whl wheelhouse/ + + - name: Use Python 3.10 + uses: actions/setup-python@v7 + with: + python-version: '3.10' + - name: Wheel Python 3.10 + run: | + python3 -m pip install wheel twine build virtualenv + cd build + mkdir -p wheelhouse + COMPILE_BINDINGS=True python3 -m build + cp dist/*.whl wheelhouse/ + + - name: Use Python 3.11 + uses: actions/setup-python@v7 + with: + python-version: '3.11' + - name: Wheel Python 3.11 + run: | + python3 -m pip install wheel twine build virtualenv + cd build + mkdir -p wheelhouse + COMPILE_BINDINGS=True python3 -m build + cp dist/*.whl wheelhouse/ + + - name: Use Python 3.12 + uses: actions/setup-python@v7 + with: + python-version: '3.12' + - name: Wheel Python 3.12 + run: | + python3 -m pip install wheel twine build virtualenv + cd build + mkdir -p wheelhouse + COMPILE_BINDINGS=True python3 -m build + cp dist/*.whl wheelhouse/ + + - name: Use Python 3.13 + uses: actions/setup-python@v7 + with: + python-version: '3.13' + - name: Wheel Python 3.13 + run: | + python3 -m pip install wheel twine build virtualenv + cd build + mkdir -p wheelhouse + COMPILE_BINDINGS=True python3 -m build + cp dist/*.whl wheelhouse/ + + - name: Use Python 3.14 + uses: actions/setup-python@v7 + with: + python-version: '3.14' + - name: Wheel Python 3.14 + run: | + python3 -m pip install wheel twine build virtualenv + cd build + mkdir -p wheelhouse + COMPILE_BINDINGS=True python3 -m build + cp dist/*.whl wheelhouse/ + - name: Upload macOS artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: - name: ${{env.APP_NAME}}-macos-arm64 + name: ${{env.APP_NAME}}-macos-${{matrix.arch}} path: | build/*.pkg build_tar/*.tar.gz + build/wheelhouse/*.whl + libiio/build/*.pkg + libiio/build_tar/*.tar.gz + if-no-files-found: error + + - name: Upload to testPyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + run: | + python3 -m pip install --upgrade twine + python3 -m twine upload --repository testpypi build/wheelhouse/*.whl + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + + build_windows: + runs-on: windows-2022 + needs: identify_version + env: + BUILD_SOURCESDIRECTORY: ${{ github.workspace }} + BUILD_ARTIFACTSTAGINGDIRECTORY: ${{ github.workspace }}/staging + COMPILER: Visual Studio 17 2022 + ARCH: x64 + PLATFORM: win64 + LIBIIO_VERSION: libiio-v0 + steps: + - name: Checkout code repository + uses: actions/checkout@v6 + + - name: Select Python 3.11 for main build + uses: actions/setup-python@v7 + with: + python-version: '3.11' + + - name: Install dependencies + shell: pwsh + run: ./CI/windows/install_deps.ps1 + + - name: Build libm2k + shell: pwsh + run: ./CI/windows/make_windows.ps1 + + - name: Use Python 3.9 + uses: actions/setup-python@v7 + with: + python-version: '3.9' + - name: Wheel Python 3.9 + shell: pwsh + run: | + $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY + $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName + $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" + Set-Location $TEMP_BUILD_DIR + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") + Set-Location $SRC_DIR + + - name: Use Python 3.10 + uses: actions/setup-python@v7 + with: + python-version: '3.10' + - name: Wheel Python 3.10 + shell: pwsh + run: | + $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY + $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName + $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" + Set-Location $TEMP_BUILD_DIR + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") + Set-Location $SRC_DIR + + - name: Use Python 3.11 + uses: actions/setup-python@v7 + with: + python-version: '3.11' + - name: Wheel Python 3.11 + shell: pwsh + run: | + $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY + $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName + $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" + Set-Location $TEMP_BUILD_DIR + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") + Set-Location $SRC_DIR + + - name: Use Python 3.12 + uses: actions/setup-python@v7 + with: + python-version: '3.12' + - name: Wheel Python 3.12 + shell: pwsh + run: | + $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY + $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName + $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" + Set-Location $TEMP_BUILD_DIR + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") + Set-Location $SRC_DIR + + - name: Use Python 3.13 + uses: actions/setup-python@v7 + with: + python-version: '3.13' + - name: Wheel Python 3.13 + shell: pwsh + run: | + $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY + $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName + $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" + Set-Location $TEMP_BUILD_DIR + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") + Set-Location $SRC_DIR + + - name: Use Python 3.14 + uses: actions/setup-python@v7 + with: + python-version: '3.14' + - name: Wheel Python 3.14 + shell: pwsh + run: | + $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY + $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName + $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" + $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" + Set-Location $TEMP_BUILD_DIR + python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv + $env:COMPILE_BINDINGS = $true + python.exe -m build + Remove-Item Env:COMPILE_BINDINGS + Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") + Set-Location $SRC_DIR + + - name: Create artifact staging directory + shell: pwsh + run: New-Item -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY -ItemType Directory -Force + + - name: Create libm2k-system-setup installer + shell: pwsh + run: ./CI/windows/create_installer.ps1 + + - name: Upload installer artifact + uses: actions/upload-artifact@v7 + with: + name: Libm2k-System-Setup-Exe + path: ${{ github.workspace }}/staging/installer/*.exe + if-no-files-found: error + + - name: Create ZIPs + shell: pwsh + run: ./CI/windows/create_zips.ps1 + + - name: Upload Windows folder artifact + uses: actions/upload-artifact@v7 + with: + name: Windows-VS-2022-x64 + path: ${{ github.workspace }}/staging/libm2k-win64 if-no-files-found: error diff --git a/CI/macOS/install_deps b/CI/macOS/install_deps index 10cf5fd3..e30e2141 100755 --- a/CI/macOS/install_deps +++ b/CI/macOS/install_deps @@ -48,6 +48,7 @@ build_libiio() { mkdir -p build && cd build cmake "${WORKDIR}"/libiio \ -Werror=dev \ + -Wno-error=install-absolute-destination \ -DCOMPILE_WARNING_AS_ERROR=ON \ -DOSX_PACKAGE=ON \ -DCPP_BINDINGS=ON \ @@ -64,6 +65,7 @@ build_libiio() { mkdir -p build_tar && cd build_tar cmake "${WORKDIR}"/libiio \ -Werror=dev \ + -Wno-error=install-absolute-destination \ -DCOMPILE_WARNING_AS_ERROR=ON \ -DOSX_PACKAGE=OFF \ -DENABLE_PACKAGING=ON \ @@ -83,6 +85,7 @@ build_libiio() { cd "${WORKDIR}"/libiio/build cmake "${WORKDIR}"/libiio \ -Werror=dev \ + -Wno-error=install-absolute-destination \ -DCOMPILE_WARNING_AS_ERROR=ON \ -DCPP_BINDINGS=ON \ -DPYTHON_BINDINGS=ON \ diff --git a/CI/windows/create_installer.ps1 b/CI/windows/create_installer.ps1 index 9a57ef40..eb862e41 100644 --- a/CI/windows/create_installer.ps1 +++ b/CI/windows/create_installer.ps1 @@ -17,7 +17,17 @@ Write-Output "INSTALLER_PATH to $INSTALLER_PATH" Set-Location $SRC_DIR -ISCC (Join-Path $BUILD_DIR "libm2k.iss") + +# libm2k.iss.cmakein hard-codes the Azure DevOps layout (sources at D:\a\1\s, +# build root at D:\a\1). Rewrite those literals to the actual paths so the +# installer builds on any runner. No-op on Azure, where they already match. +$iss = Join-Path $BUILD_DIR "libm2k.iss" +(Get-Content $iss) ` + -replace [regex]::Escape("D:\a\1\s"), $SRC_DIR.FullName ` + -replace [regex]::Escape("D:\a\1"), $OUTSIDE_BUILD | + Set-Content $iss + +ISCC $iss $ARTIFACTS_DIR = Get-Item -Path $env:BUILD_ARTIFACTSTAGINGDIRECTORY # path to repo New-Item -Path (Join-Path $ARTIFACTS_DIR "installer") -ItemType Directory diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 68ba422a..e1e5b21c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -75,161 +75,3 @@ jobs: inputs: targetPath: '$(Build.ArtifactStagingDirectory)' artifactName: '$(artifactName)' - -- job: macOSBuilds - workspace: - clean: all - strategy: - matrix: - macOS_14_x64: - poolName: 'Azure Pipelines' - vmImage: 'macOS-14' - artifactName: 'macOS-14-x64' - # TODO: discuss with DevOps team how to setup ARM agent - # macOS_13_arm64: - # poolName: 'Default' - # vmImage: - # agentName: 'macOS_arm64' - # artifactName: 'macOS-13-arm64' - pool: - name: $(poolName) - vmImage: $(vmImage) - steps: - - checkout: self - fetchDepth: 1 - clean: true - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.11' - addToPath: true - - script: ./CI/macOS/install_deps - displayName: "Install Dependencies" - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/libiio/build/' - contents: '$(Agent.BuildDirectory)/s/libiio/build/?(*.pkg)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/libiio/build_tar/' - contents: '$(Agent.BuildDirectory)/s/libiio/build_tar/?(*.tar.gz)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - script: ./CI/macOS/make_macOS - displayName: "Build" - - ${{ each pyVersion in parameters.pythonVersions }}: - - task: UsePythonVersion@0 - displayName: Use Python ${{ pyVersion }} - inputs: - versionSpec: '${{ pyVersion }}' - - script: | - python3 --version - python3 -m pip install wheel twine build virtualenv - cd '$(Agent.BuildDirectory)/s/build/' - mkdir -p wheelhouse - export COMPILE_BINDINGS=True - python3 -m build - export COMPILE_BINDINGS= - cp dist/*.whl wheelhouse - displayName: Wheel Python ${{ pyVersion }} - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/?(*.pkg)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build/' - contents: '$(Agent.BuildDirectory)/s/build/wheelhouse/?(*.whl)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - inputs: - sourceFolder: '$(Agent.BuildDirectory)/s/build_tar/' - contents: '$(Agent.BuildDirectory)/s/build_tar/?(*.tar.gz)' - targetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishPipelineArtifact@1 - condition: succeeded() - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: '$(artifactName)' - - script: | - python -m pip install --upgrade pip twine - cd '$(Agent.BuildDirectory)/s/build/wheelhouse/' - python -m twine upload --repository "testpypi" *.whl - condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) - displayName: "Upload to PyPI" - env: - TWINE_USERNAME: '__token__' - TWINE_PASSWORD: $(TWINE_PASSWORD) - -- job: WindowsBuilds - workspace: - clean: all - strategy: - matrix: - VS_2022: - poolName: 'Azure Pipelines' - vmImage: 'windows-2022' - COMPILER: 'Visual Studio 17 2022' - ARCH: 'x64' - PLATFORM: 'win64' - artifactName: 'Windows-VS-2022-x64' - pool: - vmImage: $[ variables['vmImage'] ] - steps: - - checkout: self - fetchDepth: 1 - clean: true - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.11' - - task: PowerShell@2 - displayName: 'Install Dependencies' - inputs: - targetType: filePath - filePath: ./CI/windows/install_deps.ps1 - - task: PowerShell@2 - displayName: "Build libm2k" - inputs: - targetType: 'filePath' - filePath: ./CI/windows/make_windows.ps1 - - ${{ each pyVersion in parameters.pythonVersions }}: - - task: UsePythonVersion@0 - displayName: Use Python ${{ pyVersion }} - inputs: - versionSpec: '${{ pyVersion }}' - - powershell: | - $SRC_DIR = Get-Item -Path $env:BUILD_SOURCESDIRECTORY - $OUTSIDE_BUILD = $SRC_DIR.Parent.FullName - - $BUILD_DIR = Join-Path $OUTSIDE_BUILD "libm2k-$env:PLATFORM" - $TEMP_BUILD_DIR = Join-Path $SRC_DIR "tmp-build-$env:PLATFORM" - - Set-Location $TEMP_BUILD_DIR - python.exe -m pip install --user --upgrade pip setuptools wheel twine build virtualenv - $env:COMPILE_BINDINGS = $true - python.exe -m build - Remove-Item Env:COMPILE_BINDINGS - Copy-Item -Path "dist/libm2k*.whl" -Destination (Join-Path $BUILD_DIR "dist") - Set-Location $SRC_DIR - displayName: Wheel Python ${{ pyVersion }} - - task: PowerShell@2 - displayName: 'Create libm2k-system-setup installer' - condition: and(succeeded(), eq(variables['System.JobName'], 'VS_2022')) - inputs: - targetType: 'filePath' - filePath: ./CI/windows/create_installer.ps1 - - task: PublishPipelineArtifact@1 - condition: and(succeeded(), eq(variables['System.JobName'], 'VS_2022')) - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/installer' - artifactName: 'Libm2k-System-Setup-Exe' - - task: PowerShell@2 - displayName: "Create ZIPs" - inputs: - targetType: 'filePath' - filePath: ./CI/windows/create_zips.ps1 - - task: PublishPipelineArtifact@1 - condition: succeeded() - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/libm2k-$(PLATFORM)' - artifactName: '$(artifactName)'