diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index d01950b37..f67e40ad7 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -13,10 +13,19 @@ on: required: true type: boolean default: false + version: + description: 'The version to publish' + required: true + type: text jobs: publish-docker-image: + strategy: + fail-fast: false + matrix: + flavour: ['min','slim','full'] + name: ${{ matrix.flavour }} runs-on: ubuntu-latest steps: - name: Checkout @@ -28,46 +37,43 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Setup variables + run: | + if [ "${{ github.event_name }}" == "release" ]; then + echo "should_publish=true" >> $GITHUB_ENV + echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_ENV + elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "version=${{ github.event.inputs.version }}" >> $GITHUB_ENV + echo "should_publish=${{ github.event.inputs.publish }}" >> $GITHUB_ENV + fi + shell: bash + - name: Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.TEST_DOCKERHUB_USERNAME }} password: ${{ secrets.TEST_DOCKERHUB_TOKEN }} - - name: Build and test - uses: docker/build-push-action@v4 - with: - context: . - load: true - target: full - - - name: Run Tests - run: docker run --rm hydromt pytest - - #build should be cached from previous steps - - name: Build and push full image - uses: docker/build-push-action@v4 - with: - context: . - load: true - target: full - push: ${{ inputs.publish }} - tags: deltares/hydromt:full + - name: generate envs + run: | + pip install tomli + python make_env.py -p '3.11' -o ${{ matrix.flavour }}-environment.yml ${{ matrix.flavour }} - - name: Build and push min image + - name: Build and push ${{ matrix.flavour }} image uses: docker/build-push-action@v4 with: context: . load: true - target: min - push: ${{ inputs.publish }} - tags: deltares/hydromt:min + target: ${{ matrix.flavour }} # + push: ${{ env.should_publish }} + tags: deltares/hydromt:${{ env.version }}-${{ matrix.flavour }} - - name: Build and push slim image + - name: Build and push latest image + if: matrix.flavour == 'slim' uses: docker/build-push-action@v4 with: context: . load: true - target: slim - push: ${{ inputs.publish }} - tags: deltares/hydromt:slim + target: ${{ matrix.flavour }} # + push: ${{ env.should_publish }} + tags: deltares/hydromt:${{ env.version }}, deltares/hydromt:latest diff --git a/.github/workflows/test-docker.yml b/.github/workflows/test-docker.yml index 19e2c1811..30b8c65c8 100644 --- a/.github/workflows/test-docker.yml +++ b/.github/workflows/test-docker.yml @@ -34,7 +34,7 @@ jobs: - name: generate envs run: | pip install tomli - python make_env.py -p 3.11 -o full-environment.yml full + python make_env.py -p "3.11" -o full-environment.yml full - name: Build and test uses: docker/build-push-action@v4