VoidLoader/VoidLoaderCore/pipeline/head This commit looks good
Signed-off-by: Faumaray <faumaray@gmail.com>
129 lines
5.1 KiB
Groovy
129 lines
5.1 KiB
Groovy
pipeline {
|
|
agent {
|
|
docker { image 'faumaray/jdk-mingw-cpp:latest' }
|
|
}
|
|
|
|
parameters {
|
|
string(name: 'TAG_NAME', defaultValue: 'latest', description: 'Tag name for Gitea release')
|
|
string(name: 'RELEASE_NAME', defaultValue: 'latest', description: 'Release name for Gitea release')
|
|
}
|
|
|
|
stages {
|
|
stage('Build-Linux') {
|
|
tools { jdk 'JDK21' }
|
|
steps {
|
|
sh '''
|
|
java -version
|
|
echo $JAVA_HOME
|
|
rm -rf build/linux
|
|
mkdir -p build/linux
|
|
cmake -B build/linux -DCMAKE_BUILD_TYPE=Release
|
|
cmake --build build/linux
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Build-Windows') {
|
|
tools { jdk 'JDK21DOCKERWIN' }
|
|
steps {
|
|
sh '''
|
|
export PATH="$JAVA_HOME/bin:$PATH"
|
|
java -version
|
|
echo $JAVA_HOME
|
|
rm -rf build/windows
|
|
mkdir -p build/windows
|
|
cmake -B build/windows -DCMAKE_TOOLCHAIN_FILE=mingw.cmake -DCMAKE_BUILD_TYPE=Release
|
|
cmake --build build/windows
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Package-Artifacts') {
|
|
steps {
|
|
sh '''
|
|
rm -rf dist
|
|
rm -rf VoidLoader.zip
|
|
mkdir -p dist/native/windows dist/native/linux
|
|
|
|
# collect libs
|
|
find build/linux -type f -name "*.vlmod" -exec cp {} dist/native/linux/ \\;
|
|
find build/windows -type f -name "*.vlmod" -exec cp {} dist/native/windows/ \\;
|
|
|
|
cd dist
|
|
zip -r ../VoidLoader.zip native
|
|
'''
|
|
}
|
|
post {
|
|
success {
|
|
archiveArtifacts artifacts: 'VoidLoader.zip', fingerprint: true
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Publish-To-Gitea') {
|
|
steps {
|
|
withCredentials([string(credentialsId: 'GITEA_TOKEN', variable: 'GITEA_TOKEN')]) {
|
|
sh '''
|
|
set -e
|
|
GITEA_URL="https://git.faumaray.ru"
|
|
REPO="VoidLoader/VoidLoaderCore"
|
|
TAG="${TAG_NAME:-latest}"
|
|
RELEASE="${RELEASE_NAME:-latest}"
|
|
|
|
echo "📦 Checking release: $RELEASE ($TAG)"
|
|
|
|
# Query existing release (if any)
|
|
EXISTING_RELEASE=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/tags/$TAG" || true)
|
|
|
|
RELEASE_ID=$(echo "$EXISTING_RELEASE" | jq -r '.id // empty')
|
|
PRERELEASE=$(echo "$EXISTING_RELEASE" | jq -r '.prerelease // false')
|
|
|
|
if [ -n "$RELEASE_ID" ] && [ "$PRERELEASE" = "true" ]; then
|
|
echo "⚠️ Existing prerelease found (ID $RELEASE_ID), removing..."
|
|
|
|
# Delete release
|
|
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID" >/dev/null || true
|
|
|
|
# Delete tag (safe to ignore if not present)
|
|
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/tags/$TAG" >/dev/null || true
|
|
|
|
echo "🧹 Old prerelease removed."
|
|
fi
|
|
|
|
echo "🚀 Creating new release..."
|
|
|
|
CREATE_RESPONSE=$(curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\\"tag_name\\": \\"$TAG\\",
|
|
\\"name\\": \\"$RELEASE\\",
|
|
\\"prerelease\\": true
|
|
}" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases")
|
|
|
|
RELEASE_ID=$(echo "$CREATE_RESPONSE" | jq -r '.id')
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
|
echo "❌ Failed to create release!"
|
|
echo "$CREATE_RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ New release created (ID $RELEASE_ID)"
|
|
|
|
# Upload artifact
|
|
echo "⬆️ Uploading VoidLoader.zip ..."
|
|
curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@VoidLoader.zip" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" >/dev/null
|
|
|
|
echo "🎉 Upload complete: $GITEA_URL/$REPO/releases/tag/$TAG"
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|