fix: use ubuntu-latest docker runner for JDK 25
This commit is contained in:
@@ -6,7 +6,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: self-hosted
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
@@ -30,63 +30,42 @@ jobs:
|
|||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
VERSION=$(grep "^version:" src/main/resources/plugin.yml | awk "{print \$2}" | tr -d "\r\n ")
|
VERSION=$(grep "^version:" src/main/resources/plugin.yml | awk '{print $2}' | tr -d "\r\n ")
|
||||||
TAG="v${VERSION}"
|
TAG="v${VERSION}"
|
||||||
BASE="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
|
BASE="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
|
||||||
echo "Version: ${VERSION}, Tag: ${TAG}"
|
echo "Version: ${VERSION}, Tag: ${TAG}"
|
||||||
echo "Token prefix: ${GITEA_TOKEN:0:8}..."
|
|
||||||
|
|
||||||
echo "=== Testing API access ==="
|
|
||||||
curl -s -w "\nHTTP_CODE:%{http_code}\n" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
"${BASE}" | tail -5
|
|
||||||
|
|
||||||
echo "=== Checking existing tag ${TAG} ==="
|
echo "=== Checking existing tag ${TAG} ==="
|
||||||
RESP=$(curl -s -w "\nHTTP_CODE:%{http_code}" \
|
RESP=$(curl -s -w "\nHTTP_CODE:%{http_code}" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
"${BASE}/releases/tags/${TAG}")
|
"${BASE}/releases/tags/${TAG}")
|
||||||
HTTP_CODE=$(echo "$RESP" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
HTTP_CODE=$(echo "$RESP" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
||||||
echo "Check tag HTTP: ${HTTP_CODE}"
|
|
||||||
|
|
||||||
if [ "$HTTP_CODE" = "200" ]; then
|
if [ "$HTTP_CODE" = "200" ]; then
|
||||||
OLD_ID=$(echo "$RESP" | head -1 | grep -o "\"id\":[0-9]*" | head -1 | cut -d: -f2)
|
OLD_ID=$(echo "$RESP" | head -1 | grep -o "\"id\":[0-9]*" | head -1 | cut -d: -f2)
|
||||||
echo "Tag ${TAG} exists (release #${OLD_ID}), deleting..."
|
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" "${BASE}/releases/${OLD_ID}"
|
||||||
curl -s -X DELETE \
|
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" "${BASE}/tags/${TAG}"
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
"${BASE}/releases/${OLD_ID}"
|
|
||||||
curl -s -X DELETE \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
"${BASE}/tags/${TAG}"
|
|
||||||
sleep 1
|
sleep 1
|
||||||
elif [ "$HTTP_CODE" = "404" ]; then
|
|
||||||
echo "Tag ${TAG} not found, will create new"
|
|
||||||
else
|
|
||||||
echo "Warning: unexpected response checking tag"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=== Creating release ${TAG} ==="
|
echo "=== Creating release ${TAG} ==="
|
||||||
RELEASE_RESP=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST \
|
RELEASE_RESP=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Sdf1_login ${TAG}\",\"body\":\"Version: ${VERSION}\\\\nCommit: \${{ gitea.sha }}\\\\nBranch: \${{ gitea.ref_name }}\",\"draft\":false,\"prerelease\":false}" \
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Sdf1_login ${TAG}\",\"body\":\"Version: ${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
"${BASE}/releases")
|
"${BASE}/releases")
|
||||||
RELEASE_HTTP=$(echo "$RELEASE_RESP" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
RELEASE_HTTP=$(echo "$RELEASE_RESP" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
||||||
echo "Create release HTTP: ${RELEASE_HTTP}"
|
echo "Create release HTTP: ${RELEASE_HTTP}"
|
||||||
|
|
||||||
if [ "$RELEASE_HTTP" != "201" ]; then
|
if [ "$RELEASE_HTTP" != "201" ]; then
|
||||||
echo "=== Release creation failed! ==="
|
echo "Release creation failed!"
|
||||||
echo "$RELEASE_RESP" | head -1
|
echo "$RELEASE_RESP" | head -1
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RELEASE_RESP" | head -1 | grep -o "\"id\":[0-9]*" | head -1 | cut -d: -f2)
|
RELEASE_ID=$(echo "$RELEASE_RESP" | head -1 | grep -o "\"id\":[0-9]*" | head -1 | cut -d: -f2)
|
||||||
if [ -n "$RELEASE_ID" ]; then
|
curl -s -X POST \
|
||||||
echo "=== Uploading JAR to release #${RELEASE_ID} ==="
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
curl -s -X POST \
|
-F "attachment=@target/Sdf1_login.jar" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
"${BASE}/releases/${RELEASE_ID}/assets"
|
||||||
-F "attachment=@target/Sdf1_login.jar" \
|
echo "Release ${TAG} created with JAR"
|
||||||
"${BASE}/releases/${RELEASE_ID}/assets"
|
|
||||||
echo "Release ${TAG} created with JAR"
|
|
||||||
else
|
|
||||||
echo "Release created but could not get release ID for JAR upload"
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
name: Auto Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: self-hosted
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Extract version from plugin.yml
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
echo "version=\$(grep "^version: " src/main/resources/plugin.yml | sed "s/version: //")" >> \$GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Setup JDK 25
|
|
||||||
run: |
|
|
||||||
export JAVA_HOME=/root/.sdkman/candidates/java/25.0.3-tem
|
|
||||||
echo "JAVA_HOME=\$JAVA_HOME" >> \$GITHUB_ENV
|
|
||||||
echo "\$JAVA_HOME/bin" >> \$GITHUB_PATH
|
|
||||||
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn -B clean package -DskipTests
|
|
||||||
|
|
||||||
- name: Verify JAR exists
|
|
||||||
run: ls -la target/Sdf1_login.jar
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
tag_name: v\${{ steps.version.outputs.version }}
|
|
||||||
name: v\${{ steps.version.outputs.version }}
|
|
||||||
files: target/Sdf1_login.jar
|
|
||||||
generate_release_notes: true
|
|
||||||
Reference in New Issue
Block a user