generated from cuioss/cui-java-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
126 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Maven Release | |
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
types: [ closed ] | ||
paths: | ||
- '.github/project.yml' | ||
workflow_dispatch: | ||
|
@@ -13,69 +13,69 @@ jobs: | |
name: release | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false # otherwise, the token used is the PA_TOKEN, instead of your personal access token. | ||
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false # otherwise, the token used is the PA_TOKEN, instead of your personal access token. | ||
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | ||
|
||
- uses: radcortez/[email protected] | ||
name: Retrieve project metadata from '.github/project.yml' | ||
id: metadata | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
metadata-file-path: '.github/project.yml' | ||
local-file: true | ||
- uses: radcortez/[email protected] | ||
name: Retrieve project metadata from '.github/project.yml' | ||
id: metadata | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
metadata-file-path: '.github/project.yml' | ||
local-file: true | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: sonatype-nexus-snapshots | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_CENTRAL_TOKEN | ||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
cache: maven | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: sonatype-nexus-snapshots | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_CENTRAL_TOKEN | ||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
cache: maven | ||
|
||
- name: Configure Git author | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Cuioss Robot Action" | ||
- name: Configure Git author | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Cuioss Robot Action" | ||
- name: Maven release ${{steps.metadata.outputs.current-version}} | ||
run: | | ||
git checkout -b release | ||
./mvnw -B -Prelease release:clean release:prepare -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} | ||
./mvnw -B -Prelease javadoc:aggregate site:site site:stage | ||
git checkout ${{vars.GITHUB_BASE_REF}} | ||
git rebase release | ||
./mvnw -B -Prelease release:perform -DskipTests | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} | ||
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSS_SONATYPE_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
- name: Maven release ${{steps.metadata.outputs.current-version}} | ||
run: | | ||
git checkout -b release | ||
./mvnw -B -Prelease release:clean release:prepare -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}} | ||
./mvnw -B -Prelease javadoc:aggregate site:site site:stage | ||
git checkout ${{vars.GITHUB_BASE_REF}} | ||
git rebase release | ||
./mvnw -B -Prelease release:perform -DskipTests | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} | ||
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSS_SONATYPE_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
|
||
- name: Deploy Maven Site to cuioss.github.io -> ${{steps.metadata.outputs.pages-reference}}🚀 | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: target/site | ||
repository-name: cuioss/cuioss.github.io | ||
target-folder: ${{steps.metadata.outputs.pages-reference}} | ||
branch: main | ||
token: ${{ secrets.PAGES_DEPLOY_TOKEN }} | ||
# | ||
- name: Push changes to ${{github.ref_name}} | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{github.ref_name}} | ||
force: true | ||
- name: Deploy Maven Site to cuioss.github.io -> ${{steps.metadata.outputs.pages-reference}}🚀 | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: target/site | ||
repository-name: cuioss/cuioss.github.io | ||
target-folder: ${{steps.metadata.outputs.pages-reference}} | ||
branch: main | ||
token: ${{ secrets.PAGES_DEPLOY_TOKEN }} | ||
|
||
- name: Push tag ${{steps.metadata.outputs.current-version}} | ||
uses: ad-m/[email protected] | ||
with: | ||
branch: ${{github.ref_name}} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tags: true | ||
force: true | ||
- name: Push changes to ${{github.ref_name}} | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{github.ref_name}} | ||
force: true | ||
|
||
- name: Push tag ${{steps.metadata.outputs.current-version}} | ||
uses: ad-m/[email protected] | ||
with: | ||
branch: ${{github.ref_name}} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tags: true | ||
force: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Master Build | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
branches: [ "main", "feature/*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
|
@@ -20,84 +12,84 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
version: [17,21,23] | ||
version: [ 17,21,23 ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK ${{ matrix.version }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.version }} | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven, Java ${{ matrix.version }} | ||
run: ./mvnw -B verify -Dmaven.compiler.source=${{ matrix.version }} -Dmaven.compiler.target=${{ matrix.version }} | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK ${{ matrix.version }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.version }} | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven, Java ${{ matrix.version }} | ||
run: ./mvnw --no-transfer-progress verify -Dmaven.compiler.source=${{ matrix.version }} -Dmaven.compiler.target=${{ matrix.version }} | ||
|
||
sonar-build: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 17 for Sonar-build | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
|
||
- name: Set up JDK 17 for Sonar-build | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- uses: radcortez/project-metadata-action@master | ||
name: Retrieve project metadata from '.github/project.yml' | ||
id: metadata | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
metadata-file-path: '.github/project.yml' | ||
local-file: true | ||
|
||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
|
||
- uses: radcortez/[email protected] | ||
name: Retrieve project metadata from '.github/project.yml' | ||
id: metadata | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
metadata-file-path: '.github/project.yml' | ||
local-file: true | ||
|
||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: ./mvnw -B verify -Psonar -Dsonar.projectKey=${{steps.metadata.outputs.sonar-project-key}} sonar:sonar | ||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: ./mvnw -B verify -Psonar -Dsonar.projectKey=${{steps.metadata.outputs.sonar-project-key}} sonar:sonar | ||
|
||
deploy-snapshot: | ||
needs: sonar-build | ||
if: github.event_name != 'pull_request' | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 for snapshot release | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: sonatype-nexus-snapshots | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_CENTRAL_TOKEN | ||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
cache: maven | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 for snapshot release | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: sonatype-nexus-snapshots | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_CENTRAL_TOKEN | ||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
cache: maven | ||
|
||
- name: Extract project version | ||
id: project | ||
run: echo ::set-output name=version::$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
- name: Extract project version | ||
id: project | ||
run: echo ::set-output name=version::$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) | ||
|
||
- name: Deploy Snapshot with Maven, version ${{ steps.project.outputs.version }} | ||
if: ${{endsWith(steps.project.outputs.version, '-SNAPSHOT')}} | ||
run: | | ||
./mvnw -B -Prelease-snapshot javadoc:aggregate | ||
./mvnw -B -Prelease-snapshot deploy -Dmaven.test.skip=true | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} | ||
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSS_SONATYPE_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
- name: Deploy Snapshot with Maven, version ${{ steps.project.outputs.version }} | ||
if: ${{endsWith(steps.project.outputs.version, '-SNAPSHOT')}} | ||
run: | | ||
./mvnw -B -Prelease-snapshot javadoc:aggregate | ||
./mvnw -B -Prelease-snapshot deploy -Dmaven.test.skip=true | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} | ||
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSS_SONATYPE_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |