Skip to content

Commit

Permalink
Update gradle.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyt291 authored Nov 25, 2023
1 parent 3032822 commit 4a8ca32
Showing 1 changed file with 47 additions and 24 deletions.
71 changes: 47 additions & 24 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Build and Release

name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read
on: push

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
- uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
java-version: '17'
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
run: ./gradlew shadowJar

- name: Extract version from build.gradle
id: extract_version
run: |
VERSION=$(grep '^version ' build.gradle | awk '{print $3}' | tr -d "'")
echo "Extracted version is $VERSION"
echo "::set-output name=version::$VERSION"
- name: Check if Tag Exists
id: check_tag
run: |
if git rev-parse "v${{ steps.extract_version.outputs.version }}" >/dev/null 2>&1; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Create Tag
# You may pin to the exact commit or the version.
# uses: negz/create-tag@39bae1e0932567a58c20dea5a1a0d18358503320
uses: negz/create-tag@v1
if: steps.check_tag.outputs.exists == 'false'
continue-on-error: true
with:
token: ${{secrets.TEST}}
version: "v${{ steps.extract_version.outputs.version }}"
message: ""

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
arguments: build
token: ${{secrets.TEST}}
tag_name: "v${{ steps.extract_version.outputs.version }}"
name: "Release v${{ steps.extract_version.outputs.version }}"
files: build/libs/*.jar

0 comments on commit 4a8ca32

Please sign in to comment.