Files
Shiroha/scripts/SetENV.sh
T
Bacteria 3082c3f1d1 Add CI workflows, dependabot and env script
Introduce CI infrastructure: add Dependabot config to update GitHub Actions and Gradle dependencies weekly; add build-pr workflow to run PR builds, create the paperclip JAR, and upload artifacts; add full Camellia CI workflow to build, set environment, upload artifacts, optionally publish to Maven and create GitHub releases (with release notes and prerelease handling); add publish-api workflow to publish the API artifact. Also add scripts/SetENV.sh which reads gradle.properties, computes build/release flags, renames the paperclip jar and exports environment variables for the workflows. These changes set up automated builds, dependency maintenance, publishing and release automation for the project.
2026-07-09 18:22:49 +08:00

63 lines
1.7 KiB
Bash

#!/bin/sh
# Camellia CI - Environment Setup Script
# Reads gradle.properties and sets GitHub Actions environment variables
prop() {
grep "^[[:space:]]*${1}" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//'
}
project_id="camellia"
project_id_b="Camellia"
commitid=$(git log --pretty='%h' -1)
mcversion=$(prop mcVersion)
release=$(prop release)
pushRepo=$(prop pushRepo)
release_tag="$mcversion-$commitid"
run_attempt="${GITHUB_RUN_ATTEMPT:-1}"
jarName="$project_id-$mcversion-$BUILD_NUMBER-$run_attempt.jar"
jarName_dir="camellia-server/build/libs/$jarName"
flag_push_repo=false
flag_release=false
pre=false
make_latest=false
if [ "$release" = "pre" ]; then
pre=true
flag_release=true
make_latest=true
flag_push_repo=true
elif [ "$release" = "true" ]; then
flag_release=true
make_latest=true
flag_push_repo=true
fi
if [ "$pushRepo" = "true" ]; then
flag_push_repo=true
elif [ "$pushRepo" = "false" ]; then
flag_push_repo=false
fi
# Rename the paperclip jar to a standardized name
actual_jar=$(ls camellia-server/build/libs/*-paperclip-*.jar 2>/dev/null | head -n 1)
if [ -n "$actual_jar" ]; then
mv "$actual_jar" "$jarName_dir"
else
echo "Warning: No paperclip jar found to rename"
fi
echo "project_id=$project_id" >> $GITHUB_ENV
echo "project_id_b=$project_id_b" >> $GITHUB_ENV
echo "commit_id=$commitid" >> $GITHUB_ENV
echo "commit_msg=$(git log --pretty='> [%h] %s' -1)" >> $GITHUB_ENV
echo "mcversion=$mcversion" >> $GITHUB_ENV
echo "pre=$pre" >> $GITHUB_ENV
echo "tag=$release_tag" >> $GITHUB_ENV
echo "jar=$jarName" >> $GITHUB_ENV
echo "jar_dir=$jarName_dir" >> $GITHUB_ENV
echo "flag_push_repo=$flag_push_repo" >> $GITHUB_ENV
echo "flag_release=$flag_release" >> $GITHUB_ENV
echo "make_latest=$make_latest" >> $GITHUB_ENV