From ca76ab35fd23ab0730d03eb5a2e021e04c811bf5 Mon Sep 17 00:00:00 2001 From: Manik Magar Date: Wed, 30 Oct 2024 19:09:41 +0530 Subject: [PATCH] chore: add repo standard configs (#8) --- .github/workflows/build.yml | 174 ++++++++---------------------------- .gitignore | 1 + CODEOWNERS | 4 + LICENSE | 24 +++++ 4 files changed, 66 insertions(+), 137 deletions(-) create mode 100644 CODEOWNERS create mode 100644 LICENSE diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a86d208..31338be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,147 +1,47 @@ -name: Maven Build and Deploy +name: Maven Build and Release for Mule-Plugin on: push: branches: - 'main' - - 'feature/**' + - 'chore/**' + - 'feat/**' + - 'fix/**' pull_request: branches: - 'main' jobs: - Build: - runs-on: ubuntu-latest - - outputs: - version: ${{ steps.set-version.outputs.version }} - token: ${{ steps.get-token.outputs.token }} - - steps: - - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - name: Set up JDK 1.8 for build and unit test - uses: actions/setup-java@v3 - with: - distribution: adopt-hotspot - java-version: 8 - cache: maven - server-id: mulesoft-ee-releases - server-username: MULE_EE_USERNAME - server-password: MULE_EE_PASSWORD - - - name: Set Version - id: set-version - run: echo version=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT - - - name: Print Version - run: echo "Version ${{ steps.set-version.outputs.version }}" - - - name: Compile - run: ./mvnw compile - env: - MULE_EE_USERNAME: ${{ secrets.MULE_EE_USERNAME }} - MULE_EE_PASSWORD: ${{ secrets.MULE_EE_PASSWORD }} - - - name: Verify - run: ./mvnw --batch-mode verify - env: - MULE_EE_USERNAME: ${{ secrets.MULE_EE_USERNAME }} - MULE_EE_PASSWORD: ${{ secrets.MULE_EE_PASSWORD }} - - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - junit_files: ./**/surefire-reports/*.xml - - - name: Set up JDK 1.8 for maven central publish - uses: actions/setup-java@v3 - with: - distribution: adopt-hotspot - java-version: 8 - cache: maven - server-id: ossrh - server-username: OSSRH_USERNAME - server-password: OSSRH_PASSWORD - gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} - gpg-passphrase: MAVEN_GPG_PASSPHRASE - - - name: Publish to Maven Central - id: publish-to-maven-central - if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - run: ./mvnw clean deploy -DskipTests -Drelease=true - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - - - name: Set up JDK for Exchange Publish - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 8 - cache: maven - server-id: anypoint-exchange - server-username: ANYPOINT_USERNAME - server-password: ANYPOINT_PASSWORD - - - name: Get Exchange Token - id: get-token - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - run: | - echo token=$(curl --location --request POST 'https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'client_id=${{secrets.ANYPOINT_EXCHANGE_CLIENT_ID}}' --data-urlencode 'client_secret=${{secrets.ANYPOINT_EXCHANGE_CLIENT_SECRET}}' --data-urlencode 'grant_type=client_credentials' | jq -r .access_token) >> $GITHUB_OUTPUT - - - name: Publish Exchange Artifact - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - env: - ANYPOINT_USERNAME: "~~~Token~~~" - ANYPOINT_PASSWORD: ${{ steps.get-token.outputs.token }} - run: ./deploy-to-exchange.sh ${{ secrets.ANYPOINT_ORG_ID }} - - - name: Tag Release - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - env: - GIT_USER: ${{ secrets.GIT_USER }} - GIT_PASSWORD: ${{ secrets.GIT_TOKEN }} - run: | - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - git config --global user.name "${{ github.actor }}" - git remote set-url origin "https://${{github.actor}}:${{ github.token }}@github.com/${{ github.repository }}.git" - git tag -a "v${{ steps.set-version.outputs.version }}" "${{ github.sha }}" -m "Version ${{ steps.set-version.outputs.version }}" - git push --follow-tags - - - name: Increment Version - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - run: | - ./mvnw clean build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT -DprocessAllModules versions:commit - - - name: Set New Version Variable - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - id: set-new-version - run: echo version=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT - - - name: Create Pull Request - if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} - uses: peter-evans/create-pull-request@v4 - with: - branch: "feature/v${{ steps.set-new-version.outputs.version }}" - commit-message: "[create-pull-request] Auto increment to v${{ steps.set-new-version.outputs.version }}" - title: "Auto increment to v${{ steps.set-new-version.outputs.version }}" - delete-branch: true - assignees: ${{ github.actor }} - reviewers: adesjardin,adammead, manikmagar, kkingavio - -# - name: Add Release Note and Create Github Release -# if: ${{ !contains(steps.set-version.outputs.version, 'SNAPSHOT') && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} -# uses: release-drafter/release-drafter@v5 -# with: -# version: ${{ steps.set-version.outputs.version }} -# tag: v${{ steps.set-version.outputs.version }} -# publish: true -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + Build-Maven: + uses: avioconsulting/shared-workflows/.github/workflows/maven-build.yml@main + secrets: inherit + with: + include-mule-ee-repo: true + # java-distribution: adopt-hotspot + # java-version: 8 + # include-test-results: true + # maven-args: -X + + Release-Maven: + needs: Build-Maven + uses: avioconsulting/shared-workflows/.github/workflows/maven-release.yml@main + secrets: inherit + with: + app-version: ${{ needs.Build-Maven.outputs.app-version }} + publish-maven-central: true + # java-distribution: adopt-hotspot + # java-version: 8 + # maven-args: -X + # main-branch: main + + Post-Release-Maven: + needs: [Build-Maven, Release-Maven] + uses: avioconsulting/shared-workflows/.github/workflows/maven-post-release.yml@main + secrets: inherit + with: + app-version: ${{ needs.Build-Maven.outputs.app-version }} + # java-distribution: adopt-hotspot + # java-version: 8 + # maven-args: -X + # main-branch: main + # pr-reviewers: adesjardin, manikmagar, kkingavio \ No newline at end of file diff --git a/.gitignore b/.gitignore index e31aee7..6f0edaa 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ target/ velocity.log .classpath .project +.idea/ diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..18cce40 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,4 @@ + +## Require review from one of the member from this team + +* @avioconsulting/avio-mulesoft-frameworks \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ae3e818 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +BSD 2-Clause License + +Copyright (c) 2022-2024, AVIO Consulting, LLC + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file