diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9b705e0b..973042f4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,6 +10,11 @@ on: tags: ['v*'] pull_request: workflow_dispatch: + inputs: + publish_to_central: + description: "Deploy to Maven Central (snapshot if -SNAPSHOT, release if a vX.Y.Z tag)" + type: boolean + default: false env: JAVA_VERSION: '21' MODEL_URL: "https://huggingface.co/TheBloke/CodeLlama-7B-GGUF/resolve/main/codellama-7b.Q2_K.gguf" @@ -871,7 +876,7 @@ jobs: publish-snapshot: name: Publish Snapshot to Central needs: [check-snapshot, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style] - if: needs.check-snapshot.result == 'success' + if: needs.check-snapshot.result == 'success' && inputs.publish_to_central runs-on: ubuntu-latest environment: maven-central permissions: @@ -901,6 +906,15 @@ jobs: server-password: MAVEN_PASSWORD gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Guard - require a -SNAPSHOT version + shell: bash + run: | + VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version | tail -n1) + echo "Resolved project version: $VERSION" + case "$VERSION" in + *-SNAPSHOT) echo "OK: -SNAPSHOT version, continuing snapshot deploy." ;; + *) echo "::error::Refusing to publish non-SNAPSHOT version '$VERSION' from the snapshot job. Snapshot publishing requires a -SNAPSHOT version; releases go through the v* tag path."; exit 1 ;; + esac - name: Publish snapshot run: mvn --batch-mode --no-transfer-progress -P release,cuda,opencl-android -Dmaven.test.skip=true deploy env: @@ -945,7 +959,7 @@ jobs: publish-release: name: Publish Release to Central - if: needs.check-tag.result == 'success' + if: needs.check-tag.result == 'success' && inputs.publish_to_central needs: [check-tag, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style] runs-on: ubuntu-latest environment: maven-central