Skip to content

Commit 078a35e

Browse files
fix(publish): add check-snapshot/check-tag gates to fix release routing
Inserts two lightweight gate jobs between `report` and the publish/release jobs to fix incorrect routing: - `github-snapshot` and `publish-snapshot` were firing on any workflow_dispatch, including dispatches from a tag ref. - `publish-release` condition used `||` so it fired on any dispatch with release_to_maven_central=true even from a branch (where github-release was skipped, causing publish-release to also skip silently). The two new gate jobs (`check-snapshot`, `check-tag`) succeed only on the correct ref type. Downstream jobs gate on `needs.<gate>.result == 'success'` so they automatically skip when the gate is skipped.
1 parent 6cd8fba commit 078a35e

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

.github/workflows/publish.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -620,12 +620,30 @@ jobs:
620620
files: target/site/jacoco/jacoco.xml
621621
continue-on-error: true
622622

623-
github-snapshot:
624-
name: Update Snapshot Pre-release on GitHub
623+
check-snapshot:
624+
name: Check: main branch / SNAPSHOT
625625
needs: [report]
626+
runs-on: ubuntu-latest
626627
if: >-
627628
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
628-
github.event_name == 'workflow_dispatch'
629+
(github.event_name == 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/v'))
630+
steps:
631+
- name: Confirm snapshot ref
632+
run: echo "Confirmed on snapshot ref ${{ github.ref }}"
633+
634+
check-tag:
635+
name: Check: v* tag
636+
needs: [report]
637+
runs-on: ubuntu-latest
638+
if: startsWith(github.ref, 'refs/tags/v')
639+
steps:
640+
- name: Confirm tag ref
641+
run: echo "Confirmed on tag ${{ github.ref }}"
642+
643+
github-snapshot:
644+
name: Update Snapshot Pre-release on GitHub
645+
needs: [check-snapshot]
646+
if: needs.check-snapshot.result == 'success'
629647
runs-on: ubuntu-latest
630648
permissions:
631649
contents: write
@@ -650,10 +668,8 @@ jobs:
650668
651669
publish-snapshot:
652670
name: Publish Snapshot to Central
653-
needs: [github-snapshot]
654-
if: >-
655-
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
656-
github.event_name == 'workflow_dispatch'
671+
needs: [github-snapshot, check-snapshot]
672+
if: needs.check-snapshot.result == 'success'
657673
runs-on: ubuntu-latest
658674
environment: maven-central
659675
steps:
@@ -685,8 +701,8 @@ jobs:
685701

686702
github-release:
687703
name: Attach Binaries to GitHub Release
688-
needs: [report]
689-
if: startsWith(github.ref, 'refs/tags/v')
704+
needs: [check-tag]
705+
if: needs.check-tag.result == 'success'
690706
runs-on: ubuntu-latest
691707
permissions:
692708
contents: write
@@ -702,8 +718,8 @@ jobs:
702718

703719
publish-release:
704720
name: Publish Release to Central
705-
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.release_to_maven_central == 'true'
706-
needs: [github-release, crosscompile-linux-x86_64-cuda]
721+
if: needs.check-tag.result == 'success' && github.event.inputs.release_to_maven_central == 'true'
722+
needs: [github-release, check-tag, crosscompile-linux-x86_64-cuda]
707723
runs-on: ubuntu-latest
708724
environment: maven-central
709725
steps:

0 commit comments

Comments
 (0)