Merge pull request #1 from astroidmc/copilot/fix-github-actions-auto-… #12
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: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| permissions: | |
| contents: write | |
| packages: write | |
| issues: read | |
| pull-requests: read | |
| actions: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn clean package -DskipTests | |
| - name: Run tests | |
| run: mvn test | |
| continue-on-error: true | |
| - name: Upload Paper JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: NetworkDataAPI-Paper | |
| path: networkdataapi-paper/target/NetworkDataAPI-Paper-*.jar | |
| - name: Upload Bungee JAR | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: NetworkDataAPI-Bungee | |
| path: networkdataapi-bungee/target/NetworkDataAPI-Bungee-*.jar | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn clean package -DskipTests | |
| - name: Get version from tag | |
| id: get_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: Release ${{ steps.get_version.outputs.VERSION }} | |
| body: | | |
| ## NetworkDataAPI ${{ steps.get_version.outputs.VERSION }} | |
| ### 📦 Downloads | |
| - **Paper/Spigot**: NetworkDataAPI-Paper-${{ steps.get_version.outputs.VERSION }}.jar | |
| - **BungeeCord**: NetworkDataAPI-Bungee-${{ steps.get_version.outputs.VERSION }}.jar | |
| ### 🚀 Installation | |
| 1. Download the appropriate JAR for your server type | |
| 2. Place in `plugins/` folder | |
| 3. Configure MongoDB in `plugins/NetworkDataAPI/config.yml` | |
| 4. Restart server | |
| ### 📚 Documentation | |
| - [API Documentation](https://github.com/${{ github.repository }}/blob/main/API_DOCUMENTATION.md) | |
| - [Quick Start Guide](https://github.com/${{ github.repository }}/blob/main/QUICK_START.md) | |
| ### ✨ Features | |
| - ✅ Shared MongoDB connection pool | |
| - ✅ High-performance caching (80-95% hit rate) | |
| - ✅ Thread-safe async operations | |
| - ✅ REST API support | |
| - ✅ Works on Paper/Spigot and BungeeCord | |
| draft: false | |
| prerelease: false | |
| - name: Upload Paper Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./networkdataapi-paper/target/NetworkDataAPI-Paper-1.0-SNAPSHOT.jar | |
| asset_name: NetworkDataAPI-Paper-${{ steps.get_version.outputs.VERSION }}.jar | |
| asset_content_type: application/java-archive | |
| - name: Upload Bungee Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./networkdataapi-bungee/target/NetworkDataAPI-Bungee-1.0-SNAPSHOT.jar | |
| asset_name: NetworkDataAPI-Bungee-${{ steps.get_version.outputs.VERSION }}.jar | |
| asset_content_type: application/java-archive | |
| auto-release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn clean package -DskipTests | |
| - name: Get current date | |
| id: date | |
| run: echo "DATE=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT | |
| - name: Get commit count | |
| id: commit_count | |
| run: echo "COUNT=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT | |
| - name: Delete existing latest release | |
| continue-on-error: true | |
| run: | | |
| gh release delete latest --yes --cleanup-tag | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create latest release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: latest | |
| release_name: "Development Build (${{ steps.date.outputs.DATE }}-${{ steps.commit_count.outputs.COUNT }})" | |
| draft: false | |
| prerelease: true | |
| - name: Find Paper JAR | |
| id: find_paper | |
| run: | | |
| PAPER_JAR=$(find networkdataapi-paper/target -name 'NetworkDataAPI-Paper-*.jar' -type f | head -n 1) | |
| if [ -n "$PAPER_JAR" ]; then | |
| echo "PAPER_JAR_PATH=$PAPER_JAR" >> $GITHUB_OUTPUT | |
| echo "PAPER_JAR_FOUND=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "PAPER_JAR_FOUND=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Find Bungee JAR | |
| id: find_bungee | |
| run: | | |
| BUNGEE_JAR=$(find networkdataapi-bungee/target -name 'NetworkDataAPI-Bungee-*.jar' -type f | head -n 1) | |
| if [ -n "$BUNGEE_JAR" ]; then | |
| echo "BUNGEE_JAR_PATH=$BUNGEE_JAR" >> $GITHUB_OUTPUT | |
| echo "BUNGEE_JAR_FOUND=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "BUNGEE_JAR_FOUND=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload Paper Release Asset | |
| if: steps.find_paper.outputs.PAPER_JAR_FOUND == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_paper.outputs.PAPER_JAR_PATH }} | |
| asset_name: NetworkDataAPI-Paper-${{ steps.date.outputs.DATE }}-${{ steps.commit_count.outputs.COUNT }}.jar | |
| asset_content_type: application/java-archive | |
| - name: Upload Bungee Release Asset | |
| if: steps.find_bungee.outputs.BUNGEE_JAR_FOUND == 'true' | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ${{ steps.find_bungee.outputs.BUNGEE_JAR_PATH }} | |
| asset_name: NetworkDataAPI-Bungee-${{ steps.date.outputs.DATE }}-${{ steps.commit_count.outputs.COUNT }}.jar | |
| asset_content_type: application/java-archive | |