Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4feb77b14 | |||
| e2449be3c8 |
+54
-4
@@ -4,7 +4,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
run-tests:
|
||||
@@ -47,7 +46,6 @@ jobs:
|
||||
runs-on: java26
|
||||
# Publish to the Maven repo after the Gitea release has been created
|
||||
needs: create-release
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
env:
|
||||
MAVEN_REPO_URL: ${{ secrets.MAVEN_REPO_URL }}
|
||||
MAVEN_REPO_USER: ${{ secrets.MAVEN_REPO_USER }}
|
||||
@@ -106,7 +104,6 @@ jobs:
|
||||
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 }}
|
||||
|
||||
@@ -129,6 +126,25 @@ jobs:
|
||||
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: |
|
||||
@@ -149,6 +165,7 @@ jobs:
|
||||
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 }}"
|
||||
@@ -185,4 +202,37 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Release $TAG created successfully."
|
||||
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."
|
||||
|
||||
@@ -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
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'dev.coph'
|
||||
version = '0.0.3'
|
||||
version = '0.0.4'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
Reference in New Issue
Block a user