download pylon using optional URLs #189
This file contains 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 | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: | |
- '**' | |
tags: | |
- '*.*.*' | |
pull_request: | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
TWINE_USERNAME: __token__ | |
# Uncomment the relevant lines to switch between deployment to test.pypi.org or pypi.org | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
# TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ | |
# TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
jobs: | |
prepare: | |
runs-on: ubuntu-22.04 | |
outputs: | |
is_release_build: ${{ env.RELEASE_BUILD == '1' }} | |
steps: | |
- uses: actions/cache@v3 | |
id: cache | |
with: | |
path: pylon-installer | |
key: pylon-installer-${{ hashFiles('pylon-installer.txt') }} | |
- name: Fetch installers | |
if: steps.cache.outputs.cache-hit != 'true' | |
env: | |
PYLON_DOWNLOAD_URL_BASE: ${{ secrets.PYLON_DOWNLOAD_URL_BASE }} | |
PYLON_DOWNLOAD_URL_BASE_7_4: ${{ secrets.PYLON_DOWNLOAD_URL_BASE_7_4 }} | |
run: | | |
mkdir pylon-installer && cd pylon-installer | |
URLS=( | |
"${PYLON_DOWNLOAD_URL_BASE_7_4}pylon-7.4.0.14900_linux-x86_64_setup.tar.gz ${PYLON_DOWNLOAD_URL_BASE_7_4}pylon_7.4.0.14900_linux_x86_64_setup.tar.gz " | |
"${PYLON_DOWNLOAD_URL_BASE_7_4}pylon_7_4_0_14900_linux_aarch64_setup.tar.gz ${PYLON_DOWNLOAD_URL_BASE_7_4}pylon-7.4.0.14900_linux-aarch64_setup.tar.gz" | |
"${PYLON_DOWNLOAD_URL_BASE}pylon_6.2.0.21487_armhf_setup.tar.gz ${PYLON_DOWNLOAD_URL_BASE}pylon-6.2.0.21487-armhf_setup.tar.gz" | |
"${PYLON_DOWNLOAD_URL_BASE}pylon_7_3_1_0011.dmg" | |
"${PYLON_DOWNLOAD_URL_BASE}basler_pylon_7_4_0_14900.exe" | |
) | |
download_file() { | |
local url="$1" | |
local filename="${url##*/}" | |
wget -q "$url" -O "$filename" | |
if [ $? -ne 0 ]; then | |
echo "Error downloading $filename" | |
return 1 | |
fi | |
} | |
# Iterate through the list of possible download URLs | |
for sublist in "${URLS[@]}"; do | |
success=false | |
# Split the sublist into individual URLs | |
read -ra urls <<< "$sublist" | |
for url in "${urls[@]}"; do | |
download_file "$url" | |
if [ $? -eq 0 ]; then | |
echo "Downloaded $url" | |
success=true | |
break # Successfully downloaded, move to the next sublist | |
fi | |
done | |
if [ "$success" = false ]; then | |
echo "None of the URLs were successfully downloaded." | |
exit 1 | |
fi | |
done | |
echo "All files downloaded successfully!" | |
md5sum * | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: pylon-installer | |
path: pylon-installer | |
- name: Check for release build | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
echo "Build release for $GITHUB_REF" | |
echo "RELEASE_BUILD=1" >> $GITHUB_ENV | |
build-linux: | |
needs: prepare | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
a: [cp36m, cp37m, cp38, cp39, cp3_10, cp3_11, cp3_12] | |
p: [manylinux_2_31_x86_64, manylinux_2_31_aarch64, manylinux_2_28_armv7l] | |
env: | |
P: ${{ matrix.p }} | |
A: ${{ matrix.a }} | |
# 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@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: pylon-installer | |
path: pylon-installer | |
- name: Build with docker | |
run: | | |
pwd | |
ls | |
ls pylon-installer | |
docker run --rm --privileged multiarch/qemu-user-static:register --reset | |
./scripts/build/build-arch.sh --platform-tag $P --abi-tag $A --pylon-dir ./pylon-installer $ARGS | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: build-results-${{ matrix.p }}-${{ matrix.a }} | |
path: dist/* | |
- name: Upload Release Asset | |
if: needs.prepare.outputs.is_release_build == 'true' | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: dist/* | |
- name: Publish package to (Test)PyPI | |
if: needs.prepare.outputs.is_release_build == 'true' && startsWith( matrix.p, 'manylinux' ) | |
run: | | |
sudo pip3 install twine | |
python3 -m twine upload --non-interactive --skip-existing dist/* | |
build-windows: | |
needs: prepare | |
runs-on: windows-2019 | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.6 - 3.12" | |
- uses: actions/download-artifact@v3 | |
with: | |
name: pylon-installer | |
path: pylon-installer | |
- name: Setup pylon | |
run: | | |
cd pylon-installer | |
basler_pylon_7_4_0_14900.exe /quiet /install="GigE_Support;USB_Support;Camera_Link_Support;CoaXPress_Support;GenTL_Consumer_Support;CamEmu_Support;SDKs;DataProcessing_SDK" | |
shell: cmd | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
PYLON_DEV_DIR: "C:\\Program Files\\Basler\\pylon 7\\Development" | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
- name: Upload Release Asset | |
if: needs.prepare.outputs.is_release_build == 'true' | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: ./wheelhouse/*.whl | |
- name: Publish package to (Test)PyPI | |
if: needs.prepare.outputs.is_release_build == 'true' | |
run: | | |
python -m pip install twine | |
python -m twine upload --non-interactive --skip-existing wheelhouse\\* | |
shell: cmd | |
build-macos: | |
needs: prepare | |
runs-on: macos-11 | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.6 - 3.12" | |
- uses: actions/download-artifact@v3 | |
with: | |
name: pylon-installer | |
path: pylon-installer | |
- name: Setup pylon | |
run: | | |
# install universal | |
cd pylon-installer | |
hdiutil attach pylon_*.dmg | |
sudo installer -pkg /Volumes/pylon\ *\ Camera\ Software\ Suite/pylon-*.pkg -target / | |
hdiutil detach /Volumes/pylon\ *\ Camera\ Software\ Suite | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
PYLON_FRAMEWORK_ARM64: /Library/Frameworks | |
PYLON_FRAMEWORK_X86_64: /Library/Frameworks | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
- name: Upload Release Asset | |
if: needs.prepare.outputs.is_release_build == 'true' | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: ./wheelhouse/*.whl | |
- name: Publish package to (Test)PyPI | |
if: needs.prepare.outputs.is_release_build == 'true' | |
run: | | |
sudo pip3 install twine | |
python3 -m twine upload --non-interactive --skip-existing wheelhouse/* | |
cleanup: | |
if: always() | |
needs: [ | |
prepare, | |
build-linux, | |
build-macos, | |
build-windows | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: geekyeggo/delete-artifact@v2 | |
continue-on-error: true | |
with: | |
name: pylon-installer | |