Skip to content

Commit

Permalink
OAK-9500 Deploy Snapshot artifacts from trunk to Apache Nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
kwin committed Jan 2, 2025
1 parent 26e6eeb commit d2f4d41
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,40 @@ jobs:
java-version: 11
distribution: temurin
cache: maven
server-id: apache.snapshots.https # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_APACHE_NEXUS_USERNAME # env variable for username in deploy
server-password: MAVEN_APACHE_NEXUS_PASSWORD # env variable for token in deploy
# 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
- name: Set environment variables
shell: bash
run: |
if [ "${{github.ref}}" = "refs/pull/1935/merge" ] && [ "${{github.event_name}}" = "pull_request" ] && [ "${{github.repository_owner}}" = "apache" ]; then
echo 'Running on main branch of the canonical repo'
echo "MVN_ADDITIONAL_OPTS=-DdeployAtEnd=true" >> $GITHUB_ENV
echo "MVN_GOAL=deploy" >> $GITHUB_ENV
echo "MAVEN_APACHE_NEXUS_USERNAME=${{ secrets.NEXUS_USER }}" >> $GITHUB_ENV
echo "MAVEN_APACHE_NEXUS_PASSWORD=${{ secrets.NEXUS_PW }}" >> $GITHUB_ENV
else
echo 'Running outside main branch/canonical repo'
echo "MVN_ADDITIONAL_OPTS=" >> $GITHUB_ENV
echo "MVN_GOAL=install" >> $GITHUB_ENV
fi
- name: Build
# executing ITs requires installing artifacts to the local repository
run: mvn -B install -Pcoverage,integrationTesting,javadoc -Dnsfixtures=SEGMENT_TAR,DOCUMENT_NS
run: mvn -B ${{ env.MVN_GOAL }} ${{ env.MVN_ADDITIONAL_OPTS }} -Pcoverage,integrationTesting,javadoc -Dnsfixtures=SEGMENT_TAR,DOCUMENT_NS
- name: Upload build result
uses: actions/upload-artifact@v4
with:
name: compiled-classes-and-coverage
# compare with https://docs.sonarsource.com/sonarcloud/advanced-setup/languages/java/#java-analysis-and-bytecode
# compare with https://docs.sonarsource.com/sonarqube-cloud/advanced-setup/languages/java/#java-analysis-and-bytecode
path: |
**/target/**/*.class
**/target/site/jacoco*/*.xml
# execute analysis in a separate job for better visualization and usage of matrix builds
# https://docs.sonarsource.com/sonarcloud/advanced-setup/ci-based-analysis/sonarscanner-for-maven/#invoking-the-goal
sonar:
name: SonarCloud Analysis
name: SonarQube Analysis
runs-on: ubuntu-latest
needs: build
# not supported on forks, https://portal.productboard.com/sonarsource/1-sonarqube-cloud/c/50-sonarcloud-analyzes-external-pull-request
Expand All @@ -68,13 +87,13 @@ jobs:
uses: actions/download-artifact@v4
with:
name: compiled-classes-and-coverage
- name: Cache SonarCloud packages
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Analyze with SonarCloud
- name: Analyze with SonarQube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions oak-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<!-- at least 3.1.0 for https://issues.apache.org/jira/browse/MDEPLOY-200 -->
<version>3.1.3</version>
<configuration>
<skip>${skip.deployment}</skip>
</configuration>
Expand Down

0 comments on commit d2f4d41

Please sign in to comment.