Skip to content

Commit 2758e2a

Browse files
committed
ci: improve publish check
1 parent b9544aa commit 2758e2a

1 file changed

Lines changed: 30 additions & 15 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,32 @@ on:
1515

1616
jobs:
1717

18+
check-publish:
19+
name: check publish
20+
runs-on: ubuntu-latest
21+
outputs:
22+
BUILD_VERSION: ${{ env.BUILD_VERSION }}
23+
BUILD_SNAPSHOT: ${{ env.BUILD_SNAPSHOT }}
24+
BUILD_PUBLISH: ${{ env.BUILD_PUBLISH }}
25+
26+
steps:
27+
- name: get version
28+
id: get-version
29+
uses: openapi-processor/openapi-processor-base/.github/actions/version@main
30+
with:
31+
version-file: 'gradle/libs.versions.toml'
32+
version-path: 'versions.project'
33+
34+
- name: set version outputs
35+
shell: bash
36+
run: |
37+
echo BUILD_VERSION="${{steps.get-version.outputs.version}}" >> $GITHUB_ENV
38+
echo BUILD_SNAPSHOT="${{steps.get-version.outputs.snapshot}}" >> $GITHUB_ENV
39+
echo BUILD_PUBLISH="${{steps.get-version.outputs.publish}}" >> $GITHUB_ENV
40+
cat $GITHUB_ENV
41+
1842
build:
43+
name: build & test
1944
runs-on: ubuntu-latest
2045

2146
steps:
@@ -27,7 +52,7 @@ jobs:
2752
distribution: 'temurin'
2853
java-version: 17
2954

30-
- name: build & publish (sonatype)
55+
- name: build
3156
env:
3257
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3358
ORG_GRADLE_PROJECT_signKey: ${{ secrets.SIGN_KEY }}
@@ -36,22 +61,12 @@ jobs:
3661
PUBLISH_KEY: ${{ secrets.PUBLISH_KEY }}
3762
run: ./gradlew check --stacktrace
3863

39-
check-publish:
40-
needs: [build]
41-
name: check publish
42-
43-
runs-on: ubuntu-latest
44-
if: >-
45-
github.actor != 'dependabot[bot]' &&
46-
github.actor == 'hauner' && contains(needs.version.outputs.BUILD_VERSION, 'SNAPSHOT')
47-
48-
steps:
49-
- run: echo "should publish ..."
50-
51-
5264
publish:
53-
needs: [check-publish]
65+
needs: [check-publish, build]
66+
name: publish (maven central)
67+
5468
runs-on: ubuntu-latest
69+
if: needs.check-publish.outputs.BUILD_PUBLISH == 'true'
5570

5671
steps:
5772
- uses: actions/checkout@v6

0 commit comments

Comments
 (0)