Build Plugin and Mod #47
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: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
env: | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
generate-matrix: | |
runs-on: windows-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate Matrix | |
id: set-matrix | |
shell: pwsh | |
run: .\matrix.ps1 -path "fabric","forge","spigot","velocity" | |
build: | |
runs-on: windows-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 | |
shell: pwsh | |
run: | | |
$mod_version = Get-Content version.txt | |
Write-Host "Version: $mod_version" | |
echo "MOD_VERSION=$mod_version" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV | |
- name: Init Files | |
shell: pwsh | |
run: ./init.ps1 | |
- name: Build | |
env: | |
USERNAME: ${{ github.actor }} | |
PACKAGE_READ_ONLY_TOKEN: ${{ secrets.PACKAGE_READ_ONLY_TOKEN }} | |
run: | | |
cd ${{ matrix.config.mc-loader }}/${{ matrix.config.mc-loader }}-${{ matrix.config.mc-version }} | |
./gradlew clean build | |
cd ../.. | |
- 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 | |
- name: Set Version Type | |
id: set-version-type | |
shell: pwsh | |
run: | | |
if ($env:GITHUB_REF -eq 'refs/heads/main') { | |
echo "VERSION_TYPE=release" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV | |
} else { | |
echo "VERSION_TYPE=beta" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV | |
} | |
- name: Set Game Version | |
id: set-game-version | |
shell: pwsh | |
run: | | |
if (${{ matrix.config.mc-loader }} -eq 'velocity') { | |
echo "game_version=1.20.1" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV | |
} else { | |
echo "game_version=${{ matrix.config.mc-version }}" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_ENV | |
} | |
- name: Publish to Modrinth and CurseForge | |
uses: Kir-Antipov/mc-publish@v3.3 | |
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: Publish to CurseForge | |
# if: ${{ matrix.config.mc-loader != 'velocity' }} | |
# uses: Kir-Antipov/mc-publish@v3.3 | |
# with: | |
# 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: ${{ matrix.config.mc-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' }} | |
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 |