Skip to content

Merge pull request #112 from Jake-Moore/dependabot/gradle/com.rabbitm… #289

Merge pull request #112 from Jake-Moore/dependabot/gradle/com.rabbitm…

Merge pull request #112 from Jake-Moore/dependabot/gradle/com.rabbitm… #289

name: Maven Deploy & Release
on:
push:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write # Access to Publish a Release
packages: write # Access to Publish a Package
#--------------------------------------------------------------------------------------------
# Build the Artifact and Publish to Luxious Repository
#--------------------------------------------------------------------------------------------
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
# 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
with:
gradle-version: '8.7'
- name: Extract Version from Gradle
id: extract_version
run: |
gradle clean
version=$(gradle properties -q | grep "^version:" | awk '{print $2}')
echo "version=$version" >> $GITHUB_OUTPUT
- name: Display Version
run: echo "Version is ${{ steps.extract_version.outputs.version }}"
- name: Build with Gradle 8.7
if: "!endsWith(steps.extract_version.outputs.version, 'SNAPSHOT')"
run: gradle publish
env:
LUXIOUS_NEXUS_USER: ${{ secrets.MAVEN_NAME }}
LUXIOUS_NEXUS_PASS: ${{ secrets.MAVEN_SECRET }}
#--------------------------------------------------------------------------------------------
# Create a Github Release
#--------------------------------------------------------------------------------------------
- name: Create Release (Spigot Jar + Module Jars)
if: "!endsWith(steps.extract_version.outputs.version, 'SNAPSHOT')"
uses: ncipollo/release-action@v1
with:
artifacts: "spigot-jar/build/libs/*.jar, spigot-utils/build/libs/*.jar, standalone-jar/build/libs/*.jar, standalone-utils/build/libs/*.jar, shared-jar/build/libs/*.jar"
allowUpdates: true
removeArtifacts: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
tag: "${{ steps.extract_version.outputs.version }}"
# Update the README.md Badge with the new version
- name: Create Version Badge
if: "!endsWith(steps.extract_version.outputs.version, 'SNAPSHOT')"
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 5dfd7c9bb8b81ae5867c81e9a77ee821
filename: test.json # Use test.svg if you want to use the SVG mode.
label: Latest Release
message: "${{ steps.extract_version.outputs.version }}"
color: blue
- name: Update Download Link Gist
if: "!endsWith(steps.extract_version.outputs.version, 'SNAPSHOT')"
env:
GIST_ID: 5dfd7c9bb8b81ae5867c81e9a77ee821
AUTH_KEY: ${{ secrets.GIST_SECRET }}
VERSION: ${{ steps.extract_version.outputs.version }}
run: |
CONTENT="https://github.com/Jake-Moore/KamiCommon/releases/download/$VERSION/kamicommon-$VERSION.jar"
curl -X PATCH \
-H "Authorization: token $AUTH_KEY" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/gists/$GIST_ID \
-d "{\"files\": {\"kamicommon.txt\": {\"content\": \"$CONTENT\"}}}"
# Will revisit later, repo settings don't allow direct pushes to main from actions atm
# # Automatically bump the version
# # This will also automatically update the VERSION to -SNAPSHOT
# # So that any PRs or commits that are merged to main won't be automatically released
# # It will now require an intentional release by changing the version
# - name: Increment Version
# if: "!endsWith(steps.extract_version.outputs.version, 'SNAPSHOT')"
# id: increment_version
# run: |
# # Extract the current version and split it into components
# version=$current_version
# major=$(echo $version | cut -d'.' -f1)
# minor=$(echo $version | cut -d'.' -f2)
# patch=$(echo $version | cut -d'.' -f3)
# build=$(echo $version | cut -d'.' -f4)
#
# # Increment the patch or minor version (you can customize this logic)
# new_build=$((build + 1))
# new_version="$major.$minor.$patch.$new_build-SNAPSHOT"
#
# echo "new_version=$new_version" >> $GITHUB_OUTPUT
# echo "New Gradle Version: $new_version"
#
# # Push changes to the build.gradle.kts file
# - name: Update VERSION in build.gradle.kts
# if: "!endsWith(steps.extract_version.outputs.version, 'SNAPSHOT')"
# run: |
# new_version=${{ steps.increment_version.outputs.new_version }}
# sed -i 's/^var VERSION = ".*"/var VERSION = "$new_version"/' build.gradle.kts
# git config --global user.name "github-actions[bot]"
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
# git commit -am "Increment version to $new_version after release"
# git push