Conda Build #191
Workflow file for this run
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
| name: Conda Build | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| buildNumber: | |
| type: string | |
| required: true | |
| description: "build-nr: anaconda.org build-nr (DON'T trigger build if you don't know how to set it)" | |
| version: | |
| type: string | |
| required: true | |
| description: "version: PEP440 package-version (DON'T trigger build if you don't know what PEP440 is)" | |
| python-version: | |
| type: string | |
| required: true | |
| description: "Python version to test" | |
| buildDocker: | |
| type: boolean | |
| required: false | |
| default: false | |
| description: "build docker-img if conda-build & tests succeeded?" | |
| latestDocker: | |
| type: boolean | |
| required: false | |
| default: false | |
| description: "tag docker-img as latest (if `buildDocker` is enabled)" | |
| workflow_call: | |
| inputs: | |
| buildNumber: | |
| type: string | |
| required: true | |
| version: | |
| type: string | |
| required: true | |
| python-version: | |
| type: string | |
| required: true | |
| description: "Python version to test" | |
| buildDocker: | |
| type: boolean | |
| required: false | |
| default: false | |
| latestDocker: | |
| type: boolean | |
| required: false | |
| default: false | |
| jobs: | |
| conda-build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| karabo-version: ${{ steps.bcs.outputs.karabo_version }} | |
| build-docker: ${{ steps.bcs.outputs.build_docker == 'true' }} | |
| latest-docker: ${{ steps.bcs.outputs.latest_docker == 'true' }} | |
| python-version: ${{ steps.bcs.outputs.python_version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Conda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| - name: Build Conda | |
| id: bcs | |
| shell: bash -l {0} | |
| run: | | |
| if [[ ${{ github.event_name }} == 'release' ]] | |
| then | |
| echo "Conda build from release" | |
| apt-get update && apt-get install -y git | |
| git config --global safe.directory '*' | |
| KARABO_TAG=$(git describe --tags --abbrev=0) | |
| build="0" | |
| if [[ ${KARABO_TAG:0:1} == "v" ]]; then | |
| KARABO_VERSION="${KARABO_TAG:1}" | |
| else | |
| echo "Karabo-tag: `$KARABO_TAG` has no leading v" | |
| exit 1 | |
| fi | |
| BUILD_DOCKER=true | |
| LATEST_DOCKER=true | |
| elif [[ ${{ github.event_name }} == 'workflow_dispatch' ]] || [[ ${{ github.event_name }} == 'workflow_call' ]]; then | |
| echo "Conda build from dispatch | call" | |
| build=${{ inputs.buildNumber }} | |
| BUILD_DOCKER=${{ inputs.buildDocker }} | |
| LATEST_DOCKER=${{ inputs.latestDocker }} | |
| KARABO_VERSION=${{ inputs.version }} | |
| if [[ ${KARABO_VERSION:0:1} == "v" ]]; then | |
| KARABO_VERSION="${KARABO_VERSION:1}" | |
| fi | |
| conda install -c conda-forge python versioneer | |
| VERSIONEER_VERSION=$(python -c 'import versioneer; print(versioneer.get_version())') | |
| if [[ "$VERSIONEER_VERSION" != *"$KARABO_VERSION"* ]] && [[ "$KARABO_VERSION" != *"dev"* ]]; then | |
| echo "Provided version $KARABO_VERSION doesn't match the actual version $VERSIONEER_VERSION" | |
| exit 1 | |
| fi | |
| else | |
| echo "Unexpected github-event occured" | |
| exit 1 | |
| fi | |
| if [[ "$KARABO_VERSION" == *"dev"* ]]; then | |
| if [[ $LATEST_DOCKER == 'true' ]]; then | |
| echo "Dev build docker image can not be tagged as latest!" | |
| exit 1 | |
| fi | |
| build="$(($build + 1000))" | |
| fi | |
| export KARABO_VERSION=$KARABO_VERSION build=$build | |
| echo "karabo_version=$KARABO_VERSION" >> $GITHUB_OUTPUT | |
| echo "build_docker=$BUILD_DOCKER" >> $GITHUB_OUTPUT | |
| echo "latest_docker=$LATEST_DOCKER" >> $GITHUB_OUTPUT | |
| echo "python_version=$PYTHON_VERSION" >> $GITHUB_OUTPUT | |
| conda install -y -n base conda-libmamba-solver | |
| conda config --set solver libmamba | |
| conda install "conda-build>=25" | |
| conda config --remove channels defaults | |
| conda config --append channels i4ds | |
| conda config --append channels nvidia/label/cuda-11.7.0 | |
| conda config --append channels conda-forge | |
| cd conda | |
| conda build | |
| - name: Publish to Conda | |
| shell: bash -l {0} | |
| run: | | |
| conda activate base | |
| anaconda -t ${{ secrets.ANACONDA_SECRET }} upload /opt/conda/conda-bld/linux-64/karabo-pipeline-*.tar.bz2 --force | |
| test-build: | |
| needs: conda-build | |
| uses: ./.github/workflows/test-user-package.yml | |
| with: | |
| version: ${{ needs.conda-build.outputs.karabo-version }} | |
| buildDocker: ${{ needs.conda-build.outputs.build-docker == 'true' }} | |
| latestDocker: ${{ needs.conda-build.outputs.latest-docker == 'true' }} | |
| python-version: ${{ inputs.python-version }} |