|
| 1 | +# © 2025. TU Dortmund University, |
| 2 | +# Institute of Energy Systems, Energy Efficiency and Energy Economics, |
| 3 | +# Research group Distribution grid planning and operation |
| 4 | +# |
| 5 | + |
| 6 | +name: CI |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + paths-ignore: |
| 11 | + - 'docs/**' |
| 12 | + branches: |
| 13 | + - main |
| 14 | + - dev |
| 15 | + - 'hotfix/*' |
| 16 | + - 'rel/*' |
| 17 | + - 'dependabot/*' |
| 18 | + pull_request: |
| 19 | + branches: |
| 20 | + - main |
| 21 | + - dev |
| 22 | + |
| 23 | +jobs: |
| 24 | + buildAndTest: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout Source |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + |
| 33 | + - name: Setup Gradle |
| 34 | + uses: gradle/actions/setup-gradle@v4 |
| 35 | + |
| 36 | + - name: Check Branch |
| 37 | + run: | |
| 38 | + if [ "${{ github.event_name }}" == "pull_request" ]; then |
| 39 | + BRANCH_NAME="${{ github.head_ref }}" |
| 40 | + else |
| 41 | + BRANCH_NAME="${{ github.ref_name }}" |
| 42 | + fi |
| 43 | +
|
| 44 | + if [[ "$BRANCH_NAME" == refs/heads/* ]]; then |
| 45 | + BRANCH_NAME="${BRANCH_NAME#refs/heads/}" |
| 46 | + fi |
| 47 | + |
| 48 | + export BRANCH_NAME |
| 49 | + |
| 50 | + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV |
| 51 | + |
| 52 | + ./gradlew checkBranchName -PbranchName="$BRANCH_NAME" --warning-mode=none |
| 53 | + |
| 54 | + bash scripts/branch_type.sh |
| 55 | +
|
| 56 | + - name: Version Check |
| 57 | + if: ${{ github.event_name == 'pull_request' }} |
| 58 | + env: |
| 59 | + BASE_BRANCH: ${{ github.event.pull_request.base.ref }} |
| 60 | + run: bash scripts/run-version-check.sh |
| 61 | + |
| 62 | + - name: Setup Java |
| 63 | + uses: actions/setup-java@v4 |
| 64 | + with: |
| 65 | + distribution: 'temurin' |
| 66 | + java-version: 17 |
| 67 | + |
| 68 | + - name: Build Project |
| 69 | + run: ./gradlew --refresh-dependencies clean assemble spotlessCheck |
| 70 | + |
| 71 | + - name: Run Tests |
| 72 | + run: ./gradlew pmdMain pmdTest spotbugsMain spotbugsTest test jacocoTestReport jacocoTestCoverageVerification |
| 73 | + |
| 74 | + - name: Build Java-Docs |
| 75 | + run: ./gradlew javadoc |
| 76 | + |
| 77 | + - name: SonarQube |
| 78 | + run: | |
| 79 | + ./gradlew sonar \ |
| 80 | + -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \ |
| 81 | + -Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \ |
| 82 | + -Dsonar.login=${{ secrets.SONAR_TOKEN }} \ |
| 83 | + -Dsonar.qualitygate.wait=true |
| 84 | +
|
| 85 | + #Deployment |
| 86 | + - name: Deploy |
| 87 | + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' |
| 88 | + env: |
| 89 | + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVENCENTRAL_SIGNINGKEY }} |
| 90 | + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVENCENTRAL_SIGNINGPASS }} |
| 91 | + ORG_GRADLE_PROJECT_user: ${{ secrets.MAVENCENTRAL_USER }} |
| 92 | + ORG_GRADLE_PROJECT_password: ${{ secrets.MAVENCENTRAL_PASS }} |
| 93 | + run: | |
| 94 | + if [ "${GITHUB_REF}" == "refs/heads/main" ]; then |
| 95 | + currentVersion=$(./gradlew -q currentVersion) |
| 96 | + else |
| 97 | + currentVersion=$(./gradlew -q devVersion) |
| 98 | + fi |
| 99 | + |
| 100 | + echo "currentVersion=$currentVersion" |
| 101 | +
|
| 102 | + ./gradlew publish -PdeployVersion=$currentVersion |
0 commit comments