diff --git a/.github/workflows/build_radioconda.yml b/.github/workflows/build_radioconda.yml new file mode 100644 index 0000000..3cd0f58 --- /dev/null +++ b/.github/workflows/build_radioconda.yml @@ -0,0 +1,121 @@ +name: Build radioconda +on: [push, pull_request] + +env: + DISTNAME: radioconda + SOURCE: github.com/ryanvolz/radioconda + +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: macos-latest + PLATFORM: osx-64 + OS_NAME: MacOSX + ARCH: x86_64 + - os: windows-latest + PLATFORM: win-64 + OS_NAME: Windows + ARCH: x86_64 + + steps: + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Install python environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: buildenv.yaml + + - name: Build installer (bash) + if: runner.os != 'Windows' + shell: bash -l {0} + env: + PLATFORM: ${{ matrix.PLATFORM }} + run: | + python build_installer.py -v + + - name: Build installer (cmd.exe) + if: runner.os == 'Windows' + shell: powershell + env: + PLATFORM: ${{ matrix.PLATFORM }} + run: | + $Env:Path = "$Env:CONDA_PREFIX\NSIS;$Env:Path" + echo $Env:Path + python build_installer.py -v + + - name: List built installers + shell: bash + run: | + ls -lh dist + + - name: Test installer (sh) + if: contains(matrix.OS_NAME, 'Linux') || contains(matrix.OS_NAME, 'MacOSX') + 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 (pkg) + if: contains(matrix.OS_NAME, 'MacOSX') + continue-on-error: true # this test doesn't work yet + shell: bash + env: + OS_NAME: ${{ matrix.OS_NAME }} + ARCH: ${{ matrix.ARCH }} + TARGET_VOLUME: CurrentUserHomeDirectory + INSTALL_PATH: ~/Applications/${{ env.DISTNAME }} + run: | + installer -verbose -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 + source $INSTALL_PATH/Scripts/activate + conda info + conda list + + - name: Upload to Github artifact + if: ${{ (success() || failure()) && !startsWith(github.ref, 'refs/tags/') }} + uses: actions/upload-artifact@v2 + 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 diff --git a/build_installer.py b/build_installer.py index 39afd80..869b0dd 100755 --- a/build_installer.py +++ b/build_installer.py @@ -20,14 +20,16 @@ def spec_dir_extract_platform(installer_spec_dir: pathlib.Path) -> str: if __name__ == "__main__": import argparse + import os import subprocess import sys from constructor import main as constructor_main - platform = constructor_main.cc_platform cwd = pathlib.Path(".").absolute() here = pathlib.Path(__file__).parent.absolute().relative_to(cwd) + distname = os.getenv("DISTNAME", "radioconda") + platform = os.getenv("PLATFORM", constructor_main.cc_platform) parser = argparse.ArgumentParser( description=( @@ -39,7 +41,7 @@ if __name__ == "__main__": "installer_spec_dir", type=pathlib.Path, nargs="?", - default=here / "installer_specs" / f"radioconda-{platform}", + default=here / "installer_specs" / f"{distname}-{platform}", help=( "Installer specification directory (containing construct.yaml)" " for a particular platform (name ends in the platform identifier)." @@ -61,6 +63,8 @@ if __name__ == "__main__": platform = spec_dir_extract_platform(args.installer_spec_dir) + args.output_dir.mkdir(parents=True, exist_ok=True) + constructor_cmdline = [ "constructor", args.installer_spec_dir, diff --git a/buildenv.yaml b/buildenv.yaml new file mode 100644 index 0000000..f394ecd --- /dev/null +++ b/buildenv.yaml @@ -0,0 +1,5 @@ +name: buildenv +channels: + - conda-forge +dependencies: + - constructor diff --git a/rerender.py b/rerender.py index df6fac8..780d3eb 100755 --- a/rerender.py +++ b/rerender.py @@ -109,8 +109,12 @@ def render_constructor_specs( if __name__ == "__main__": import argparse import datetime + import os - here = pathlib.Path(__file__).parent.relative_to("") + cwd = pathlib.Path(".").absolute() + here = pathlib.Path(__file__).parent.absolute().relative_to(cwd) + distname = os.getenv("DISTNAME", "radioconda") + source = os.getenv("SOURCE", "github.com/ryanvolz/radioconda") parser = argparse.ArgumentParser( description=( @@ -122,7 +126,7 @@ if __name__ == "__main__": "environment_file", type=pathlib.Path, nargs="?", - default=here / "radioconda.yaml", + default=here / f"{distname}.yaml", help=( "YAML file defining an installer distribution, with a 'name' string and" " 'channels', 'platforms', and 'dependencies' lists." @@ -132,7 +136,7 @@ if __name__ == "__main__": parser.add_argument( "--company", type=str, - default="github.com/ryanvolz/radioconda", + default=source, help=( "Name of the company/entity who is responsible for the installer." " (default: %(default)s)"