Files
VoidLoaderCore/Jenkinsfile
T
faumaray 8c4bcf125b
VoidLoader/VoidLoaderCore/pipeline/head This commit looks good
parametrize release
Signed-off-by: Faumaray <faumaray@gmail.com>
2025-10-19 04:29:50 +03:00

106 lines
4.2 KiB
Groovy

pipeline {
agent any
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 'JDK21-WIN' }
steps {
sh '''
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
mkdir -p dist/native/windows dist/native/linux
# collect libs
find build/linux -type f -name "*.so*" -exec cp {} dist/native/linux/ \\;
find build/windows -type f -name "*.dll" -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 "📦 Preparing release: $RELEASE ($TAG)"
# Ensure release exists
curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\\"tag_name\\": \\"$TAG\\", \\"name\\": \\"$RELEASE\\"}" \
"$GITEA_URL/api/v1/repos/$REPO/releases" >/dev/null || true
# Get release ID
RELEASE_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$REPO/releases/tags/$TAG" | jq -r '.id')
echo "✅ Release ID = $RELEASE_ID"
# Delete any existing asset with same name
ASSET_ID=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" | \
jq -r '.[] | select(.name=="VoidLoader.zip") | .id')
if [ -n "$ASSET_ID" ] && [ "$ASSET_ID" != "null" ]; then
echo "🗑 Removing old asset (ID $ASSET_ID)"
curl -s -X DELETE -H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/v1/repos/$REPO/releases/assets/$ASSET_ID" >/dev/null || true
fi
# Upload new artifact
echo "⬆️ Uploading new 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/VoidLoader/VoidLoaderCore/releases/tag/$TAG"
'''
}
}
}
}
}