|
10 | 10 | tags: ['v*'] |
11 | 11 | pull_request: |
12 | 12 | workflow_dispatch: |
| 13 | + inputs: |
| 14 | + publish_to_central: |
| 15 | + description: "Deploy to Maven Central (snapshot if -SNAPSHOT, release if a vX.Y.Z tag)" |
| 16 | + type: boolean |
| 17 | + default: false |
13 | 18 | env: |
14 | 19 | JAVA_VERSION: '21' |
15 | 20 | MODEL_URL: "https://huggingface.co/TheBloke/CodeLlama-7B-GGUF/resolve/main/codellama-7b.Q2_K.gguf" |
@@ -871,7 +876,7 @@ jobs: |
871 | 876 | publish-snapshot: |
872 | 877 | name: Publish Snapshot to Central |
873 | 878 | needs: [check-snapshot, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style] |
874 | | - if: needs.check-snapshot.result == 'success' |
| 879 | + if: needs.check-snapshot.result == 'success' && inputs.publish_to_central |
875 | 880 | runs-on: ubuntu-latest |
876 | 881 | environment: maven-central |
877 | 882 | permissions: |
@@ -901,6 +906,15 @@ jobs: |
901 | 906 | server-password: MAVEN_PASSWORD |
902 | 907 | gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} |
903 | 908 | gpg-passphrase: MAVEN_GPG_PASSPHRASE |
| 909 | + - name: Guard - require a -SNAPSHOT version |
| 910 | + shell: bash |
| 911 | + run: | |
| 912 | + VERSION=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version | tail -n1) |
| 913 | + echo "Resolved project version: $VERSION" |
| 914 | + case "$VERSION" in |
| 915 | + *-SNAPSHOT) echo "OK: -SNAPSHOT version, continuing snapshot deploy." ;; |
| 916 | + *) 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 ;; |
| 917 | + esac |
904 | 918 | - name: Publish snapshot |
905 | 919 | run: mvn --batch-mode --no-transfer-progress -P release,cuda,opencl-android -Dmaven.test.skip=true deploy |
906 | 920 | env: |
@@ -945,7 +959,7 @@ jobs: |
945 | 959 |
|
946 | 960 | publish-release: |
947 | 961 | name: Publish Release to Central |
948 | | - if: needs.check-tag.result == 'success' |
| 962 | + if: needs.check-tag.result == 'success' && inputs.publish_to_central |
949 | 963 | needs: [check-tag, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style] |
950 | 964 | runs-on: ubuntu-latest |
951 | 965 | environment: maven-central |
|
0 commit comments