Skip to content

v1.5.1

v1.5.1 #151

name: Build and Publish (Production)
on:
push:
branches:
- main
# To freely commit on other branches without publishing the mod
jobs:
initial-checks:
name: Initial checks
runs-on: ubuntu-latest
# why lol
if: startsWith(github.event.head_commit.message, 'v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch all tags
run: git fetch --tags # why
- name: Initial version check
run: |
echo "VERSION_INPUT=$(echo "${{ github.event.head_commit.message }}" | sed -n '1p')" >> $GITHUB_ENV
VERSION_INPUT="$(echo "${{ github.event.head_commit.message }}" | sed -n '1p')"
if [[ $(git log -1 --pretty=format:'%s') =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version $VERSION_INPUT is valid."
else
echo "Version $VERSION_INPUT doesn't seem to be invalid. Goodbye!"
exit 1
fi
- name: Secondary version check
run: |
# help needed fixing
if "'echo $(git tag | sed ':a;N;$!ba;s/\n/\\n/g')'" | grep -q "$VERSION_INPUT"; then
echo "The version you're trying to release ($VERSION_INPUT) already have existed! Make sure you know what you're doing!"
exit 1
else
echo "All good! :3"
fi
magic-touches:
needs: [initial-checks]
name: Modify mod files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update changelog and bump version
id: update_changelog
run: |
VERSION_INPUT="$(echo "${{ github.event.head_commit.message }}" | sed -n '1p')"
echo "VERSION_INPUT=$(echo "${{ github.event.head_commit.message }}" | sed -n '1p')" >> $GITHUB_ENV
RAW_CHANGELOG=$(echo "${{ github.event.head_commit.message }}" | sed ':a;N;$!ba;s/\n/\\n/g')
echo "$RAW_CHANGELOG"
CHANGELOG=$(echo -e "$RAW_CHANGELOG" | sed '1,2d; /^Signed-off-by:/d')
if [ -z "$CHANGELOG" ]; then
echo "Changelog not provided. Skipping."
else
FORMATTED_DATE=$(date -d "${{ github.event.head_commit.timestamp }}" '+%Y-%m-%d')
FORMATTED_VERSION="## <cy>$VERSION_INPUT</c> ($FORMATTED_DATE)"
echo -e "\n$FORMATTED_VERSION\n$CHANGELOG" > tmp.md
cat ./changelog.md >> tmp.md
mv tmp.md changelog.md
echo Successfully appended:
echo - Version: $VERSION_INPUT
echo - Changelog: "|"
echo $CHANGELOG
echo ---
fi
jq --arg new_version "${VERSION_INPUT#v}" '.version = $new_version' mod.json > tmp.json && mv tmp.json mod.json
- name: Stage and commit changes
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
# Automatically modified files
git add mod.json changelog.md
git commit -m "Update version and changelog for release ${{ env.VERSION_INPUT }}" || echo "No changes to commit!?"
- name: Push changes to repository
run: |
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: ['magic-touches']
strategy:
fail-fast: false # nevermind
matrix:
config:
- name: Windows
os: windows-latest
- name: macOS
os: macos-latest
- name: Android32
os: ubuntu-latest
target: Android32
- name: Android64
os: ubuntu-latest
target: Android64
name: Build (${{ matrix.config.name }})
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Catch up
# see https://github.com/actions/checkout/issues/439
run: git pull origin ${{ github.ref }} --no-rebase
- name: Build the mod
uses: geode-sdk/build-geode-mod@main
with:
bindings: geode-sdk/bindings
bindings-ref: main
combine: true
target: ${{ matrix.config.target }}
build-ios:
name: Build for iOS
runs-on: macos-latest
needs: magic-touches
if: ${{ false }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Catch up
# see https://github.com/actions/checkout/issues/439
run: git pull origin ${{ github.ref }} --no-rebase
- name: Build iOS
uses: geode-catgirls/build-geode-mod@main
with:
bindings: geode-catgirls/bindings
target: iOS
gh-pat: ${{ secrets.GH_PAT }}
# super secret
package:
name: Package and release mod
runs-on: ubuntu-latest
needs: ['build']
steps:
- uses: geode-catgirls/build-geode-mod/combine@main
id: build
name: Combine mods
- uses: actions/upload-artifact@v4
name: Upload artifact
with:
name: Build Output
path: ${{ steps.build.outputs.build-output }}
- uses: actions/download-artifact@v4
name: Download artifact
- name: Misc. actions
run: |
MOD_FILE=$(find . -name '*.geode' -print -quit)
echo mod file path: $MOD_FILE
MOD_JSON=$(find . -iname "mod.json" -print -quit)
echo mod.json file path: $MOD_JSON
if [ -f "$(find . -name '*.geode' -print -quit)" ]; then
echo Mod file found. Proceeding!
fi
- name: Prepare for release
run: |
RAW_CHANGELOG=$(echo "${{ github.event.head_commit.message }}" | sed '1,2d; /^Signed-off-by:/d')
echo raw changelog:
echo $RAW_CHANGELOG
echo ----
LATEST_CHANGELOG=$(echo "$RAW_CHANGELOG" | perl -pe 's/\n/<br>/g')
if -z ["$LATEST_CHANGELOG"]; then
echo Hmmm, apparently no changelog has been provided. Using an alternate body for that then!
BODY=$(echo "<strong>This is an automated release. For the full changelogs of current and past versions, please refer to the \`changelog.md\` file.</strong><br><br><em>No changelog provided.</em>")
else
echo latest changelog:
echo $LATEST_CHANGELOG
echo ----
BODY=$(echo "<strong>This is an automated release. For the full changelogs of current and past versions, please refer to the \`changelog.md\` file.</strong><h2>What's New:</h2>$LATEST_CHANGELOG" | sed ':a;N;$!ba;s/\n/<br>/g')
fi
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
MOD_VER=$(echo "${{ github.event.head_commit.message }}" | sed -n '1p') >> $GITHUB_ENV
echo publishing mod ver: ${MOD_VER}
REPO=${{ github.repository }}
RELEASE_NAME="Release ${MOD_VER}"
uwu=$(echo "${BODY//[$'\t\r\n']}")
echo Summary:
echo - Mod version: $MOD_VER
echo - Target repository: $REPO
echo - Release name: $RELEASE_NAME
echo - Release body:
echo $uwu
echo ------
response=$(curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"tag_name\": \"$MOD_VER\", \"name\": \"$RELEASE_NAME\", \"body\": \"$uwu\", \"draft\": false, \"prerelease\": false}" \
https://api.github.com/repos/$REPO/releases)
echo == RESPONSE ==
echo $response
upload_url=$(echo $response | jq -r '.upload_url' | sed -e "s/{?name,label}//")
echo == UPLOAD URL ==
echo $upload_url
assets_url=$(echo $response | jq -r '.assets_url')
echo == ASSETS URL ==
echo $assets_url
for file in "Build Output"/*.geode; do
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"$upload_url?name=$(basename "$file")"
done
download_url=$(curl -s -X GET "$assets_url" | jq -r '.[0].browser_download_url')
echo ""
echo == DOWNLOAD URL ==
echo $download_url
# geode index login --token $PERSONAL_ACCESS_TOKEN
# geode index mods update $download_url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INDEX_TOKEN: ${{ secrets.GEODE_INDEX_TOKEN }}
- name: Delete mod file
uses: geekyeggo/delete-artifact@v5
with:
name: Build Output
failOnError: true