Skip to content

bump version

bump version #8

name: Build and Release ShadowJar
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build-and-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Java 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- name: Extract version
id: get_version
run: |
VERSION=$(grep -E "^version\s+['\"]" build.gradle | head -n 1 | sed -E "s/version\s+['\"]([^'\"]+)['\"]/\1/")
echo "Found version: $VERSION"
echo "::set-output name=VERSION::$VERSION"
- name: Check if version is new
id: version_check
run: |
CURRENT_VERSION=${{ steps.get_version.outputs.VERSION }}
echo "Current version: $CURRENT_VERSION"
if git rev-parse "refs/tags/${CURRENT_VERSION}" >/dev/null 2>&1; then
echo "Tag ${CURRENT_VERSION} already exists. Skipping release."
echo "::set-output name=new_version::false"
else
echo "Tag ${CURRENT_VERSION} does not exist. Proceeding with release."
echo "::set-output name=new_version::true"
fi
- name: Grant execute permission for Gradle wrapper
run: chmod +x gradlew
- name: Build shadowJar
if: steps.version_check.outputs.new_version == 'true'
run: ./gradlew shadowJar
- name: Create Release
if: steps.version_check.outputs.new_version == 'true'
id: create_release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.get_version.outputs.VERSION }}
name: Release ${{ steps.get_version.outputs.VERSION }}
generateReleaseNotes: true
- name: Upload artifact to release
if: steps.version_check.outputs.new_version == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
files: build/libs/*-all.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}