VoidLoader/VoidLoaderApi/pipeline/head This commit looks good
Signed-off-by: Faumaray <faumaray@gmail.com>
109 lines
4.3 KiB
Groovy
109 lines
4.3 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 '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 "*.vlmod" -exec cp {} dist/native/linux/ \\;
|
|
find build/windows -type f -name "*.vlmod" -exec cp {} dist/native/windows/ \\;
|
|
|
|
cd dist
|
|
zip -r ../VoidLoaderApi.zip native
|
|
'''
|
|
}
|
|
post {
|
|
success {
|
|
archiveArtifacts artifacts: 'VoidLoaderApi.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/VoidLoaderApi"
|
|
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=="VoidLoaderApi.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/$RELEASE_ID/assets/$ASSET_ID" >/dev/null || true
|
|
fi
|
|
|
|
|
|
# Upload new artifact
|
|
echo "⬆️ Uploading new VoidLoaderApi.zip ..."
|
|
curl -s -X POST -H "Authorization: token $GITEA_TOKEN" \
|
|
-F "attachment=@VoidLoaderApi.zip" \
|
|
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets" >/dev/null
|
|
|
|
echo "🎉 Upload complete: $GITEA_URL/VoidLoader/VoidLoaderApi/releases/tag/$TAG"
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|