Skip to content

Commit

Permalink
ci: publish to modrinth
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Dec 24, 2024
1 parent 6666c50 commit b2ad4e4
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fire==0.4.0
curseuploadpy @ git+https://github.com/MrTJP/curseuploadpy.git@dev
modrinthpy @ git+https://github.com/MrTJP/modrinthpy.git@dev
67 changes: 56 additions & 11 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ jobs:
case $release_type in
"release")
publish_maven=true
publish_curse=true
publish_launchers=true
publish_gh_release=true
version_format="{major}.{minor}.{patch}"
;;
"beta")
publish_maven=true
publish_curse=true
publish_launchers=true
publish_gh_release=false
version_format="{major}.{minor}.{patch}-beta+{increment}"
;;
"alpha")
publish_maven=true
publish_curse=false
publish_launchers=false
publish_gh_release=false
version_format="{major}.{minor}.{patch}-alpha+{increment}"
;;
*)
echo "::warning::Unknown release type: $release_type"
publish_maven=false
publish_curse=false
publish_launchers=false
publish_gh_release=false
version_format="{major}.{minor}.{patch}-$release_type+{increment}"
esac
Expand All @@ -61,7 +61,7 @@ jobs:
echo "release_channel=$release_channel" >> $GITHUB_OUTPUT
echo "release_type=$release_type" >> $GITHUB_OUTPUT
echo "publish_maven=$publish_maven" >> $GITHUB_OUTPUT
echo "publish_curse=$publish_curse" >> $GITHUB_OUTPUT
echo "publish_launchers=$publish_launchers" >> $GITHUB_OUTPUT
echo "publish_gh_release=$publish_gh_release" >> $GITHUB_OUTPUT
echo "version_format=$version_format" >> $GITHUB_OUTPUT
echo "tag_format=$tag_format" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -127,16 +127,17 @@ jobs:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}

- name: Curse publish
if: ${{ steps.release_type.outputs.publish_curse == 'true' }}
- name: Publish to Curse
if: ${{ steps.release_type.outputs.publish_launchers == 'true' }}
run: |
# Base args for all modules
COMMON_ARGS=( \
-k $CURSE_TOKEN \
-rt $CURSE_RELEASE_TYPE \
-k $API_TOKEN \
-rt $RELEASE_TYPE \
-v 'Java 17' \
-v 1.20.1 \
-v Forge \
-v NeoForge \
-c ./CHANGELOG.md \
--required-dep codechicken-lib-1-8 \
--required-dep cb-multipart \
Expand Down Expand Up @@ -164,8 +165,52 @@ jobs:
python -m curseuploadpy "${MODULE_ARGS[@]}" -p 478939 -f transmission/build/libs/*-transmission.jar
env:
CURSE_RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
CURSE_TOKEN: ${{ secrets.CURSE_TOKEN }}
RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
API_TOKEN: ${{ secrets.CURSE_TOKEN }}


- name: Publish to Modrinth
if: ${{ steps.release_type.outputs.publish_launchers == 'true' }}
run: |
# Base args for all modules
COMMON_ARGS=( \
-k $API_TOKEN \
create-version \
-v "$AUTO_GENERATED_VERSION" \
-c ./CHANGELOG.md \
-gv 1.20.1 \
-vt $RELEASE_TYPE \
-l Forge \
-l NeoForge \
--required-dep codechicken-lib-1-8 \
--required-dep cb-multipart \
)
# All submodules need PR Core
MODULE_ARGS=( \
"${COMMON_ARGS[@]}" \
--required-dep project-red-core \
)
# Fabrication is special and also needs Integration and Transmission
FAB_ARGS=( \
"${MODULE_ARGS[@]}" \
--required-dep project-red-integration \
--required-dep project-red-transmission \
)
python -m modrinthpy "${COMMON_ARGS[@]}" -p 228702 -f core/build/libs/*-core.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p 229048 -f expansion/build/libs/*-expansion.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p 229049 -f exploration/build/libs/*-exploration.jar
python -m modrinthpy "${FAB_ARGS[@]}" -p 230111 -f fabrication/build/libs/*-fabrication.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p 229046 -f illumination/build/libs/*-illumination.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p 229045 -f integration/build/libs/*-integration.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p 478939 -f transmission/build/libs/*-transmission.jar
env:
RELEASE_TYPE: ${{ steps.release_type.outputs.release_type }}
API_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
AUTO_GENERATED_VERSION: ${{ steps.versioning.outputs.version }}

- name: Tag and Release
if: ${{ steps.release_type.outputs.publish_gh_release == 'true' }}
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/verify-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
build_test:
name: Build and Test
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout git repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -91,3 +92,50 @@ jobs:
with:
name: project-red-${{ steps.versioning.outputs.version }}
path: '*/build/libs/ProjectRed-*.jar'

- name: TEST Publish to Modrinth
# if: ${{ steps.release_type.outputs.publish_launchers == 'true' }}
continue-on-error: true
run: |
# Base args for all modules
COMMON_ARGS=( \
-k $API_TOKEN \
create-version \
-v "$AUTO_GENERATED_VERSION" \
-c ./CHANGELOG.md \
-gv 1.20.1 \
-vt $RELEASE_TYPE \
-l forge \
-l neoForge \
--required-dep codechicken-lib \
--required-dep cb-multipart \
)
# All submodules need PR Core
MODULE_ARGS=( \
"${COMMON_ARGS[@]}" \
--required-dep project-red-core \
)
# Fabrication is special and also needs Integration and Transmission
FAB_ARGS=( \
"${MODULE_ARGS[@]}" \
--required-dep project-red-integration \
--required-dep project-red-transmission \
)
# TEST: Make changelog
echo "## $AUTO_GENERATED_VERSION \n * change1 \n * change2 \n * change3" > ./CHANGELOG.md
python -m modrinthpy "${COMMON_ARGS[@]}" -p project-red-core -f core/build/libs/*-core.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-expansion -f expansion/build/libs/*-expansion.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-exploration -f exploration/build/libs/*-exploration.jar
python -m modrinthpy "${FAB_ARGS[@]}" -p project-red-fabrication -f fabrication/build/libs/*-fabrication.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-illumination -f illumination/build/libs/*-illumination.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-integration -f integration/build/libs/*-integration.jar
python -m modrinthpy "${MODULE_ARGS[@]}" -p project-red-transmission -f transmission/build/libs/*-transmission.jar
env:
RELEASE_TYPE: alpha
API_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
AUTO_GENERATED_VERSION: ${{ steps.versioning.outputs.version }}

0 comments on commit b2ad4e4

Please sign in to comment.