Update README #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: | |
- 21 | |
fail-fast: false | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Set up JDK 21 | |
uses: actions/[email protected] | |
with: | |
distribution: adopt | |
java-version: '21' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Get current version | |
id: get_version | |
run: | | |
echo "version=$(${{github.workspace}}/gradlew -q pluginVersion)" >> $GITHUB_OUTPUT | |
- name: Check if version is in development | |
id: in_dev_check | |
run: | | |
CURRENT_VERSION=${{ steps.get_version.outputs.version }} | |
echo "Current version: $CURRENT_VERSION" | |
if [[ "$CURRENT_VERSION" == *"InDEV"* ]]; then | |
echo "Version contains 'InDEV'. Skipping..." | |
echo "version_in_dev=true" >> $GITHUB_OUTPUT | |
else | |
echo "Version is not contains 'InDEV'. Proceeding." | |
echo "version_in_dev=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Check if version changed | |
if: steps.in_dev_check.outputs.version_in_dev == 'false' | |
id: version_check | |
run: | | |
git fetch --tags | |
CURRENT_VERSION=${{ steps.get_version.outputs.version }} | |
echo "Current version: $CURRENT_VERSION" | |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "no-tag-found") | |
echo "Latest tag: $LATEST_TAG" | |
if [ "$LATEST_TAG" == "$CURRENT_VERSION" ]; then | |
echo "Version has not changed. Exiting." | |
echo "version_changed=false" >> $GITHUB_OUTPUT | |
else | |
echo "Version has changed. Proceeding." | |
echo "version_changed=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Build with Gradle | |
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true' | |
run: ./gradlew clean plugin-core:shadowJar | |
- name: Upload JAR file | |
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true' | |
uses: actions/[email protected] | |
with: | |
name: Dream-Template | |
path: plugin-core/build/libs/*.jar | |
- name: Download JAR file | |
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true' | |
uses: actions/[email protected] | |
with: | |
name: Dream-Template | |
path: ./plugin-core/build/libs | |
- name: Create GitHub Release | |
if: steps.in_dev_check.outputs.version_in_dev == 'false' && steps.version_check.outputs.version_changed == 'true' | |
id: create_release | |
uses: softprops/[email protected] | |
with: | |
name: v${{ steps.get_version.outputs.version }} | |
tag_name: ${{ steps.get_version.outputs.version }} | |
files: ./plugin-core/build/libs/*.jar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |