Skip to content

Commit 3fa7a5f

Browse files
committed
OAK-9500 Deploy Snapshot artifacts from trunk to Apache Nexus
1 parent 26e6eeb commit 3fa7a5f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,38 @@ jobs:
3535
java-version: 11
3636
distribution: temurin
3737
cache: maven
38+
server-id: apache.snapshots.https # Value of the distributionManagement/repository/id field of the pom.xml
39+
server-username: MAVEN_APACHE_NEXUS_USERNAME # env variable for username in deploy
40+
server-password: MAVEN_APACHE_NEXUS_PASSWORD # env variable for token in deploy
41+
# sets environment variables to be used in subsequent steps: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
42+
- name: Set environment variables
43+
shell: bash
44+
run: |
45+
if [ "${{github.ref}}" = "refs/heads/trunk" ] && [ "${{github.event_name}}" = "push" && "${{github.repository_owner}}" = "apache"]; then
46+
echo "MVN_ADDITIONAL_OPTS=-DdeployAtEnd=true" >> $GITHUB_ENV
47+
echo "MVN_GOAL=deploy" >> $GITHUB_ENV
48+
echo "MAVEN_APACHE_NEXUS_USERNAME=${{ secrets.NEXUS_USER }}" >> $GITHUB_ENV
49+
echo "MAVEN_APACHE_NEXUS_PASSWORD=${{ secrets.NEXUS_PW }}" >> $GITHUB_ENV
50+
else
51+
echo "MVN_ADDITIONAL_OPTS=" >> $GITHUB_ENV
52+
echo "MVN_GOAL=install" >> $GITHUB_ENV
53+
fi
3854
- name: Build
3955
# executing ITs requires installing artifacts to the local repository
40-
run: mvn -B install -Pcoverage,integrationTesting,javadoc -Dnsfixtures=SEGMENT_TAR,DOCUMENT_NS
56+
run: mvn -B ${{ env.MVN_GOAL }} ${{ env.MVN_ADDITIONAL_OPTS }} -Pcoverage,integrationTesting,javadoc -Dnsfixtures=SEGMENT_TAR,DOCUMENT_NS
4157
- name: Upload build result
4258
uses: actions/upload-artifact@v4
4359
with:
4460
name: compiled-classes-and-coverage
45-
# compare with https://docs.sonarsource.com/sonarcloud/advanced-setup/languages/java/#java-analysis-and-bytecode
61+
# compare with https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/java/#java-analysis-and-bytecode
4662
path: |
4763
**/target/**/*.class
4864
**/target/site/jacoco*/*.xml
65+
4966
# execute analysis in a separate job for better visualization and usage of matrix builds
5067
# https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarscanner-for-maven/#invoking-the-goal
5168
sonar:
52-
name: SonarCloud Analysis
69+
name: SonarQube Analysis
5370
runs-on: ubuntu-latest
5471
needs: build
5572
# not supported on forks, https://portal.productboard.com/sonarsource/1-sonarqube-cloud/c/50-sonarcloud-analyzes-external-pull-request
@@ -68,13 +85,13 @@ jobs:
6885
uses: actions/download-artifact@v4
6986
with:
7087
name: compiled-classes-and-coverage
71-
- name: Cache SonarCloud packages
88+
- name: Cache SonarQube packages
7289
uses: actions/cache@v4
7390
with:
7491
path: ~/.sonar/cache
7592
key: ${{ runner.os }}-sonar
7693
restore-keys: ${{ runner.os }}-sonar
77-
- name: Analyze with SonarCloud
94+
- name: Analyze with SonarQube
7895
env:
7996
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
8097
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

0 commit comments

Comments
 (0)