Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from Aninuscsalas/mc-modpack-kit
Browse files Browse the repository at this point in the history
feat(ci): move to mc-modpack-kit
  • Loading branch information
Aninuscsalas authored Sep 27, 2023
2 parents c077bae + fc89b17 commit f92ab02
Show file tree
Hide file tree
Showing 96 changed files with 1,324 additions and 11,178 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Disable Git line ending conversion, to prevent packwiz index hashes changing when committing from Windows
* -text
73 changes: 73 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: 'Build Modpack Action | Action'
description: 'Uses packwiz to build the modpack!'
inputs:
release-tag:
description: "The release tag for the modpack upload"
required: true
build-modrinth:
description: "Set to 'true' to build the Modrinth .mrpack file"
required: true
build-curse:
description: "Set to 'true' to build the CurseForge .zip file"
required: true
modpack:
description: "Path to the modpack directory"
required: false
default: '.'

runs:
using: "composite"

steps:
- name: Check Out Git Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: 'main'

- name: Install packwiz
uses: supplypike/setup-bin@v3
with:
uri: "https://nightly.link/packwiz/packwiz/workflows/go/main/Linux%2064-bit%20x86.zip"
name: "packwiz"
version: "linux"

- name: Build Modrinth Modpack
if: inputs.build-modrinth == 'true'
run: |
packwiz modrinth export
echo "::notice ::⚙ Modpack ${{ inputs.modpack }} has been exported as .mrpack"
shell: bash
working-directory: ${{ inputs.modpack }}

- name: Build CurseForge Modpack
if: inputs.build-curse == 'true'
run: |
packwiz curseforge export
echo "::notice ::⚙ Modpack ${{ inputs.modpack }} has been exported as .zip"
shell: bash
working-directory: ${{ inputs.modpack }}

- name: Upload Modrinth Modpack to GitHub Releases
if: inputs.build-modrinth == 'true'
run: |
gh release upload ${{ inputs.release-tag }} *.mrpack \
--repo ${{ github.repository_owner }}/${{ github.event.repository.name }} \
--clobber
echo "::notice ::☀ Modpack ${{ inputs.modpack }} has been uploaded to GitHub Releases as a .mrpack"
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
working-directory: ${{ inputs.modpack }}

- name: Upload CurseForge Modpack to GitHub Releases
if: inputs.build-curse == 'true'
run: |
gh release upload ${{ inputs.release-tag }} *.zip \
--repo ${{ github.repository_owner }}/${{ github.event.repository.name }} \
--clobber
echo "::notice ::☀ Modpack ${{ inputs.modpack }} has been uploaded to GitHub Releases as a .zip"
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}
working-directory: ${{ inputs.modpack }}
31 changes: 31 additions & 0 deletions .github/actions/bump-version-pack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Bump Modpack Action | Action'
description: 'Bump a modpacks version'

inputs:
release-tag:
description: 'The release tag to bump the modpack to'
required: true
modpack:
description: 'Path to the modpack directory'
required: false
default: '.'
pack-file:
description: 'Path to the pack config file'
required: false
default: 'pack.toml'

runs:
using: 'composite'

steps:
- name: Check Out Git Repository
uses: actions/checkout@v3

- name: Set the version
run: sed -i 's/version = "[^"]*"/version = "${{ inputs.release-tag }}"/' ${{ inputs.modpack }}/${{ inputs.pack-file }}
shell: bash

- name: Push the Updated Version
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(${{ inputs.modpack }}): bump version to ${{ inputs.release-tag }}"
48 changes: 48 additions & 0 deletions .github/actions/parse/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Parse Modpack | Action'
description: 'Parses a modpacks pack file'

inputs:
modpack:
description: 'Path to the modpack directory'
required: false
default: '.'
pack-file:
description: 'Path to the pack config file'
required: false
default: 'pack.toml'

outputs:
loader:
description: 'Detected mod loader'
value: ${{ steps.parse.outputs.loader }}
game-version:
description: 'Detected game version'
value: ${{ steps.parse.outputs.game-version }}

runs:
using: 'composite'

steps:
- name: Check Out Git Repository
uses: actions/checkout@v3

- name: Parse the pack.toml
id: parse
run: |
loaders=("fabric" "forge" "quilt" "neoforge")
for loader in "${loaders[@]}"; do
if [[ $(<"${{ env.pack-file }}") == *"$loader ="* ]]; then
LOADER="$loader" && break
fi
done
[[ -z "$LOADER" ]] && { echo "::error file=${{ env.pack-file }}::No match found for loaders in ${{ env.pack-file }}" && exit 1; }
GAME_VERSION=$(grep -oP 'minecraft = "\K[^"]+' "${{ env.pack-file }}")
echo "loader=$LOADER" >> $GITHUB_ENV
echo "game-version=$GAME_VERSION" >> $GITHUB_ENV
echo "::notice ::⚙ The detected loader for ${{ inputs.modpack }} is $LOADER"
echo "::notice ::⚙ The detected game version for ${{ inputs.modpack }} is $GAME_VERSION"
shell: bash
working-directory: ${{ inputs.modpack }}
124 changes: 124 additions & 0 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: 'Release Modpack From A Release | Action'
description: 'This automatically downloads the newest release and description and uploads it to vendors!'
inputs:
loader:
description: "Current Modpack Loader"
required: true
game-version:
description: "Current Modpack Game Version"
required: true
upload-modrinth:
description: "Should the Modpack Be Uploaded to Modrinth"
required: true
upload-curse:
description: "Should the Modpack Be Uploaded to CurseForge"
required: true

