diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..2a8838e --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @darksaid98 diff --git a/.github/actions/gradle/action.yml b/.github/actions/gradle/action.yml index aac0ff3..2b3f4e6 100644 --- a/.github/actions/gradle/action.yml +++ b/.github/actions/gradle/action.yml @@ -1,5 +1,5 @@ name: 'Setup Gradle' -description: 'Grant execute permissions and validate Gradle wrapper' +description: 'Grant execute permissions, validate Gradle wrapper, setup Gradle wrapper' runs: using: 'composite' @@ -9,7 +9,9 @@ runs: shell: bash - name: Validate Gradle Wrapper Authenticity - uses: gradle/actions/wrapper-validation@v3 + uses: gradle/actions/wrapper-validation@v4 - - name: Setup Gradle and Caching - uses: gradle/actions/setup-gradle@v3 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + add-job-summary: 'on-failure' diff --git a/.github/actions/jdk/action.yml b/.github/actions/jdk/action.yml index ea75f21..012e1df 100644 --- a/.github/actions/jdk/action.yml +++ b/.github/actions/jdk/action.yml @@ -4,8 +4,12 @@ description: 'Set up JDK' inputs: java-version: description: 'Java version' - required: true + required: false default: '8' + distribution: + description: 'JDK Distribution' + required: false + default: 'temurin' runs: using: 'composite' @@ -14,4 +18,4 @@ runs: uses: actions/setup-java@v4 with: java-version: ${{ inputs.java-version }} - distribution: 'temurin' + distribution: ${{ inputs.distribution }} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..377a6ff --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,26 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + commit-message: + prefix: "ci:" + target-branch: "main" + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" + commit-message: + prefix: "build:" + target-branch: "main" + groups: + "org.flywaydb": + patterns: + - "org.flywaydb*" + "org.jooq": + patterns: + - "org.jooq*" + "net.kyori": + patterns: + - "net.kyori*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a378e3d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI/CD + +on: + push: + branches: + - "main" + - "master" + tags: + - "*.*.*" + pull_request: + branches: + - "*" + workflow_dispatch: + +permissions: + attestations: write + contents: write + id-token: write + checks: write + +concurrency: + group: ${{ format('{0}-{1}', github.job, github.ref) }} + cancel-in-progress: true + +jobs: + test: + name: Test + uses: ./.github/workflows/test.yml + with: + os: ubuntu-latest + java: 21 + + stage: + name: Stage + needs: test + if: ${{ github.event_name != 'pull_request' }} + uses: ./.github/workflows/stage.yml + with: + os: ubuntu-latest + java: 21 + secrets: inherit + + deploy: + name: Deploy + needs: stage + if: github.ref_type == 'tag' + uses: ./.github/workflows/deploy.yml + with: + os: ubuntu-latest + secrets: inherit diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d970a22 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,67 @@ +name: Deploy + +on: + workflow_call: + inputs: + os: + description: "The os the workflow shold use" + required: false + type: string + default: ubuntu-latest + +permissions: + contents: write + +jobs: + deploy: + name: "Release" + runs-on: ${{ inputs.os }} + steps: + - name: Download Snapshot + uses: actions/download-artifact@v4 + with: + name: Release + run-id: ${{ github.event.workflow_run.id }} + path: "${{ github.workspace }}/tmp/" + + # Generate changelog + - name: Generate Changelog + uses: ardalanamini/auto-changelog@v4 + id: changelog + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + commit-types: | + feat: New Features + fix: Bug Fixes + build: Build System & Dependencies + perf: Performance Improvements + docs: Documentation + test: Tests + refactor: Refactors + chore: Chores + ci: CI + style: Code Style + revert: Reverts + default-commit-type: Other Changes + release-name: ${{ github.ref_name }} + mention-authors: true + mention-new-contributors: true + include-compare-link: true + include-pr-links: true + include-commit-links: true + semver: true + use-github-autolink: true + + # Create release + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: | + ${{ github.workspace }}/tmp/* + fail_on_unmatched_files: true + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ github.ref_name }} + draft: false + prerelease: ${{ contains(github.ref_name, '-RC-') }} + generate_release_notes: false + body: ${{ steps.changelog.outputs.changelog }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml deleted file mode 100644 index 451058e..0000000 --- a/.github/workflows/releases.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: Release - -on: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: write - discussions: write - pull-requests: write - -jobs: - tests: - name: Tests - uses: ./.github/workflows/tests.yml - release: - name: Build - needs: [tests] - strategy: - matrix: - os: [ubuntu-latest] - java: [8] - runs-on: ${{ matrix.os }} - steps: - # Checkout repository - - name: Checkout Repository - uses: actions/checkout@v4 - - # Build setup - - name: Setup JDK - uses: ./.github/actions/jdk - with: - java-version: ${{ matrix.java }} - - - name: Setup Gradle - uses: ./.github/actions/gradle - - # Makes the next semantic tag variable available for use in workflow - - uses: jveldboom/action-conventional-versioning@v1 - id: version - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - default-bump: patch - - # Build and upload to Maven - - name: Build with Gradle & Publish to Maven - run: ./gradlew clean build publishAllPublicationsToReleasesRepository -PcustomVersion=${{ steps.version.outputs.version }} --info - env: - MAVEN_USERNAME: ${{ secrets.MAVEN_NAME }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }} - - # Generate changelog - - name: Changelog - uses: ardalanamini/auto-changelog@v4 - id: changelog - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - commit-types: | - feat: New Features - fix: Bug Fixes - build: Build System & Dependencies - perf: Performance Improvements - docs: Documentation - test: Tests - refactor: Refactors - chore: Chores - ci: CI - style: Code Style - revert: Reverts - default-commit-type: Other Changes - release-name: ${{ steps.version.outputs.version-with-prefix }} - mention-authors: true - mention-new-contributors: true - include-compare-link: true - include-pr-links: true - include-commit-links: true - semver: true - use-github-autolink: true - - # Create release - - name: Create Release - uses: softprops/action-gh-release@v2 - with: - name: ${{ steps.version.outputs.version-with-prefix }} - tag_name: ${{ steps.version.outputs.version }} - generate_release_notes: false - body: ${{ steps.changelog.outputs.changelog }} - files: | - ${{ github.workspace }}/build/libs/* - token: ${{ secrets.GITHUB_TOKEN }} - draft: false - prerelease: ${{ contains(github.ref_name, '-RC-') }} \ No newline at end of file diff --git a/.github/workflows/snapshots.yml b/.github/workflows/snapshots.yml deleted file mode 100644 index 992ab54..0000000 --- a/.github/workflows/snapshots.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Snapshot - -on: - push: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: write - discussions: write - pull-requests: write - -jobs: - tests: - name: Tests - uses: ./.github/workflows/tests.yml - snapshot: - name: Build - needs: [tests] - strategy: - matrix: - os: [ubuntu-latest] - java: [8] - runs-on: ${{ matrix.os }} - steps: - # Checkout repository - - name: Checkout Repository - uses: actions/checkout@v4 - - # Build setup - - name: Setup JDK - uses: ./.github/actions/jdk - with: - java-version: ${{ matrix.java }} - - - name: Setup Gradle - uses: ./.github/actions/gradle - - # Makes the next semantic tag variable available for use in workflow - - uses: jveldboom/action-conventional-versioning@v1 - id: version - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - default-bump: patch - - # If on main branch, upload snapshot to maven - - name: Build with Gradle & Publish to Maven - if: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) - run: ./gradlew clean build publishAllPublicationsToSnapshotsRepository -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info - env: - MAVEN_USERNAME: ${{ secrets.MAVEN_NAME }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }} - - # Else if, upload built jar from push - - name: Build with Gradle - if: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) == false - run: ./gradlew clean build -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info - - - name: Upload build artifact - uses: actions/upload-artifact@v4 - if: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) == false - with: - name: Build ${{ steps.version.outputs.version-with-prefix }}-SNAPSHOT-${{ github.run_number }} - path: ${{ github.workspace }}/build/libs/ - retention-days: 3 diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml new file mode 100644 index 0000000..ccbe81f --- /dev/null +++ b/.github/workflows/stage.yml @@ -0,0 +1,118 @@ +name: Stage + +on: + workflow_call: + inputs: + os: + description: "The os the workflow shold use" + required: false + type: string + default: ubuntu-latest + java: + description: "The Java version the workflow should use" + required: false + type: number + default: 21 + +permissions: + attestations: write + contents: write + id-token: write + +jobs: + stage-build-snapshot: + name: "Build Snapshot" + if: github.ref_type != 'tag' + runs-on: ${{ inputs.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup JDK + uses: ./.github/actions/jdk + with: + java-version: ${{ inputs.java }} + + - name: Setup Gradle + uses: ./.github/actions/gradle + + # Get version field in project properties file for snapshot version + - name: Get Project Version + shell: bash + run: | + echo "CUSTOM_VERSION=$(grep "^version=" ./gradle.properties | awk -F'=' '{print $2}')-SNAPSHOT-${{ github.run_number }}" >> $GITHUB_ENV + + - name: Build with Gradle + run: ./gradlew build -PaltVer=${{ env.CUSTOM_VERSION }} -x test --info + + - name: Upload Snapshot + uses: actions/upload-artifact@v4 + with: + name: Snapshot-${{ github.run_number }} + path: ${{ github.workspace }}/build/libs/ + retention-days: 7 + + stage-version: + name: "Update Project Version" + runs-on: ${{ inputs.os }} + if: github.ref_type == 'tag' + steps: + # Checkout repository + - name: Checkout Repository + if: contains(github.ref_name, '-RC-') == false + uses: actions/checkout@v4 + + # Update version field in project properties file + - name: Update Gradle Project Version + if: contains(github.ref_name, '-RC-') == false + shell: bash + run: | + sed -i -b 's/^version=.*/version=${{ github.ref_name }}/' ./gradle.properties + + # Commit and push updated version properties file + - name: Update repository + if: contains(github.ref_name, '-RC-') == false + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore: bump version to v${{ github.ref_name }}" + branch: ${{ github.event.repository.default_branch }} + + stage-build-release: + name: "Build Release" + needs: stage-version + runs-on: ${{ inputs.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup JDK + uses: ./.github/actions/jdk + with: + java-version: ${{ inputs.java }} + + - name: Setup Gradle + uses: ./.github/actions/gradle + + - name: Set Version Environment Variable + run: | + echo "CUSTOM_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + + - name: Build with Gradle and publish + run: ./gradlew build publish deployAll -PaltVer=${{ env.CUSTOM_VERSION }} -x test --info + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_TOKEN }} + GPG_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY }} + GPG_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_SECRET_KEY_PASSWORD }} + + - name: Generate Build Provenance Attestations + uses: actions/attest-build-provenance@v2 + with: + subject-path: "${{ github.workspace }}/build/libs/*" + + - name: Upload Snapshot + uses: actions/upload-artifact@v4 + with: + name: Release + path: ${{ github.workspace }}/build/libs/ + retention-days: 7 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..d66dd6f --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,26 @@ +name: "Close Stale Issues & PRs" +on: + schedule: + - cron: "30 1 * * *" + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + stale-issue-message: "This issue has been automatically marked as stale because it has been open for 60 days with no activity." + stale-pr-message: "This PR has been automatically marked as stale because it has been open for 60 days with no activity." + close-issue-message: "This issue was closed because it has been stalled for -1 days with no activity." + close-pr-message: "This PR was closed because it has been stalled for -1 days with no activity." + days-before-issue-stale: 60 + days-before-pr-stale: 60 + days-before-issue-close: -1 + days-before-pr-close: -1 + stale-issue-label: "stale" + stale-pr-label: "stale" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..971198c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,47 @@ +name: Test + +on: + workflow_call: + inputs: + os: + description: "The os the workflow shold use" + required: false + type: string + default: ubuntu-latest + java: + description: "The Java version the workflow should use" + required: false + type: number + default: 21 + +permissions: + checks: write + contents: write + +jobs: + test-build: + name: "Run Tests" + runs-on: ${{ inputs.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup JDK + uses: ./.github/actions/jdk + with: + java-version: ${{ inputs.java }} + + - name: Setup Gradle + uses: ./.github/actions/gradle + + - name: Test with Gradle + run: ./gradlew test --info + + - name: Publish Test Report + uses: mikepenz/action-junit-report@v5 + if: success() || failure() + with: + require_tests: false + fail_on_failure: true + check_name: Test Report + report_paths: '**/build/test-results/**/TEST-*.xml' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 1deab61..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Tests - -on: - workflow_dispatch: - workflow_call: - -permissions: - contents: write - discussions: write - pull-requests: write - -jobs: - test-build: - name: Build - strategy: - matrix: - os: [ubuntu-latest] - java: [8] - runs-on: ${{ matrix.os }} - steps: - # Checkout repository - - name: Checkout Repository - uses: actions/checkout@v4 - - # Setup JDK - - name: Setup JDK - uses: ./.github/actions/jdk - with: - java-version: ${{ matrix.java }} - - # Setup Gradle & Verify wrapper - - name: Setup Gradle - uses: ./.github/actions/gradle - - # Makes the next semantic tag variable available for use in workflow - - uses: jveldboom/action-conventional-versioning@v1 - id: version - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - default-bump: patch - - # Build with Gradle - - name: Build with Gradle - run: ./gradlew clean build -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info