Skip to content

Commit

Permalink
Configuring GitHub package Maven repos.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Jul 31, 2024
1 parent 629a1f9 commit 3b5f838
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 85 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/build-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
on:
push:
branches:
- release/**
- develop
- feature/**
pull_request:
types: [opened, synchronize, reopened]
branches:
- release/**
- develop
- feature/**
merge_group:
workflow_dispatch:
name: Build and Test
env:
BUILD_SNAPSHOT: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') &&
(github.ref_name == 'develop' || startsWith(github.ref_name, 'release/')) }}
MAVEN_VERSION: 3.9.8
JAVA_DISTRO: temurin
JAVA_VERSION_FILE: .java-version
jobs:
build-code:
name: Code
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
# security-events: write

steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
submodules: recursive
filter: tree:0
# -------------------------
# Java Environment Setup
# -------------------------
- name: Set up Maven
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1
with:
maven-version: ${{ env.MAVEN_VERSION }}
- name: Set up JDK 11 (build only)
if: ${{ !((github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'develop') }}
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version-file: ${{ env.JAVA_VERSION_FILE }}
distribution: ${{ env.JAVA_DISTRO }}
cache: 'maven'
- name: Set up JDK 11 (deploy)
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name == 'develop'
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version-file: ${{ env.JAVA_VERSION_FILE }}
distribution: ${{ env.JAVA_DISTRO }}
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
# - uses: s4u/maven-settings-action@7802f6aec16c9098b4798ad1f1d8ac75198194bd
# with:
# servers: |
# [{
# "id": "github",
# "configuration": {
# "username": "GITHUB_ACTOR",
# "password": "GITHUB_TOKEN"
# }
# }]
# - name: Initialize CodeQL
# if: github.event_name == 'push'
# uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c
# with:
# languages: java
# -------------------------
# Maven Build
# -------------------------
- id: build-test-deploy
name: Build, Test and DEPLOY SNAPSHOT Code
if: ${{ env.BUILD_SNAPSHOT == 'true' }}
run: |
mvn -B -e -Prelease -Pgpg deploy site -Dmaven.deploy.skip=releases
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Build and Test Code / Website
if: ${{ steps.build-test-deploy.outcome == 'skipped' }}
run: |
mvn -B -e -Prelease install
# - name: Perform CodeQL Analysis
# if: github.event_name == 'push'
# uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c
# with:
# upload: ${{ github.ref_name == 'develop' && 'always' || 'never' }}
build-website:
name: Website
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
submodules: recursive
filter: tree:0
# -------------------------
# Java Environment Setup
# -------------------------
- name: Set up Maven
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1
with:
maven-version: ${{ env.MAVEN_VERSION }}
- name: Set up JDK 11
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version-file: ${{ env.JAVA_VERSION_FILE }}
distribution: ${{ env.JAVA_DISTRO }}
cache: 'maven'
# -------------------------
# Maven Build
# -------------------------
- name: Build and Test Website
run: |
mvn -B -e -Prelease install site site:stage -Dmaven.test.skip=true
82 changes: 0 additions & 82 deletions .github/workflows/build.yml

This file was deleted.

1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11
10 changes: 7 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@
<tag>HEAD</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>github</id>
<name>GitHub Metaschema Framework Apache Maven Packages</name>
<url>https://maven.pkg.github.com/metaschema-framework/oss-maven</url>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<site>
<id>site_scm</id>
Expand Down Expand Up @@ -762,6 +765,7 @@
</build>
</profile>
</profiles>

<modules>
<module>oss-build-support</module>
<module>oss-parent</module>
Expand Down

0 comments on commit 3b5f838

Please sign in to comment.