Skip to content

Commit 3940db0

Browse files
authored
Merge pull request #408 from modelix/feature/test-publish-workflow
ci: test the publish workflow in PRs if changed
2 parents b462195 + af57e33 commit 3940db0

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

.github/workflows/publish.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- '[0-9]+.[0-9]+.[0-9]+*'
77
workflow_dispatch:
8+
# Test this workflow in PRs in case it changed
9+
pull_request:
10+
paths:
11+
- .github/workflows/publish.yml
812

913
jobs:
1014
newRelease:
@@ -26,8 +30,16 @@ jobs:
2630
java-version: '11'
2731
- name: Set up Gradle
2832
uses: gradle/gradle-build-action@v2
29-
- name: Use tag as version
30-
run: echo "${GITHUB_REF#refs/*/}" > version.txt
33+
- name: Configure the project version
34+
env:
35+
IS_PR: ${{ github.event_name == 'pull_request' }}
36+
run: |-
37+
if [[ "$IS_PR" = 'true' ]]; then
38+
echo "0.0.1-SNAPSHOT" > version.txt
39+
else
40+
echo "${GITHUB_REF#refs/*/}" > version.txt
41+
fi
42+
cat version.txt
3143
# Perform the build in a separate call to avoid trying to publish
3244
# something where the build already failed partially. This could happen
3345
# due to the use of the --continue flag in the publish step.
@@ -46,27 +58,36 @@ jobs:
4658
# Usually, the artifact that cannot be uploaded is strangely already
4759
# in the repo. As the result, by ignoring the exception, we should end
4860
# up with a working release in most cases.
49-
run: >-
50-
./gradlew --build-cache publish
51-
--continue
52-
--info
53-
-PciBuild=true
54-
-Partifacts.itemis.cloud.user=${{ secrets.ARTIFACTS_ITEMIS_CLOUD_USER }}
55-
-Partifacts.itemis.cloud.pw=${{ secrets.ARTIFACTS_ITEMIS_CLOUD_PW }}
56-
-Pgpr.user=${{ github.actor }}
57-
-Pgpr.key=${{ secrets.GITHUB_TOKEN }}
58-
-Pgpr.universalkey=${{ secrets.GHP_UNIVERSAL_PUBLISH_TOKEN }}
59-
-Porg.gradle.internal.http.connectionTimeout=180000
60-
-Porg.gradle.internal.http.socketTimeout=180000
61+
run: |-
62+
if [[ "$IS_PR" = 'true' ]]; then
63+
TARGET=publishToMavenLocal
64+
else
65+
TARGET=publish
66+
fi
67+
./gradlew --build-cache $TARGET \
68+
--continue \
69+
--info \
70+
-PciBuild=true \
71+
-Partifacts.itemis.cloud.user=${{ secrets.ARTIFACTS_ITEMIS_CLOUD_USER }} \
72+
-Partifacts.itemis.cloud.pw=${{ secrets.ARTIFACTS_ITEMIS_CLOUD_PW }} \
73+
-Pgpr.user=${{ github.actor }} \
74+
-Pgpr.key=${{ secrets.GITHUB_TOKEN }} \
75+
-Pgpr.universalkey=${{ secrets.GHP_UNIVERSAL_PUBLISH_TOKEN }} \
76+
-Porg.gradle.internal.http.connectionTimeout=180000 \
77+
-Porg.gradle.internal.http.socketTimeout=180000
6178
env:
6279
NODE_AUTH_TOKEN: ${{ secrets.ARTIFACTS_ITEMIS_CLOUD_NPM_TOKEN }}
80+
IS_PR: ${{ github.event_name == 'pull_request' }}
6381
- name: Set up QEMU
6482
uses: docker/setup-qemu-action@v3
6583
- name: Set up Docker Buildx
6684
uses: docker/setup-buildx-action@v3
6785
with:
6886
platforms: linux/amd64,linux/arm64
6987
- name: Build and Publish Docker
88+
# As publishing is currently baked into the scripts, we can't test this
89+
# in PRs
90+
if: ${{ github.event_name != 'pull_request' }}
7091
env:
7192
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
7293
DOCKER_HUB_KEY: ${{ secrets.DOCKER_HUB_KEY }}

0 commit comments

Comments
 (0)