MODRINTH_TOKEN:
required: false
description: "Token used to uploading modpack to Modrinth"
MODRINTH_ID:
required: false
description: "ID used to uploading modpack to Modrinth"
CURSEFORGE-TOKEN:
required: false
description: "Token used to uploading modpack to Curseforge"
CURSEFORGE-ID:
required: false
description: "ID used to uploading modpack to Curseforge"

modpack:
description: "Modpack directory"
required: false
default: .


runs:
using: "composite"
steps:
- name: Check Out Git Repository
uses: actions/checkout@v3

- name: Get Latest tag
id: tag
uses: WyriHaximus/github-action-get-previous-tag@v1

- name: Download the pack files
uses: robinraju/release-downloader@v1.8
id: download-files
with:
fileName: "*"
tag: ${{ steps.tag.outputs.tag }}
tarBall: false
zipBall: false


- name: Get latest release description
uses: cardinalby/git-get-release-action@v1
id: latest-release
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ steps.tag.outputs.tag }}

- name: Set publish version-type
id: release-type
run: |
if [ "${{ steps.latest-release.outputs.prerelease }}" = "true" ]; then
echo "Setting release-type to beta"
echo "release-type=beta" >> $GITHUB_OUTPUT
else
echo "Setting release-type to release"
echo "release-type=release" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Pipe latest release description to file
run: echo "${{ steps.latest-release.outputs.body }}" > CHANGELOG.release.md
shell: bash

- name: Print status
run: |
echo "::notice ::⚙ Assets from latest release ${{ steps.latest-release.outputs.tag_name }} downloaded successfully!"
echo "::notice ::⚙ Latest release ${{ steps.latest-release.outputs.tag_name }} description piped into a file successfully!"
shell: bash

- name: Publish to Modrinth
id: modrinth
if: inputs.upload-modrinth == 'true'
uses: Kir-Antipov/mc-publish@v3.2
with:
modrinth-id: ${{ inputs.MODRINTH_ID }}
modrinth-token: ${{ inputs.MODRINTH_TOKEN }}
loaders: ${{ env.loader }}
game-versions: ${{ env.game-version }}
changelog-file: CHANGELOG.release.*
files: "*.mrpack"
version: ${{ steps.tag.outputs.tag }}
version-type: ${{ steps.release-type.outputs.release-type }}

- name: Print Modrinth upload status
if: steps.modrinth.outcome == 'success'
run: |
echo "::notice ::☀ Modpack ${{ inputs.modpack }} has been uploaded to Modrinth with ${{ inputs.MODRINTH_ID }}"
shell: bash

- name: Publish to CurseForge
id: curseforge
if: inputs.upload-curse == 'true'
uses: Kir-Antipov/mc-publish@v3.2
with:
curseforge-id: ${{ inputs.CURSEFORGE_ID }}
curseforge-token: ${{ inputs.CURSEFORGE_TOKEN }}
loaders: ${{ env.loader }}
game-versions: ${{ env.game-version }}
changelog-file: CHANGELOG.release.*
files: "*.zip"
version: ${{ steps.tag.outputs.tag }}
version-type: ${{ steps.release-type.outputs.release-type }}

- name: Print Curseforge upload status
if: steps.curseforge.outcome == 'success'
run: |
echo "::notice ::☀ Modpack ${{ inputs.modpack }} has been uploaded to Curseforge with ${{ inputs.CURSEFORGE_ID }}"
shell: bash
2 changes: 2 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enabled: true
titleOnly: true
59 changes: 59 additions & 0 deletions .github/workflows/bump-version-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Bump Release Please Version | Pipeline'

on:
workflow_dispatch:
inputs:
release-tag:
description: 'The release tag to bump the releases to'
required: false
default: '1.0.0'
type: string
modpack:
description: 'Path to the modpack directory'
required: false
default: 'main'
type: string
workflow_call:
inputs:
release-tag:
description: 'The release tag to bump the releases to'
required: false
default: '1.0.0'
type: string
modpack:
description: 'Path to the modpack directory'
required: false
default: 'main'
type: string


jobs:
set-version:
runs-on: ubuntu-latest

name: Update Version

permissions:
contents: write

steps:
- name: Check Out Git Repository
uses: actions/checkout@v4

- name: Get current branch
id: branch
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT

- name: Set the New Version
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_options: '--allow-empty'
skip_dirty_check: true
commit_message: |
chore(${{ steps.branch.outputs.branch }}): release ${{ inputs.release-tag }}
Release-As: ${{ inputs.release-tag }}}
- name: Print the Warning
run: |
echo "::warning ::⚠ The current release PR will update next push due to the GitHub Actions Token limitations!"
shell: bash
Loading

0 comments on commit f92ab02

Please sign in to comment.