refactor: add mc-modpack-kit template

This commit is contained in:
darksaid98 committed 2024-01-03 19:31:08 +01:00
1 parent 39a79e2216
commit 8a2820fb03
108 files changed
+773

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
@@ -0,0 +1,20 @@
---
name: Feature request for CI
about: Suggest an idea for this project to use in the CI actions
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
---
name: Feature request for docs
about: Suggest an idea for this project to use in it's README
title: ''
labels: documentation
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -0,0 +1,23 @@
---
name: Question
about: Ask a question about this project
title: ''
labels: question
assignees: ''
---
**Describe the question**
A clear and concise description of the question.
**Is your question related to a problem? Please describe.**
A clear and concise description of what the problem is. E.g., I'm always frustrated when [...]
**Additional context**
Add any other context or screenshots about the feature request here.
- [ ] Clarification needed
- [ ] Technical issue
- [ ] Conventional commits
- [ ] Problems with GitHub Actions
- [ ] Versioning
+84
View File
@@ -0,0 +1,84 @@
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:
# --- Checkout the repo
- name: Check Out Git Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: 'main'
# --- Install Packwiz
- 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"
# --- Build Modrinth Pack If Wanted
- 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 }}
# --- Build Curseforge Pack If Wanted
- 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 }}
# --- Upload the pack/s to releases
- 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 }}
+43
View File
@@ -0,0 +1,43 @@
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'
branch:
description: "Branch, where to do the bump"
required: false
default: 'main'
runs:
using: 'composite'
steps:
# --- Checkout with the named branch
- name: Check Out Git Repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
# --- Use sed to set the version
- name: Set the Version
run: sed -i 's/version = "[^"]*"/version = "${{ inputs.release-tag }}"/' ${{ inputs.modpack }}/${{ inputs.pack-file }}
shell: bash
# --- Push the version
- name: Push The Updated Version
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(${{ inputs.modpack }}): bump version to ${{ inputs.release-tag }}"
+53
View File
@@ -0,0 +1,53 @@
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:
# --- Checkout repo
- name: Check Out Git Repository
uses: actions/checkout@v3
# --- Parse the pack.toml
# I am bored so sorry that I don't explain this, you should probably read the code?
- name: Parse the pack.toml
id: parse
run: |
loaders=("fabric" "forge" "quilt" "neoforge")
for loader in "${loaders[@]}"; do
if [[ $(<"${{ inputs.pack-file }}") == *"$loader ="* ]]; then
LOADER="$loader" && break
fi
done
[[ -z "$LOADER" ]] && { echo "::error file=${{ inputs.pack-file }}::No match found for loaders in ${{ inputs.pack-file }}" && exit 1; }
GAME_VERSION=$(grep -oP 'minecraft = "\K[^"]+' "${{ inputs.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 }}
+136
View File
@@ -0,0 +1,136 @@
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: .
release-tag:
description: "Tag for the description"
required: true
runs:
using: "composite"
steps:
# --- Checkout the repo
- name: Check Out Git Repository
uses: actions/checkout@v3
# --- Download the pack files
- name: Download the pack files
uses: robinraju/[email protected]
id: download-files
with:
fileName: "*"
tag: ${{ inputs.release-tag }}
tarBall: false
zipBall: false
# --- Get latest release description
- name: Get latest release description
uses: cardinalby/git-get-release-action@v1
id: latest-release
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ inputs.release-tag }}
# --- Set publish version-type
- 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
# --- Pipe latest release description to file
- name: Pipe latest release description to file
run: echo "${{ steps.latest-release.outputs.body }}" > CHANGELOG.release.md
shell: bash
# --- Print status
- 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/[email protected]
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/[email protected]
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
+11
View File
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
+2
View File
@@ -0,0 +1,2 @@
enabled: true
titleOnly: true
+52
View File
@@ -0,0 +1,52 @@
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
jobs:
set-version:
runs-on: ubuntu-latest
name: Update Version
permissions:
contents: write
steps:
# --- Checkout the repo
- name: Check Out Git Repository
uses: actions/checkout@v4
# --- Get current branch
- name: Get current branch
id: branch
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
# --- Set the new version
# TODO: Change to an pr
- 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 }}}
+185
View File
@@ -0,0 +1,185 @@
name: Modpack Release | Pipeline
on:
push:
branches:
- main
env:
pack-file: 'pack.toml'
default-release-modrinth: 'true'
default-release-curseforge: 'false'
jobs:
parse-current-modpacks:
name: Parse current modpacks to a list
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
modpack-folders: ${{ steps.list-modpacks.outputs.modpack-folders }}
steps:
# -- Checkout repo
- name: Check Out Git Repository
uses: actions/checkout@v4
# --- Parse the modpacks to and list
# This just parses the folders that have pack.toml
- name: List Modpacks
id: list-modpacks
run: |
modpackFolders=()
for folder in *; do
if [ -d "$folder" ]; then
if [ -e "$folder/${{ env.pack-file }}" ]; then
modpackFolders+=("$folder")
fi
fi
done
echo "modpack-folders=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${modpackFolders[@]}")" >> "$GITHUB_OUTPUT"
# --- Print an nice msg about parsing
- name: Current detected modpacks
run: |
echo "::notice ::⚙ Current detected modpacks: ${{ steps.list-modpacks.outputs.modpack-folders }}"
release-please:
needs:
- parse-current-modpacks
if: ${{ (needs.parse-current-modpacks.outputs.modpack-folders) != '[]' }}
strategy:
fail-fast: false
matrix:
modpack: ${{ fromJson(needs.parse-current-modpacks.outputs.modpack-folders) }}
name: Handle Releases
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.modpack }}
permissions:
contents: write
pull-requests: write
steps:
# --- Release please
# Creates and manages the prs and releases
- name: Perform Release with Release Please
id: release-please
uses: google-github-actions/release-please-action@v3
with:
monorepo-tags: true
path: ${{ matrix.modpack }}
release-type: simple
package-name: ${{ matrix.modpack }}
prerelease: true
changelog-types: >
[{"type":"feat","section":"★ Features","hidden":false},
{"type":"fix","section":"♻ Bug Fixes","hidden":false},
{"type":"mod","section":"☀ Modpack Changes","hidden":false},
{"type":"update","section":"⚘ Modpack Updates","hidden":false},
{"type":"chore","section":"⛭ Miscellaneous","hidden":true}]
# --- Parse version from PR Title when creating PR's
# Had to do this cause like to bump on the release pleae branch
# The tests for the shitty Regex can be found here: https://regexr.com/7lb8e
- name: Parse tag from PR title
uses: actions-ecosystem/action-regex-match@v2
id: version
with:
text: ${{ fromJson(steps.release-please.outputs.pr).title }}
regex: '(?<=\s)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$'
if: ${{ steps.release-please.outputs.pr != '' }}
# --- Checkout the git repo
# Remembed to do this AFTER release please
- name: Check Out Git Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# --- Bump version
# Now we should use the parsed release to bump the version on the files on the release please branch
- name: Bump Version
uses: ./.github/actions/bump-pack
with:
release-tag: ${{ steps.version.outputs.match }}
modpack: ${{ matrix.modpack }}
branch: ${{ fromJson(steps.release-please.outputs.pr).headBranchName }}
if: ${{ steps.release-please.outputs.pr != '' }}
# --- Get latest tag
# Should probably be switched to use the release please tag but whatever
- name: Get Latest tag
id: tag
uses: WyriHaximus/github-action-get-previous-tag@v1
if: ${{ steps.release-please.outputs.releases_created }}
# --- Handle the configs
- name: Parse Pack File
id: parse
uses: ./.github/actions/parse
with:
modpack: ${{ matrix.modpack }}
if: ${{ steps.release-please.outputs.releases_created }}
- name: Set Mod Vendors
id: set-mod-vendors
run: |
[[ ! -z "${{ secrets.CURSEFORGE_TOKEN }}" && ! -z "${{ secrets.CURSEFORGE_ID }}" ]] && echo "curseforge=true" >> $GITHUB_OUTPUT || echo "curseforge=false" >> $GITHUB_OUTPUT
[[ ! -z "${{ secrets.MODRINTH_TOKEN }}" && ! -z "${{ secrets.MODRINTH_ID }}" ]] && echo "modrinth=true" >> $GITHUB_OUTPUT || echo "modrinth=false" >> $GITHUB_OUTPUT
shell: bash
if: ${{ steps.release-please.outputs.releases_created }}
# --- Build an release
- name: Build Modpack
uses: ./.github/actions/build
with:
modpack: ${{ matrix.modpack }}
release-tag: ${{ steps.tag.outputs.tag }}
build-modrinth: ${{ env.default-release-modrinth }}
build-curse: ${{ env.default-release-curseforge }}
if: ${{ steps.release-please.outputs.releases_created }}
# --- Release
- name: Release Modpack to Vendors
uses: ./.github/actions/release
with:
modpack: ${{ matrix.modpack }}
release-tag: ${{ steps.tag.outputs.tag }}
loader: ${{ steps.parse.outputs.loader }}
game-version: ${{ steps.parse.outputs.game-version }}
upload-modrinth: ${{ steps.set-mod-vendors.outputs.modrinth }}
upload-curse: ${{ steps.set-mod-vendors.outputs.curseforge }}
MODRINTH_ID: ${{ secrets.MODRINTH_ID }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CURSEFORGE_ID: ${{ secrets.CURSEFORGE_ID }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
if: |
steps.release-please.outputs.releases_created &&
(steps.set-mod-vendors.outputs.modrinth || steps.set-mod-vendors.outputs.curseforge)
+86
View File
@@ -0,0 +1,86 @@
name: Update | Pipeline
on:
workflow_dispatch:
jobs:
parse-current-modpacks:
name: Parse current modpacks to a list
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
modpack_folders: ${{ steps.list_modpacks.outputs.modpack_folders }}
steps:
- name: Check Out Git Repository
uses: actions/checkout@v4
- name: List Modpacks
id: list_modpacks
run: |
modpackFolders=()
for folder in *; do
if [ -d "$folder" ]; then
if [ -e "$folder/pack.toml" ]; then
modpackFolders+=("$folder")
fi
fi
done
echo "modpack_folders=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${modpackFolders[@]}")" >> "$GITHUB_OUTPUT"
- name: Current detected modpacks
run: |
echo "::notice ::⚙ Current detected modpacks: ${{ steps.list_modpacks.outputs.modpack_folders }}"
update_mods:
name: Update Mods
runs-on: ubuntu-latest
needs:
- parse-current-modpacks
if: ${{ (needs.parse-current-modpacks.outputs.modpack_folders) != '[]' }}
strategy:
fail-fast: false
matrix:
modpack: ${{ fromJson(needs.parse-current-modpacks.outputs.modpack_folders) }}
defaults:
run:
working-directory: ${{ matrix.modpack }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- 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: Update Mods with Packwiz
run: packwiz update -a -y
- name: Push the updated mod list via a Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "update(${{ matrix.modpack }}): updated mods"
title: 'update(${{ matrix.modpack }}): updated mods'
body: >
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).