tballison commented on code in PR #19: URL: https://github.com/apache/tika-docker/pull/19#discussion_r1383363528
########## .github/workflows/docker-build.yaml: ########## @@ -0,0 +1,183 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Build Docker images + +on: + # Allow manual runs. + workflow_dispatch: + inputs: + TIKA_VERSION: + description: The Tika version to build the image from + type: string + default: 2.8.0 + PUSH_IMAGE: + description: Push image to registry + type: boolean + default: true + push: + tags: + - "*.*.*.*" + +env: + # Further platforms can be specified here as long as the base image supports them + PLATFORMS: linux/arm/v7,linux/arm64/v8,linux/amd64 + IMAGE_NAME: tika + EXPECTED_USER: "35002:35002" + +jobs: + build-image: + name: Build ${{ matrix.IMAGE_TYPE }} Docker image + runs-on: ubuntu-latest + + # Set up a local registry so the multi-arch images can be stored for testing + services: + registry: + image: registry:2 + ports: + - 5000:5000 + + # This will build both full and minimal images with each run of the workflow + strategy: + matrix: + IMAGE_TYPE: ["full", "minimal"] + + env: + TEST_CONTAINER_NAME: tika-${{ matrix.IMAGE_TYPE }}-test + TEST_IMAGE_NAME: localhost:5000/tika/tika-${{ matrix.IMAGE_TYPE }}:test + + steps: + - name: Check out repo + uses: actions/checkout@v4 + + # Determine Tika version to build from current tag name + - name: "[SETUP] Determine build configuration" + shell: bash + run: | + echo "::group::Determine whether image should be pushed" + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + # If the workflow was run manually we want whatever the PUSH_IMAGE input is + PUSH_IMAGE="${{ inputs.PUSH_IMAGE }}" + elif [[ "${{ github.event_name }}" == "create" ]] && [[ "${{ github.ref }}" == "refs/tags/"* ]]; then + # If the workflow was triggered by the creation of a new tag + PUSH_IMAGE="true" + elif [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref }}" == "refs/tags/"* ]]; then + # If the workflow was triggered by push of a new tag + PUSH_IMAGE="true" + elif [[ "${{ github.event_name }}" == "release" ]]; then + # If the workflow was triggered by the creation of a new GitHub release + PUSH_IMAGE="true" + else + PUSH_IMAGE="false" + fi + echo "PUSH_IMAGE=${PUSH_IMAGE}" >> $GITHUB_ENV + echo "Push image? ${PUSH_IMAGE}" + echo "::endgroup::" + + echo "::group::Determine Tika version to build from" + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + TIKA_VERSION="${{ inputs.TIKA_VERSION }}" + else + IMAGE_VERSION=$(git describe --tags --abbrev=0) + TIKA_VERSION=$(echo ${IMAGE_VERSION} | sed 's/\(.*\)..\d*$/\1/') Review Comment: I _think_ this regex works by accident, how about something like: `TIKA_VERSION=$(echo ${IMAGE_VERSION} | sed -r 's/^([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+(-beta)?$/\1/')` That would allow for a -beta as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@tika.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org