Files
PlayHours/.gitea/workflows/release.yml
Mr¤KayJayDee a4fc6a158e
Some checks failed
CI / test (push) Has been cancelled
feat(build): add release automation tasks and CI/CD workflows
- Introduced Gradle tasks for release preparation, version bumping, and git tagging.
- Added CI workflow for continuous integration on pushes and pull requests.
- Implemented release workflow for automated builds and Gitea releases upon tag pushes.
- Created scripts for manual release processes on Windows and Linux/macOS.
- Documented the release process and Gitea Actions setup in the new RELEASE.md and setup-gitea-actions.md files.
2025-10-23 23:42:16 +02:00

90 lines
2.8 KiB
YAML

name: Release Build
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.1)'
required: true
type: string
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper tagging
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Create Gitea Release
run: |
# Get the tag name from the trigger
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Creating release for tag: $TAG_NAME"
# Create release using Gitea API
curl -X POST \
-H "Authorization: token ${{ secrets.TOKEN }}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"$TAG_NAME\",
\"name\": \"PlayHours $TAG_NAME\",
\"body\": \"## PlayHours $TAG_NAME\\n\\n### Installation\\n1. Download the JAR file below\\n2. Place it in your server's \`mods\` folder\\n3. Restart your server\\n\\n### Requirements\\n- Minecraft ${{ env.MINECRAFT_VERSION || '1.20.1' }}\\n- Forge ${{ env.FORGE_VERSION || '47.4.10' }}\\n- Java 17+\",
\"draft\": false,
\"prerelease\": false
}" \
"${{ env.API_URL || 'https://gitea.kamisama.ovh:2222' }}/api/v1/repos/${{ github.repository }}/releases"
env:
GITEA_TOKEN: ${{ secrets.TOKEN }}
GITEA_API_URL: ${{ secrets.API_URL }}
- name: Upload JAR to Release
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
JAR_FILE=$(find build/libs -name "*.jar" | head -1)
if [ -z "$JAR_FILE" ]; then
echo "No JAR file found in build/libs/"
exit 1
fi
echo "Uploading $JAR_FILE to release $TAG_NAME"
# Upload JAR file to the release
curl -X POST \
-H "Authorization: token ${{ secrets.TOKEN }}" \
-F "attachment=@$JAR_FILE" \
"${{ env.API_URL || 'https://gitea.kamisama.ovh:2222' }}/api/v1/repos/${{ github.repository }}/releases/$TAG_NAME/assets?name=$(basename $JAR_FILE)"
env:
GITEA_TOKEN: ${{ secrets.TOKEN }}
GITEA_API_URL: ${{ secrets.API_URL }}