From c17544e6d28f0f8c709fe037b8d13285eb3df782 Mon Sep 17 00:00:00 2001 From: Voinea Radu Date: Sun, 8 Sep 2024 06:57:25 +0300 Subject: [PATCH] Updated build script --- .github/workflows/build.yml | 103 +++++++++++++++++++-------------- .github/workflows/pr_check.yml | 47 ++++++++++----- build.gradle.kts | 11 ++-- gradle.properties | 4 +- 4 files changed, 98 insertions(+), 67 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 267a2cf..65b3f66 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,3 @@ -# This script requires the following secrets to be set in the repository settings: -# - SELF_PASSWORD - name: Build on: @@ -17,83 +14,101 @@ on: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: write steps: - # ==================== SETUPS ==================== + # ==================== SETUPS ==================== - - name: Setup codebase + - name: Checkout Codebase uses: actions/checkout@v4 + with: + node-version: '12.x' - name: Setup Python - uses: actions/setup-python@v4.7.1 + uses: actions/setup-python@v5.2.0 - name: Setup Java uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 21 - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v4 with: - gradle-version: 7.6.1 + build-scan-publish: true + build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-use-agree: "yes" - # ==================== VERSION ===================== + # ==================== INCREMENT VERSION ===================== - - - name: External scripts - Increment version + - name: Increment Version run: | - wget -O tmp-increment_version.py https://raw.githubusercontent.com/L1ghtDream/report/cdn/increment_version-v2.py - python tmp-increment_version.py + python3 scripts/increment_version.py + # ==================== PUBLISH ==================== - # ==================== BUILD ==================== + - name: Commit to Repository + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Incremented patch version + commit_options: '--no-verify --signoff' + commit_user_name: Voinea Radu + commit_user_email: contact@voinearadu.com + # ==================== BUILD ==================== - - name: Execute Gradle build - run: ./gradlew build + - name: Export Credentials + run: | + mkdir -p ~/.gradle + echo " + com.voinearadu.url=https://repository.voinearadu.com/repository/maven-releases/ + com.voinearadu.auth.username=admin + com.voinearadu.auth.password=${{ secrets.NEXUS_PASSWORD }} + " > ~/.gradle/gradle.properties + if [ "${{ secrets.NEXUS_PASSWORD }}" == "" ]; then echo "com.voinearadu.publish=false" >> ~/.gradle/gradle.properties; fi + + - name: Cache Gradle Dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle + restore-keys: | + ${{ runner.os }}-gradle + - name: Set gradle permissions + run: chmod +x gradlew - # ==================== EXTERNAL SCRIPTS ==================== + - name: Execute Gradle Build + run: ./gradlew build + # ==================== ENVIRONMENT VARIABLES ==================== - name: External scripts - Environment Variables run: | - wget -O tmp-environment_variables.sh https://raw.githubusercontent.com/L1ghtDream/report/cdn/environment_variables.sh - chmod +x tmp-environment_variables.sh - ./tmp-environment_variables.sh ${{ github.REPOSITORY }} - - - name: External scripts - Readme - run: | - wget -O tmp-create_readme.py https://raw.githubusercontent.com/L1ghtDream/report/cdn/create_readme-v2.py - python tmp-create_readme.py ${{ env.REPOSITORY_NAME }} ${{ env.ARTIFACT }} ${{ env.VERSION }} - + echo "VERSION=$(./gradlew properties -q | grep "^version:" | awk '{print $2}')" >> $GITHUB_ENV + echo "ARTIFACT=$(./gradlew properties -q | grep "^name:" | awk '{print $2}')" >> $GITHUB_ENV + echo "GROUP=$(./gradlew properties -q | grep "^group:" | awk '{print $2}')" >> $GITHUB_ENV + echo "REPOSITORY_NAME=$(echo $REPOSITORY_NAME | awk -F'/' '{print $2}')" >> $GITHUB_ENV # ==================== PUBLISH ==================== - - - name: Uploading artifacts - run: | - wget -O tmp-publish.sh https://raw.githubusercontent.com/L1ghtDream/report/cdn/publish.sh - chmod +x tmp-publish.sh - ./tmp-publish.sh ${{ github.REPOSITORY }} ${{ secrets.GITHUB_TOKEN }} ${{ secrets.SELF_PASSWORD }} + - name: Execute Gradle Publish + run: ./gradlew publish - name: Automatic Releases uses: marvinpinto/action-automatic-releases@v1.2.1 - if: github.event_name != 'pull_request' with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "${{ env.VERSION }}" - prerelease: false + prerelease: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' }} title: "${{ env.VERSION }}" files: | build/libs/*.jar - - - name: Commit any changes made to the repo - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: Incremented patch version - commit_options: '--no-verify --signoff' - - commit_user_name: Radu Voinea - commit_user_email: contact@voinearadu.com \ No newline at end of file + src/*/build/libs/*.jar + src/*/*/build/libs/*.jar + src/*/*/*/build/libs/*.jar diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index 4f09a59..40753df 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -1,34 +1,49 @@ -name: PR Check +name: Pull Request Check on: [ pull_request ] jobs: - build: + pull-request-check: runs-on: ubuntu-latest - steps: - # ===== SETUPS ====== + timeout-minutes: 60 - - name: Setup codebase + steps: + # ==================== SETUPS ==================== + - name: Checkout Codebase uses: actions/checkout@v4 + with: + node-version: '12.x' - - # ===== JAVA ====== - + - name: Setup Python + uses: actions/setup-python@v5.2.0 - name: Setup Java uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 21 - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v4 with: - gradle-version: 7.6.1 - - # ===== BUILD ====== + build-scan-publish: true + build-scan-terms-of-use-url: "https://gradle.com/terms-of-service" + build-scan-terms-of-use-agree: "yes" + # ==================== BUILD ==================== - - name: Execute Gradle build - run: gradle build - + - name: Cache Gradle Dependencies + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle + restore-keys: | + ${{ runner.os }}-gradle + + - name: Set gradle permissions + run: chmod +x gradlew + + - name: Execute Gradle Build + run: ./gradlew build diff --git a/build.gradle.kts b/build.gradle.kts index b837f6e..493fa0f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,10 +72,13 @@ subprojects { } repositories { - maven(url = (project.findProperty("voinearadu.url") ?: "") as String) { - credentials(PasswordCredentials::class) { - username = (project.findProperty("voinearadu.auth.username") ?: "") as String - password = (project.findProperty("voinearadu.auth.password") ?: "") as String + if (project.properties["com.voinearadu.publish"] == "true") { + maven(url = (project.findProperty("com.voinearadu.url") ?: "") as String) { + name = "VoineaRaduRepository" + credentials(PasswordCredentials::class) { + username = (project.findProperty("com.voinearadu.auth.username") ?: "") as String + password = (project.findProperty("com.voinearadu.auth.password") ?: "") as String + } } } } diff --git a/gradle.properties b/gradle.properties index ac9900d..25c1d3c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx5G - +com.voinearadu.publish=true \ No newline at end of file