|
| 1 | +name: Build & Publish Plugin |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ 'main' ] |
| 6 | + tags: |
| 7 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 8 | + |
| 9 | +jobs: |
| 10 | + publish: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + issues: read |
| 15 | + checks: write |
| 16 | + pull-requests: write |
| 17 | + packages: write |
| 18 | + if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} |
| 19 | + steps: |
| 20 | + - name: Checkout Repo |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + ssh-key: "${{ secrets.COMMIT_KEY }}" |
| 24 | + fetch-depth: 0 |
| 25 | + - uses: actions/setup-java@v4 |
| 26 | + with: |
| 27 | + distribution: temurin |
| 28 | + java-version: 17 |
| 29 | + - uses: gradle/actions/setup-gradle@v4 |
| 30 | + - name: Pre-merge checks |
| 31 | + run: ./gradlew preMerge --continue |
| 32 | + - name: Publish Test Results |
| 33 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
| 34 | + if: always() |
| 35 | + with: |
| 36 | + files: | |
| 37 | + **/build/test-results/**/*.xml |
| 38 | + - name: Upload HTML Test Results |
| 39 | + uses: actions/upload-artifact@v4 |
| 40 | + if: always() |
| 41 | + with: |
| 42 | + name: Test results |
| 43 | + path: | |
| 44 | + **/build/reports/tests |
| 45 | + retention-days: 7 |
| 46 | + - name: Publish Ktlint reports |
| 47 | + uses: lcollins/checkstyle-github-action@v2 |
| 48 | + if: always() |
| 49 | + with: |
| 50 | + path: "**/build/reports/ktlint/**/*Check.xml" |
| 51 | + # Use Github Packages for snapshots (Gradle Plugin portal doesn't accept them) |
| 52 | + - name: Publish to Github Packages |
| 53 | + shell: bash |
| 54 | + env: |
| 55 | + GRADLE_PUBLISH_KEY: ${{ env.GITHUB_ACTOR }} |
| 56 | + GRADLE_PUBLISH_SECRET: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + run: | |
| 58 | + if [[ "${{ !startsWith(github.ref, 'refs/tags/v') }}" == "true" ]]; then |
| 59 | + ./gradlew --project-dir plugin-build setupPluginUploadFromEnvironment publishAllPublicationsToGitHubPackagesRepository -Prelease.forceSnapshot |
| 60 | + else |
| 61 | + ./gradlew --project-dir plugin-build setupPluginUploadFromEnvironment publishAllPublicationsToGitHubPackagesRepository |
| 62 | + fi |
| 63 | + - name: Publish to Gradle Plugin portal |
| 64 | + if: startsWith(github.ref, 'refs/tags/v') |
| 65 | + shell: bash |
| 66 | + env: |
| 67 | + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} |
| 68 | + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} |
| 69 | + run: ./gradlew --project-dir plugin-build setupPluginUploadFromEnvironment publishPlugins |
| 70 | + - name: Get Version |
| 71 | + id: version |
| 72 | + shell: bash |
| 73 | + run: echo "version=$(./gradlew --console plain --quiet :currentVersion -Prelease.quiet)" >> $GITHUB_OUTPUT |
| 74 | + - name: Upload build artifact |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: flatgraph-codegen-gradle |
| 78 | + path: plugin-build/flatgraph-codegen-gradle/build/libs/flatgraph-codegen-gradle-*.jar |
| 79 | + retention-days: 7 |
| 80 | + if-no-files-found: error |
| 81 | + - name: Vulnerability Scan |
| 82 | + uses: aquasecurity/trivy-action@master |
| 83 | + env: |
| 84 | + TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2 |
| 85 | + TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1 |
| 86 | + with: |
| 87 | + scan-type: 'rootfs' |
| 88 | + scan-ref: plugin-build/flatgraph-codegen-gradle/build/libs/ |
| 89 | + format: 'table' |
| 90 | + exit-code: '1' |
| 91 | + ignore-unfixed: true |
| 92 | + vuln-type: 'os,library' |
| 93 | + severity: 'CRITICAL,HIGH,MEDIUM' |
| 94 | + - name: Create Github Release |
| 95 | + uses: docker://antonyurchenko/git-release:v6 |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + RELEASE_NAME: ${{ steps.version.outputs.version }} |
| 99 | + PRE_RELEASE: ${{ github.ref_type == 'branch' }} |
| 100 | + UNRELEASED: ${{ github.ref_type == 'branch' && 'update' || '' }} |
| 101 | + UNRELEASED_TAG: latest-snapshot |
| 102 | + DRAFT_RELEASE: false |
| 103 | + ALLOW_EMPTY_CHANGELOG: ${{ github.ref_type == 'branch' && 'true' || 'false' }} |
| 104 | + with: |
| 105 | + args: plugin-build/flatgraph-codegen-gradle/build/libs/flatgraph-codegen-gradle-*.jar |
0 commit comments