Skip to content

Commit

Permalink
Updated build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Radu-Voinea committed Sep 8, 2024
1 parent 19e917d commit c17544e
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 67 deletions.
103 changes: 59 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This script requires the following secrets to be set in the repository settings:
# - SELF_PASSWORD

name: Build

on:
Expand All @@ -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: [email protected]

# ==================== 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/[email protected]
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: [email protected]
src/*/build/libs/*.jar
src/*/*/build/libs/*.jar
src/*/*/*/build/libs/*.jar
47 changes: 31 additions & 16 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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
11 changes: 7 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx5G

com.voinearadu.publish=true

0 comments on commit c17544e

Please sign in to comment.