Skip to content

[WIP] Fix workflow permissions for automatic release job #10

[WIP] Fix workflow permissions for automatic release job

[WIP] Fix workflow permissions for automatic release job #10

name: Build and Release
on:
push:
branches:
- main
- master
tags:
- 'v*'
pull_request:
branches:
- main
- master
permissions:
contents: write
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: Create automatic release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: "latest"
prerelease: true
title: "Development Build (${{ steps.date.outputs.DATE }}-${{ steps.commit_count.outputs.COUNT }})"
files: |
networkdataapi-paper/target/NetworkDataAPI-Paper-*.jar
networkdataapi-bungee/target/NetworkDataAPI-Bungee-*.jar