-
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
3 changed files
with
47 additions
and
60 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 |
---|---|---|
@@ -1,58 +1,45 @@ | ||
name: CI/CD | ||
on: | ||
pull_request: | ||
branches: main | ||
types: [opened, synchronize, reopened] | ||
branches: [ "main" ] | ||
push: | ||
branches: main | ||
paths-ignore: [ "README.md", "doc/**" ] | ||
#push: | ||
#branches: [ "main", "develop" ] | ||
#paths-ignore: [ "README.md", "doc/**" ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
- name: Build & Scan Project | ||
java-version: '21' | ||
distribution: 'temurin' #Eclipse Temurin | ||
- name: verify | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: mvn --batch-mode --no-transfer-progress verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=oneteme_${{ github.event.repository.name }} | ||
- name: Extract version | ||
id: mvnVer | ||
run: echo "version=$(mvn help:evaluate -DforceStdout -Dexpression=project.version -q)" >>$GITHUB_OUTPUT | ||
outputs: | ||
version: ${{ steps.mvnVer.outputs.version }} | ||
deploy: | ||
needs: build | ||
if: github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
if: github.ref_name == 'main' && endsWith(needs.deploy.outputs.version, '-SNAPSHOT') | ||
steps: | ||
- name: Install gpg secret key | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
cat <(echo -e "${{ secrets.MAVEN_GPG_PRIVATE_KEY }}") | gpg --batch --import | ||
gpg --list-secret-keys --keyid-format LONG | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
java-version: '21' | ||
distribution: 'temurin' #Eclipse Temurin | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
- name: Extract Maven version | ||
id: projectVersion | ||
run: echo "version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.3.0:evaluate -DforceStdout -Dexpression=project.version -q)" >>$GITHUB_OUTPUT | ||
- name: Publish SNAPSHOT | ||
if: endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') | ||
- name: deploy ${{ needs.deploy.outputs.version }} | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | ||
run: mvn --no-transfer-progress --batch-mode clean deploy | ||
- name: Publish RELEASE | ||
if: ${{ github.ref == 'refs/heads/main' && !endsWith(steps.projectVersion.outputs.version, '-SNAPSHOT') }} | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | ||
run: mvn --no-transfer-progress --batch-mode -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} -Pdeploy clean deploy | ||
run: mvn --no-transfer-progress --batch-mode clean deploy |
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
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