radioconda/.github/workflows/build_radioconda.yml
2024-05-16 12:11:53 -04:00

210 lines
6.8 KiB
YAML

name: Build radioconda
on:
push:
paths:
- "installer_specs/**"
pull_request:
paths:
- "installer_specs/**"
workflow_dispatch:
env:
DISTNAME: radioconda
LICENSE_ID: BSD-3-Clause
METAPACKAGE_LABEL: main
METAPACKAGE_SUMMARY: Metapackage to install the radioconda package set.
jobs:
build:
name: ${{ matrix.PLATFORM }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
PLATFORM: linux-64
OS_NAME: Linux
ARCH: x86_64
- os: ubuntu-latest
PLATFORM: linux-aarch64
OS_NAME: Linux
ARCH: aarch64
EMU_ARCH: aarch64
EMU_DISTRO: ubuntu_latest
- os: ubuntu-latest
PLATFORM: linux-ppc64le
OS_NAME: Linux
ARCH: ppc64le
EMU_ARCH: ppc64le
EMU_DISTRO: ubuntu_latest
- os: macos-13
PLATFORM: osx-64
OS_NAME: MacOSX
ARCH: x86_64
- os: macos-latest
PLATFORM: osx-arm64
OS_NAME: MacOSX
ARCH: arm64
- os: windows-latest
PLATFORM: win-64
OS_NAME: Windows
ARCH: x86_64
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install coreutils for macOS
if: runner.os == 'macOS'
run: brew install coreutils
- name: Install python environment
uses: mamba-org/setup-micromamba@v1
with:
environment-file: installer_specs/buildenv.conda-lock.yml
environment-name: buildenv
- name: Build installer
shell: bash -l {0}
env:
PLATFORM: ${{ matrix.PLATFORM }}
OS_NAME: ${{ matrix.OS_NAME }}
run: |
if [ "$OS_NAME" == "Windows" ]; then
PATH=$CONDA_PREFIX/NSIS:$PATH
fi
python build_installer.py installer_specs/$DISTNAME-$PLATFORM -- -v
- name: Build metapackage
shell: bash -l {0}
env:
PLATFORM: ${{ matrix.PLATFORM }}
run: |
python build_metapackage.py installer_specs/$DISTNAME-$PLATFORM.yml
- name: Copy lock file and list built installers and packages
shell: bash
env:
PLATFORM: ${{ matrix.PLATFORM }}
run: |
cp installer_specs/$DISTNAME-$PLATFORM.lock dist/
ls -lhR dist
- name: Test installer (sh native)
if: (contains(matrix.OS_NAME, 'Linux') || contains(matrix.OS_NAME, 'MacOSX')) && matrix.EMU_ARCH == null
shell: bash
env:
OS_NAME: ${{ matrix.OS_NAME }}
ARCH: ${{ matrix.ARCH }}
INSTALL_PATH: ${{ github.workspace }}/test_installation
run: |
bash dist/$DISTNAME-*-$OS_NAME-$ARCH.sh -b -p $INSTALL_PATH
eval "$($INSTALL_PATH/bin/conda shell.bash hook)"
conda info
conda list
- name: Test installer (sh emulated)
if: (contains(matrix.OS_NAME, 'Linux') || contains(matrix.OS_NAME, 'MacOSX')) && matrix.EMU_ARCH != null
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.EMU_ARCH }}
distro: ${{ matrix.EMU_DISTRO }}
dockerRunArgs: --volume "${PWD}:/workdir"
env: |
DISTNAME: ${{ env.DISTNAME }}
OS_NAME: ${{ matrix.OS_NAME }}
ARCH: ${{ matrix.ARCH }}
INSTALL_PATH: /workdir/test_installation
run: |
bash dist/$DISTNAME-*-$OS_NAME-$ARCH.sh -b -p $INSTALL_PATH
eval "$($INSTALL_PATH/bin/conda shell.bash hook)"
conda info
conda list
- name: Test installer (pkg)
if: contains(matrix.OS_NAME, 'MacOSX')
shell: bash
env:
OS_NAME: ${{ matrix.OS_NAME }}
ARCH: ${{ matrix.ARCH }}
TARGET_VOLUME: CurrentUserHomeDirectory
INSTALL_PATH: ${{ github.workspace }}/../../../${{ env.DISTNAME }}
run: |
cat >pkg-choices.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>attributeSetting</key>
<integer>0</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>io.continuum.pkg.pathupdate</string>
</dict>
</array>
</plist>
EOF
installer -verbose -dumplog -applyChoiceChangesXML pkg-choices.xml -pkg dist/$DISTNAME-*-$OS_NAME-$ARCH.pkg -target $TARGET_VOLUME
eval "$($INSTALL_PATH/bin/conda shell.bash hook)"
conda info
conda list
- name: Test installer (exe)
if: contains(matrix.OS_NAME, 'Windows')
shell: bash
env:
OS_NAME: ${{ matrix.OS_NAME }}
ARCH: ${{ matrix.ARCH }}
INSTALL_PATH_W: ${{ github.workspace }}\test_installation
run: |
INSTALL_PATH=$(cygpath -u $INSTALL_PATH_W)
INSTALLER_EXE="dist/$DISTNAME-*-$OS_NAME-$ARCH.exe"
INSTALLER_EXE_W=$(cygpath -w $INSTALLER_EXE)
echo "start /wait \"\" $INSTALLER_EXE_W /InstallationType=JustMe /RegisterPython=0 /S /D=$INSTALL_PATH_W" > install.bat
cmd.exe //c install.bat
eval "$($INSTALL_PATH/Scripts/conda.exe shell.bash hook)"
conda info
conda list
- name: Calculate sha256 hash
shell: bash
env:
OS_NAME: ${{ matrix.OS_NAME }}
ARCH: ${{ matrix.ARCH }}
run: |
cd dist
for INSTALLER_PATH in $DISTNAME-*-$OS_NAME-$ARCH.*; do
HASH_PATH="$INSTALLER_PATH.sha256"
sha256sum $INSTALLER_PATH > $HASH_PATH
cat $HASH_PATH
done
- name: Upload to Github artifact
if: ${{ (success() || failure()) && !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
path: dist/*
name: ${{ matrix.OS_NAME }}-${{ matrix.ARCH }}
- name: Upload to release
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: Upload metapackage to Anaconda.org
if: startsWith(github.ref, 'refs/tags/')
shell: bash -l {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
run: |
micromamba --help
anaconda upload -l $METAPACKAGE_LABEL --skip-existing dist/conda-bld/**/*