Skip to content

config

config #152

Workflow file for this run

name: Publish Maven Version
on: [push, workflow_dispatch]
permissions: {}
jobs:
runPush:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Read shouldPublish property
id: read_properties
run: |
shouldPublish=$(grep '^shouldPublish=' gradle.properties | cut -d'=' -f2)
echo "shouldPublish=${shouldPublish}" >> $GITHUB_ENV
- name: Increment version
if: ${{ env.shouldPublish == 'true' && github.repository == 'IriDark/Valoria' }}
run: |
# Read the current version
current_version=$(grep '^version=' gradle.properties | cut -d'=' -f2)
echo "Current version: $current_version"
# Split the version into base and last parts
IFS='-' read -ra parts <<< "$current_version"
base_version="${parts[0]}"
last_version="${parts[1]}"
# Split the last version part into segments and increment the last segment
IFS='.' read -ra last_parts <<< "$last_version"
last_parts[-1]=$((last_parts[-1] + 1))
# Construct the new version
new_last_version="${last_parts[*]}"
new_last_version="${new_last_version// /.}"
new_version="$base_version-$new_last_version"
echo "New version: $new_version"
# Update the version line in gradle.properties
sed -i "s/^version=.*/version=$new_version/" gradle.properties
cat gradle.properties
- name: Commit and Push Version Change
if: ${{ env.shouldPublish == 'true' && github.repository == 'IriDark/Valoria' }}
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add gradle.properties
git commit -m "Increment version to $new_version"
git push
- name: Publish Maven Version
env:
maventoken: ${{ secrets.MAVEN_PASSWORD }}
if: ${{ env.shouldPublish == 'true' && github.repository == 'IriDark/Valoria' }}
run: |
./gradlew clean
./gradlew publish