diff --git a/.github/workflows/prod-build.yml b/.github/workflows/prod-build.yml index 62fb832..13e6a34 100644 --- a/.github/workflows/prod-build.yml +++ b/.github/workflows/prod-build.yml @@ -1,8 +1,8 @@ # This workflow will perform following actions when code is pushed to the main branch: # - Run tests and linting checks (can be enabled via needs: test_and_lint) -# - Build and push nmrKit Docker image with layer caching for faster builds +# - Build and push nmrKit Docker image with latest and release-version tags # - Conditionally build nmr-cli image only if files in app/scripts/nmr-cli/ changed -# - Push images to Docker Hub under namespace nfdi4chem with latest tag +# - Push images to Docker Hub under namespace nfdi4chem with latest tags (plus release-version tags) # - Prevent redundant builds using concurrency control # # Maintainers: @@ -93,6 +93,19 @@ jobs: nmr-cli: - 'app/scripts/nmr-cli/**' + # Read release version from app config for versioned Docker tags + - name: Read project release version + id: release_version + shell: bash + run: | + PROJECT_VERSION=$(sed -nE 's/^VERSION\s*=\s*"([^"]+)"/\1/p' app/core/config.py | head -n1) + if [[ -z "$PROJECT_VERSION" ]]; then + echo "Unable to read VERSION from app/core/config.py" + exit 1 + fi + echo "project_version=$PROJECT_VERSION" >> "$GITHUB_OUTPUT" + echo "Detected release version: $PROJECT_VERSION" + # Build main nmrKit image with registry caching for faster builds - name: Build and push nmrKit Docker image uses: docker/build-push-action@v6 @@ -100,8 +113,10 @@ jobs: context: . file: ./Dockerfile push: true - build-args: RELEASE_VERSION=${{ env.RELEASE_TAG }} - tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMRKIT_REPOSITORY_NAME }}:${{ env.RELEASE_TAG }} + build-args: RELEASE_VERSION=${{ steps.release_version.outputs.project_version }} + tags: | + ${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMRKIT_REPOSITORY_NAME }}:${{ env.RELEASE_TAG }} + ${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMRKIT_REPOSITORY_NAME }}:${{ steps.release_version.outputs.project_version }} cache-from: type=registry,ref=${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMRKIT_REPOSITORY_NAME }}:buildcache cache-to: type=registry,ref=${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMRKIT_REPOSITORY_NAME }}:buildcache,mode=max @@ -113,7 +128,9 @@ jobs: context: ./app/scripts/nmr-cli/ file: ./app/scripts/nmr-cli/Dockerfile push: true - build-args: RELEASE_VERSION=${{ env.RELEASE_TAG }} - tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMR_CLI_REPOSITORY_NAME }}:${{ env.RELEASE_TAG }} + build-args: RELEASE_VERSION=${{ steps.release_version.outputs.project_version }} + tags: | + ${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMR_CLI_REPOSITORY_NAME }}:${{ env.RELEASE_TAG }} + ${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMR_CLI_REPOSITORY_NAME }}:${{ steps.release_version.outputs.project_version }} cache-from: type=registry,ref=${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMR_CLI_REPOSITORY_NAME }}:buildcache cache-to: type=registry,ref=${{ env.REPOSITORY_NAMESPACE }}/${{ env.NMR_CLI_REPOSITORY_NAME }}:buildcache,mode=max