Publish Modpack #63
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: Publish Modpack | |
on: | |
push: | |
paths: | |
- "src/**" | |
branches: | |
- master | |
schedule: | |
# Once every week | |
- cron: "0 0 * * 0" | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The version of the modpack to update to" | |
required: false | |
type: string | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
if: (github.event_name == 'push' && !contains(github.event.head_commit.message, '[ci-skip]')) || (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@main | |
with: | |
fetch-depth: 0 | |
- name: Install .NET | |
uses: actions/setup-dotnet@main | |
- name: Update The Modpack | |
id: push | |
run: | | |
# Install Packwiz | |
go install github.com/packwiz/packwiz@latest | |
# Make it available to everyone | |
export PATH="$HOME/go/bin:$PATH" | |
# Set the version of the modpack, if specified | |
if [ -n "${{ github.event.inputs.version }}" ]; then | |
export MODPACK_VERSION="${{ github.event.inputs.version }}" | |
fi | |
# Update the modpack | |
dotnet run --project ${{ github.workspace }}/tools/ForsakenBorders.Apollo.Tools.Updater/Apollo.csproj | |
# Go into the modpack directory | |
cd ${{ github.workspace }}/src | |
# Parse the modpack version | |
MODPACK_VERSION="$(grep -Po 'version = "\K[^"]+' pack.toml)" | |
echo MODPACK_VERSION="$MODPACK_VERSION" >> $GITHUB_OUTPUT | |
# Parse the game version | |
GAME_VERSION="$(grep -Po 'minecraft = "\K[^"]+' pack.toml)" | |
echo "GAME_VERSION=$GAME_VERSION" >> $GITHUB_OUTPUT | |
# Check if there are any changes | |
if [ -n "$(git status --porcelain)" ]; then | |
# Identify as GitHub Actions | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
# Commit changes | |
git add . | |
# Set commit message | |
echo "Update to $MODPACK_VERSION" >> .commit-message | |
echo >> .commit-message | |
cat ${{ github.workspace }}/CHANGELOG.md >> .commit-message | |
git commit -F .commit-message | |
# Create a new tag | |
git tag -a "$MODPACK_VERSION" -m "Update to $MODPACK_VERSION" | |
# Push changes | |
git push | |
fi | |
# Move the modpack to the root | |
mv "Apollo-$MODPACK_VERSION.mrpack" ${{ github.workspace }} | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@main | |
with: | |
name: "Apollo-${{ steps.push.outputs.MODPACK_VERSION }}.mrpack" | |
path: "Apollo-${{ steps.push.outputs.MODPACK_VERSION }}.mrpack" | |
- uses: Kir-Antipov/mc-publish@v3 | |
with: | |
changelog-file: "CHANGELOG.md" | |
files: "*.mrpack" | |
game-versions: ${{ steps.push.outputs.GAME_VERSION }} | |
github-tag: ${{ steps.push.outputs.MODPACK_VERSION }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
loaders: fabric | |
modrinth-id: CWFVvUtu | |
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | |
name: "Apollo ${{ steps.push.outputs.MODPACK_VERSION }}" | |
version-type: release | |
version: ${{ steps.push.outputs.MODPACK_VERSION }} |