diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index d88a15443..5cd531bfc 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -5,16 +5,18 @@ on: branches: [ master ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] - + jobs: - conda-build-arm: + conda-build-arm64: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Setup for Multi-platform image - name: Set up QEMU @@ -27,7 +29,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . - file: Dockerfile_arm_conda + file: scripts/Dockerfile_conda_build platforms: linux/arm64 build-args: | PYTHON_VERSION=${{ matrix.python-version }} @@ -39,23 +41,25 @@ jobs: matrix: python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Setup for Multi-platform image + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push Docker image arm64 + uses: docker/build-push-action@v4 with: - python-version: ${{ matrix.python-version }} - - uses: s-weigand/setup-conda@v1 - - run: | - export PYTHON_VERSION=${{ matrix.python-version }} - conda install conda-build anaconda-client - conda config --set anaconda_upload no - conda config --add channels conda-forge - export ANACONDA_API_TOKEN=${{ secrets.CONDA_TOKEN }} - PACKAGE_PATH=$(conda build . --python ${{ matrix.python-version }} --output) - conda build . --python ${{ matrix.python-version }} - if [ "${{ matrix.python-version }}" == "3.11" ]; then - anaconda -t $ANACONDA_API_TOKEN upload $PACKAGE_PATH --label main --label py3.11 --force - else - anaconda -t $ANACONDA_API_TOKEN upload $PACKAGE_PATH --label py${{ matrix.python-version }} --force - fi + context: . + file: scripts/Dockerfile_conda_build + platforms: linux/amd64 + build-args: | + PYTHON_VERSION=${{ matrix.python-version }} + ANACONDA_API_TOKEN=${{ secrets.CONDA_TOKEN }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index e181abe5c..a5fcab888 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -32,7 +32,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Setup for Multi-platform image - name: Set up QEMU @@ -125,7 +127,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Setup for Multi-platform image - name: Set up QEMU @@ -218,7 +222,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Setup for Multi-platform image - name: Set up QEMU diff --git a/Dockerfile_arm_conda b/Dockerfile_arm_conda deleted file mode 100644 index 30e0fdcd0..000000000 --- a/Dockerfile_arm_conda +++ /dev/null @@ -1,33 +0,0 @@ -FROM --platform=linux/arm64/v8 ubuntu:22.04 -COPY . /mspass -RUN mv /mspass /mspasspy_build -WORKDIR /mspasspy_build -RUN ls -RUN pwd -ARG PYTHON_VERSION -ENV PATH /opt/conda/bin:$PATH -RUN apt-get update --fix-missing && \ - apt-get install -y wget bzip2 ca-certificates curl git && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O ~/miniconda.sh && \ - /bin/bash ~/miniconda.sh -b -p /opt/conda && \ - rm ~/miniconda.sh && \ - /opt/conda/bin/conda clean -a -y && \ - ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \ - echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \ - echo "conda activate base" >> ~/.bashrc - -ARG ANACONDA_API_TOKEN - -RUN apt-get update && apt-get install -y cmake -RUN cd /mspasspy_build && sed -i '38d' meta.yaml \ - && conda install -y conda-build anaconda-client \ - && conda config --set anaconda_upload no \ - && conda config --add channels conda-forge \ - && export CONDA_BUILD_DEBUG=1 \ - && PACKAGE_PATH=$(conda build . --python ${PYTHON_VERSION} --output) \ - && conda build . --python ${PYTHON_VERSION} --debug \ - && anaconda -t $ANACONDA_API_TOKEN upload $PACKAGE_PATH --label py${PYTHON_VERSION} --force - diff --git a/scripts/Dockerfile_conda_build b/scripts/Dockerfile_conda_build new file mode 100644 index 000000000..90e0208ec --- /dev/null +++ b/scripts/Dockerfile_conda_build @@ -0,0 +1,27 @@ +FROM continuumio/miniconda3:latest +ADD . /mspass +ADD .git /mspass/.git +RUN mv /mspass /mspasspy_build && cd /mspasspy_build && git status + +ARG PYTHON_VERSION +ARG TARGETARCH + +ENV PATH /opt/conda/bin:$PATH +RUN apt-get update --fix-missing && \ + apt-get install -y cmake wget bzip2 ca-certificates curl git && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ARG ANACONDA_API_TOKEN + +RUN cd /mspasspy_build \ + && conda install -y conda-build anaconda-client \ + && conda config --set anaconda_upload no \ + && conda config --add channels conda-forge \ + && export CONDA_BUILD_DEBUG=1 \ + && PACKAGE_PATH=$(conda build . --python ${PYTHON_VERSION} --output) \ + && conda build . --python ${PYTHON_VERSION} --debug \ + && if [ "$PYTHON_VERSION" == "3.11" ]; then \ + anaconda -t $ANACONDA_API_TOKEN upload $PACKAGE_PATH --label main --label py${PYTHON_VERSION} --force ; \ + else anaconda -t $ANACONDA_API_TOKEN upload $PACKAGE_PATH --label py${PYTHON_VERSION} --force ; fi +