Added buildAll task, Free version logic and Spigot BBCode templates #11
This file contains hidden or 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: StackCraft Releases | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: stackcraft-release-${{ github.ref }} | |
| cancel-in-progress: false | |
| env: | |
| GRADLE_OPTS: "-Dorg.gradle.daemon=false" | |
| jobs: | |
| build_release: | |
| name: Build & Publish Releases | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Java JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '25' | |
| cache: gradle | |
| - name: Build Plugin | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean build | |
| - name: Prepare Release Metadata | |
| id: meta | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| VERSION=$(./gradlew properties -q | awk '/^version:/ { print $2; exit }') | |
| if [ -z "$VERSION" ]; then | |
| echo "Gradle project version could not be detected." >&2 | |
| exit 1 | |
| fi | |
| SHORT_SHA=$(git rev-parse --short HEAD) | |
| COMMIT_COUNT=$(git rev-list --count HEAD) | |
| VERSION_TAG="v${VERSION}" | |
| DEV_TAG="latest-devbuild" | |
| JAR_FILE=$(find build/libs -maxdepth 1 -type f -name "*.jar" ! -name "*-sources.jar" ! -name "*-javadoc.jar" | sort | head -n 1) | |
| if [ -z "$JAR_FILE" ] || [ ! -f "$JAR_FILE" ]; then | |
| echo "No build jar found in build/libs." >&2 | |
| exit 1 | |
| fi | |
| mkdir -p dist | |
| RELEASE_JAR="dist/StackCraft-${VERSION}.jar" | |
| DEV_JAR="dist/StackCraft-build-${COMMIT_COUNT}.jar" | |
| cp "$JAR_FILE" "$RELEASE_JAR" | |
| cp "$JAR_FILE" "$DEV_JAR" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "version_tag=$VERSION_TAG" >> "$GITHUB_OUTPUT" | |
| echo "dev_tag=$DEV_TAG" >> "$GITHUB_OUTPUT" | |
| echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT" | |
| echo "release_jar=$RELEASE_JAR" >> "$GITHUB_OUTPUT" | |
| echo "dev_jar=$DEV_JAR" >> "$GITHUB_OUTPUT" | |
| - name: Generate Changelogs | |
| id: changelog | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| VERSION_TAG="${{ steps.meta.outputs.version_tag }}" | |
| VERSION="${{ steps.meta.outputs.version }}" | |
| SHORT_SHA="${{ steps.meta.outputs.short_sha }}" | |
| { | |
| echo "## StackCraft ${VERSION}" | |
| echo | |
| echo "- Version: \`${VERSION}\`" | |
| echo "- Commit: \`${GITHUB_SHA}\`" | |
| echo "- Branch: \`${GITHUB_REF_NAME}\`" | |
| echo "- Build: [#${GITHUB_RUN_NUMBER}](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})" | |
| } > version_changelog.md | |
| { | |
| echo "## Latest StackCraft Dev Build" | |
| echo | |
| echo "- Version: \`${VERSION}\`" | |
| echo "- Commit: \`${GITHUB_SHA}\`" | |
| echo "- Branch: \`${GITHUB_REF_NAME}\`" | |
| echo "- Build: [#${GITHUB_RUN_NUMBER}](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID})" | |
| } > devbuild_changelog.md | |
| echo "version_body=version_changelog.md" >> "$GITHUB_OUTPUT" | |
| echo "dev_body=devbuild_changelog.md" >> "$GITHUB_OUTPUT" | |
| - name: Publish Latest Dev Build Release | |
| if: github.ref_name == github.event.repository.default_branch | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| DEV_TAG="${{ steps.meta.outputs.dev_tag }}" | |
| DEV_JAR="${{ steps.meta.outputs.dev_jar }}" | |
| DEV_BODY="${{ steps.changelog.outputs.dev_body }}" | |
| git tag -f "$DEV_TAG" "$GITHUB_SHA" | |
| git push -f origin "refs/tags/${DEV_TAG}" | |
| if gh release view "$DEV_TAG" >/dev/null 2>&1; then | |
| # Delete old assets to prevent accumulating Dev Build jars with different commit counts | |
| OLD_ASSETS=$(gh release view "$DEV_TAG" --json assets --jq '.assets.[].name') | |
| for ASSET in $OLD_ASSETS; do | |
| if [[ "$ASSET" == *.jar ]]; then | |
| gh release delete-asset "$DEV_TAG" "$ASSET" -y || true | |
| fi | |
| done | |
| gh release edit "$DEV_TAG" \ | |
| --title "Latest StackCraft Dev Build" \ | |
| --notes-file "$DEV_BODY" \ | |
| --latest | |
| else | |
| gh release create "$DEV_TAG" \ | |
| --title "Latest StackCraft Dev Build" \ | |
| --notes-file "$DEV_BODY" \ | |
| --latest | |
| fi | |
| gh release upload "$DEV_TAG" "$DEV_JAR" --clobber | |
| - name: Publish Version Release | |
| if: github.ref_name == github.event.repository.default_branch | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| VERSION_TAG="${{ steps.meta.outputs.version_tag }}" | |
| RELEASE_JAR="${{ steps.meta.outputs.release_jar }}" | |
| VERSION_BODY="${{ steps.changelog.outputs.version_body }}" | |
| git tag -f "$VERSION_TAG" "$GITHUB_SHA" | |
| git push -f origin "refs/tags/${VERSION_TAG}" | |
| if gh release view "$VERSION_TAG" >/dev/null 2>&1; then | |
| gh release edit "$VERSION_TAG" \ | |
| --title "StackCraft ${{ steps.meta.outputs.version }}" \ | |
| --notes-file "$VERSION_BODY" \ | |
| --prerelease \ | |
| --latest=false | |
| else | |
| gh release create "$VERSION_TAG" \ | |
| --title "StackCraft ${{ steps.meta.outputs.version }}" \ | |
| --notes-file "$VERSION_BODY" \ | |
| --prerelease \ | |
| --latest=false | |
| fi | |
| gh release upload "$VERSION_TAG" "$RELEASE_JAR" --clobber | |
| - name: Upload Workflow Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: StackCraft-${{ steps.meta.outputs.version }}-${{ steps.meta.outputs.short_sha }} | |
| path: dist/*.jar | |
| retention-days: 14 |