fix: use ubuntu-latest docker runner for JDK 25
This commit is contained in:
@@ -6,7 +6,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: self-hosted
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
@@ -30,63 +30,42 @@ jobs:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
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}"
|
||||
BASE="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
|
||||
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} ==="
|
||||
RESP=$(curl -s -w "\nHTTP_CODE:%{http_code}" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"${BASE}/releases/tags/${TAG}")
|
||||
HTTP_CODE=$(echo "$RESP" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
||||
echo "Check tag HTTP: ${HTTP_CODE}"
|
||||
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
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 \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"${BASE}/tags/${TAG}"
|
||||
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" "${BASE}/releases/${OLD_ID}"
|
||||
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" "${BASE}/tags/${TAG}"
|
||||
sleep 1
|
||||
elif [ "$HTTP_CODE" = "404" ]; then
|
||||
echo "Tag ${TAG} not found, will create new"
|
||||
else
|
||||
echo "Warning: unexpected response checking tag"
|
||||
fi
|
||||
|
||||
echo "=== Creating release ${TAG} ==="
|
||||
RELEASE_RESP=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-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")
|
||||
RELEASE_HTTP=$(echo "$RELEASE_RESP" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
||||
echo "Create release HTTP: ${RELEASE_HTTP}"
|
||||
|
||||
if [ "$RELEASE_HTTP" != "201" ]; then
|
||||
echo "=== Release creation failed! ==="
|
||||
echo "Release creation failed!"
|
||||
echo "$RELEASE_RESP" | head -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE_ID=$(echo "$RELEASE_RESP" | head -1 | grep -o "\"id\":[0-9]*" | head -1 | cut -d: -f2)
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
echo "=== Uploading JAR to release #${RELEASE_ID} ==="
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@target/Sdf1_login.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
|
||||
curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@target/Sdf1_login.jar" \
|
||||
"${BASE}/releases/${RELEASE_ID}/assets"
|
||||
echo "Release ${TAG} created with JAR"
|
||||
|
||||
@@ -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