4 Commits

Author SHA1 Message Date
CodingPhoenixx 2bcf9117c7 Remove unused comments in ci.yml to improve readability and maintain consistency across workflow steps.
CI - Test, Publish and Release / run-tests (push) Successful in 18s
CI - Test, Publish and Release / create-release (push) Successful in 19s
CI - Test, Publish and Release / check-and-publish (push) Successful in 13s
2026-05-29 09:23:00 +02:00
CodingPhoenixx 3515c67a20 Restore check-and-publish job in ci.yml to reintroduce Maven repository publishing after release creation. 2026-05-29 09:22:35 +02:00
CodingPhoenixx f4feb77b14 Bump project version to 0.0.4 in build.gradle and updated CI-Pipeline
CI - Test, Publish and Release / run-tests (push) Successful in 18s
CI - Test, Publish and Release / create-release (push) Successful in 19s
CI - Test, Publish and Release / check-and-publish (push) Successful in 17s
2026-05-29 09:20:25 +02:00
CodingPhoenixx e2449be3c8 Add test.yml for pull request testing and enhance ci.yml with JAR build and upload steps
CI - Test, Publish and Release / run-tests (push) Successful in 18s
CI - Test, Publish and Release / create-release (push) Successful in 19s
CI - Test, Publish and Release / check-and-publish (push) Successful in 14s
2026-05-29 09:19:27 +02:00
3 changed files with 178 additions and 89 deletions
+136 -88
View File
@@ -4,12 +4,10 @@ on:
push: push:
branches: branches:
- master - master
pull_request:
jobs: jobs:
run-tests: run-tests:
runs-on: java26 runs-on: java26
steps: steps:
- name: Checkout Code - name: Checkout Code
run: | run: |
@@ -43,11 +41,145 @@ jobs:
ls -la build/test-results/test || true ls -la build/test-results/test || true
fi fi
create-release:
runs-on: java26
needs: run-tests
env:
API_BASE: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
steps:
- name: Checkout Code
run: |
SERVER_DOMAIN=$(echo "${{ github.server_url }}" | sed 's/https:\/\///')
rm -rf "$GITHUB_WORKSPACE"/*
git clone "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@${SERVER_DOMAIN}/${{ github.repository }}.git" "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE"
git checkout ${{ github.sha }}
- name: Read version from Gradle
id: get_version
run: |
cd "$GITHUB_WORKSPACE"
chmod +x ./gradlew
VERSION=$(./gradlew properties | grep "^version:" | awk '{print $2}')
echo "Found local project version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Build JAR
run: |
cd "$GITHUB_WORKSPACE"
# Tests already ran in the run-tests job, so skip them here.
./gradlew jar --no-daemon --stacktrace -x test
- name: Locate built JAR
id: find_jar
run: |
cd "$GITHUB_WORKSPACE"
JAR_PATH=$(ls build/libs/*.jar | grep -v -e '-sources.jar' -e '-javadoc.jar' | head -n1)
if [ -z "$JAR_PATH" ]; then
echo "No JAR found in build/libs"
exit 1
fi
echo "Found JAR: $JAR_PATH"
echo "jar_path=$JAR_PATH" >> $GITHUB_OUTPUT
echo "jar_name=$(basename "$JAR_PATH")" >> $GITHUB_OUTPUT
- name: Check if tag/release already exists
id: check_tag
run: |
TAG="${{ steps.get_version.outputs.tag }}"
CHECK_URL="${{ env.API_BASE }}/releases/tags/${TAG}"
echo "Checking for existing release: $CHECK_URL"
STATUS=$(curl -o /dev/null -s -w "%{http_code}" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"$CHECK_URL")
if [ "$STATUS" = "200" ]; then
echo "Release for tag $TAG already exists. Skipping."
echo "is_new=false" >> $GITHUB_OUTPUT
else
echo "No release found for tag $TAG (Status $STATUS). Creating release..."
echo "is_new=true" >> $GITHUB_OUTPUT
fi
- name: Create tag and release on Gitea
id: create_release
if: steps.check_tag.outputs.is_new == 'true'
run: |
TAG="${{ steps.get_version.outputs.tag }}"
VERSION="${{ steps.get_version.outputs.version }}"
CREATE_URL="${{ env.API_BASE }}/releases"
echo "Creating release $TAG at $CREATE_URL"
# Gitea creates the tag automatically from target_commitish when it
# does not yet exist, so a separate tag-creation call is not needed.
BODY=$(cat <<EOF
{
"tag_name": "${TAG}",
"target_commitish": "${{ github.sha }}",
"name": "Release ${VERSION}",
"body": "Automated release for version ${VERSION}.",
"draft": false,
"prerelease": false
}
EOF
)
HTTP_STATUS=$(curl -s -o /tmp/release_response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$BODY" \
"$CREATE_URL")
echo "Response ($HTTP_STATUS):"
cat /tmp/release_response.json
if [ "$HTTP_STATUS" != "201" ]; then
echo "Failed to create release (HTTP $HTTP_STATUS)"
exit 1
fi
RELEASE_ID=$(grep -o '"id":[0-9]*' /tmp/release_response.json | head -n1 | cut -d':' -f2)
if [ -z "$RELEASE_ID" ]; then
echo "Could not determine release id from response"
exit 1
fi
echo "Release $TAG created successfully (id $RELEASE_ID)."
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
- name: Attach JAR to release
if: steps.check_tag.outputs.is_new == 'true'
run: |
cd "$GITHUB_WORKSPACE"
JAR_PATH="${{ steps.find_jar.outputs.jar_path }}"
JAR_NAME="${{ steps.find_jar.outputs.jar_name }}"
RELEASE_ID="${{ steps.create_release.outputs.release_id }}"
UPLOAD_URL="${{ env.API_BASE }}/releases/${RELEASE_ID}/assets?name=${JAR_NAME}"
echo "Uploading $JAR_NAME to $UPLOAD_URL"
HTTP_STATUS=$(curl -s -o /tmp/asset_response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@${JAR_PATH}" \
"$UPLOAD_URL")
echo "Response ($HTTP_STATUS):"
cat /tmp/asset_response.json
if [ "$HTTP_STATUS" != "201" ]; then
echo "Failed to upload JAR asset (HTTP $HTTP_STATUS)"
exit 1
fi
echo "JAR $JAR_NAME attached to release successfully."
check-and-publish: check-and-publish:
runs-on: java26 runs-on: java26
# Publish to the Maven repo after the Gitea release has been created
needs: create-release needs: create-release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env: env:
MAVEN_REPO_URL: ${{ secrets.MAVEN_REPO_URL }} MAVEN_REPO_URL: ${{ secrets.MAVEN_REPO_URL }}
MAVEN_REPO_USER: ${{ secrets.MAVEN_REPO_USER }} MAVEN_REPO_USER: ${{ secrets.MAVEN_REPO_USER }}
@@ -102,87 +234,3 @@ jobs:
echo "Publishing version ${{ steps.get_version.outputs.version }} zu Repository..." echo "Publishing version ${{ steps.get_version.outputs.version }} zu Repository..."
./gradlew publish ./gradlew publish
create-release:
runs-on: java26
# Create the Gitea tag/release after tests pass, before publishing
needs: run-tests
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
API_BASE: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
steps:
- name: Checkout Code
run: |
SERVER_DOMAIN=$(echo "${{ github.server_url }}" | sed 's/https:\/\///')
rm -rf "$GITHUB_WORKSPACE"/*
git clone "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@${SERVER_DOMAIN}/${{ github.repository }}.git" "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE"
git checkout ${{ github.sha }}
- name: Read version from Gradle
id: get_version
run: |
cd "$GITHUB_WORKSPACE"
chmod +x ./gradlew
VERSION=$(./gradlew properties | grep "^version:" | awk '{print $2}')
echo "Found local project version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Check if tag/release already exists
id: check_tag
run: |
TAG="${{ steps.get_version.outputs.tag }}"
CHECK_URL="${{ env.API_BASE }}/releases/tags/${TAG}"
echo "Checking for existing release: $CHECK_URL"
STATUS=$(curl -o /dev/null -s -w "%{http_code}" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"$CHECK_URL")
if [ "$STATUS" = "200" ]; then
echo "Release for tag $TAG already exists. Skipping."
echo "is_new=false" >> $GITHUB_OUTPUT
else
echo "No release found for tag $TAG (Status $STATUS). Creating release..."
echo "is_new=true" >> $GITHUB_OUTPUT
fi
- name: Create tag and release on Gitea
if: steps.check_tag.outputs.is_new == 'true'
run: |
TAG="${{ steps.get_version.outputs.tag }}"
VERSION="${{ steps.get_version.outputs.version }}"
CREATE_URL="${{ env.API_BASE }}/releases"
echo "Creating release $TAG at $CREATE_URL"
# Gitea creates the tag automatically from target_commitish when it
# does not yet exist, so a separate tag-creation call is not needed.
BODY=$(cat <<EOF
{
"tag_name": "${TAG}",
"target_commitish": "${{ github.sha }}",
"name": "Release ${VERSION}",
"body": "Automated release for version ${VERSION}.",
"draft": false,
"prerelease": false
}
EOF
)
HTTP_STATUS=$(curl -s -o /tmp/release_response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$BODY" \
"$CREATE_URL")
echo "Response ($HTTP_STATUS):"
cat /tmp/release_response.json
if [ "$HTTP_STATUS" != "201" ]; then
echo "Failed to create release (HTTP $HTTP_STATUS)"
exit 1
fi
echo "Release $TAG created successfully."
+41
View File
@@ -0,0 +1,41 @@
name: Run Tests on Pull Request
on:
pull_request:
jobs:
run-tests:
runs-on: java26
steps:
- name: Checkout Code
run: |
SERVER_DOMAIN=$(echo "${{ github.server_url }}" | sed 's/https:\/\///')
rm -rf "$GITHUB_WORKSPACE"/*
git clone "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@${SERVER_DOMAIN}/${{ github.repository }}.git" "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE"
git checkout ${{ github.sha }}
- name: Make gradlew executable
run: |
cd "$GITHUB_WORKSPACE"
chmod +x ./gradlew
- name: Run JUnit tests
id: run_tests
run: |
cd "$GITHUB_WORKSPACE"
./gradlew test --no-daemon --stacktrace
- name: Upload test reports
if: always()
run: |
cd "$GITHUB_WORKSPACE"
if [ -d "build/reports/tests/test" ]; then
echo "Test reports available in build/reports/tests/test"
ls -la build/reports/tests/test || true
fi
if [ -d "build/test-results/test" ]; then
echo "Test result XMLs:"
ls -la build/test-results/test || true
fi
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
} }
group = 'dev.coph' group = 'dev.coph'
version = '0.0.3' version = '0.0.4'
repositories { repositories {
mavenCentral() mavenCentral()