Build Plugin and Mod #124
This file contains 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 Plugin and Mod On Linux | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
env: | |
GH_TOKEN: ${{ github.token }} | |
USERNAME: ${{ github.actor }} | |
PACKAGE_READ_ONLY_TOKEN: ${{ secrets.PACKAGE_READ_ONLY_TOKEN }} | |
jobs: | |
generate-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate Matrix | |
id: set-matrix | |
shell: pwsh | |
run: chmod 777 matrix.sh && ./matrix.sh -path "minecraft","spigot","velocity","forge","neoforge","fabric" | |
build: | |
runs-on: ubuntu-latest | |
needs: | |
- generate-matrix | |
strategy: | |
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Chose JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Read version.txt and save to variable | |
run: | | |
mod_version=$(cat version.txt) | |
echo "Version: $mod_version" | |
echo "MOD_VERSION=$mod_version" >> $GITHUB_ENV | |
- name: Init Files | |
run: chmod 777 init.sh && ./init.sh | |
- name: Build | |
run: | | |
cd ${matrix.config.mc-loader}/${matrix.config.mc-loader}-${matrix.config.mc-version} | |
chmod 777 gradlew | |
./gradlew clean build | |
cd ../.. | |
- name: Set Version Type | |
id: set-version-type | |
run: | | |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then | |
echo "VERSION_TYPE=release" >> $GITHUB_ENV | |
else | |
echo "VERSION_TYPE=beta" >> $GITHUB_ENV | |
fi | |
- name: Set Game Version | |
id: set-game-version | |
run: | | |
if [ "${{ matrix.config.mc-loader }}" == "velocity" ]; then | |
echo "game_version=1.20.1" >> $GITHUB_ENV | |
else | |
echo "game_version=${{ matrix.config.mc-version }}" >> $GITHUB_ENV | |
fi | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar | |
path: QueQiao-jar/${{ env.MOD_VERSION }}/QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar | |
- uses: Kir-Antipov/mc-publish@v3.3 | |
if: ${{ github.event_name == 'push' && matrix.config.mc-loader != 'minecraft' }} | |
with: | |
modrinth-id: rVJvtYoX | |
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
curseforge-id: 1084495 | |
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} | |
name: QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }} | |
version: ${{ env.MOD_VERSION }} | |
version-type: ${{ env.VERSION_TYPE }} | |
loaders: ${{ matrix.config.mc-loader }} | |
game-versions: ${{ env.game_version }} | |
files: QueQiao-jar/${{ env.MOD_VERSION }}/QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar | |
- name: Upload to Release | |
if: ${{ github.event_name == 'push' && matrix.config.mc-loader == 'minecraft' }} | |
run: gh release upload v${{ env.MOD_VERSION }} QueQiao-jar/${{ env.MOD_VERSION }}/QueQiao-${{ matrix.config.mc-loader }}+${{ matrix.config.mc-version }}-${{ env.MOD_VERSION }}.jar |