chore: add Ramscoop.jar (prebuilt mod JAR) #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Java | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Download Starsector core jars (optional) | |
| env: | |
| STARSECTOR_CORE_URL_SECRET: ${{ secrets.STARSECTOR_CORE_URL }} | |
| run: | | |
| # Prefer environment variable, then secrets | |
| if [ -n "$STARSECTOR_CORE_URL" ]; then | |
| URL="$STARSECTOR_CORE_URL" | |
| elif [ -n "$STARSECTOR_CORE_URL_SECRET" ]; then | |
| URL="$STARSECTOR_CORE_URL_SECRET" | |
| else | |
| echo "No STARSECTOR_CORE_URL provided (set env.STARSECTOR_CORE_URL or secrets.STARSECTOR_CORE_URL). Skipping Starsector core download. If your build requires Starsector API jars, provide a download URL via repository secrets." | |
| exit 0 | |
| fi | |
| echo "Downloading Starsector core from $URL" | |
| curl -L -o starsector-core.zip "$URL" | |
| unzip starsector-core.zip -d starsector_core | |
| # Set STARSECTOR_DIR so build.ps1 picks up the extracted core | |
| echo "STARSECTOR_DIR=$PWD/starsector_core" >> $GITHUB_ENV | |
| - name: Validate Java files | |
| run: | | |
| # Check that Java source files exist and have content | |
| if [ ! -d "src/ramscoop" ]; then | |
| echo "Error: Source directory missing" | |
| exit 1 | |
| fi | |
| if [ ! -f "src/ramscoop/ModPlugin.java" ] || [ ! -f "src/ramscoop/Ramscoop.java" ]; then | |
| echo "Error: Core Java source files missing" | |
| exit 1 | |
| fi | |
| - name: Validate mod structure | |
| run: | | |
| # Check that essential mod files exist | |
| for file in "mod_info.json" "settings.json" "README.md" "LICENSE.txt" "Ramscoop.version"; do | |
| if [ ! -f "$file" ]; then | |
| echo "Error: $file is missing" | |
| exit 1 | |
| fi | |
| done | |
| # Check that LunaSettings.csv exists | |
| if [ ! -f "data/config/LunaSettings.csv" ]; then | |
| echo "Error: data/config/LunaSettings.csv is missing" | |
| exit 1 | |
| fi | |
| # Build JAR in CI using project build script (PowerShell) | |
| echo "Building Ramscoop JAR using build.ps1..." | |
| pwsh -NoProfile -NonInteractive -Command "Set-Location \"${{ github.workspace }}\"; ./build.ps1" | |
| # Check that JAR exists (we expect a committed JAR in the repo) | |
| if [ ! -f "jars/Ramscoop.jar" ]; then | |
| echo "Error: jars/Ramscoop.jar is missing. Please commit the prebuilt Ramscoop.jar to the repository."; | |
| exit 1 | |
| fi | |
| # Check that JAR exists now | |
| if [ ! -f "jars/Ramscoop.jar" ]; then | |
| echo "Error: Ramscoop.jar is missing after attempting to build" | |
| exit 1 | |
| fi | |
| - name: Generate and validate changelog.txt | |
| run: | | |
| # Test the changelog generation process | |
| sed 's/^## Version /Version /g' CHANGELOG.md | \ | |
| sed 's/^# .*//g' | \ | |
| sed 's/^- /- /g' | \ | |
| sed '/^$/N;/^\n$/d' > test-changelog.txt | |
| echo "Generated test changelog.txt:" | |
| cat test-changelog.txt | |
| # Verify it has content | |
| if [ ! -s "test-changelog.txt" ]; then | |
| echo "Error: Generated changelog is empty" | |
| exit 1 | |
| fi | |
| - name: Package validation | |
| run: | | |
| # Create a mock release package to ensure the packaging process works | |
| mkdir -p release | |
| mkdir -p release/jars | |
| touch release/jars/Ramscoop.jar | |
| # Generate changelog.txt for testing | |
| sed 's/^## Version /Version /g' CHANGELOG.md | \ | |
| sed 's/^# .*//g' | \ | |
| sed 's/^- /- /g' | \ | |
| sed '/^$/N;/^\n$/d' > changelog.txt | |
| for file in "mod_info.json" "settings.json" "README.md" "LICENSE.txt" "changelog.txt"; do | |
| cp "$file" release/ | |
| done | |
| cd release | |
| zip -r "../Ramscoop-test.zip" ./* | |
| cd .. | |
| # Verify the zip was created and has content | |
| if [ ! -f "Ramscoop-test.zip" ]; then | |
| echo "Error: Failed to create test package" | |
| exit 1 | |
| fi | |
| echo "Package validation successful" |