151 lines
5.0 KiB
YAML
151 lines
5.0 KiB
YAML
name: Upstream release
|
|
|
|
# Watches Modrinth for a new Modrinth App release, rebuilds Modrinth Enhanced
|
|
# on top of it, and publishes a release of our own if everything still works.
|
|
#
|
|
# Nothing is published unless the patches applied, the checks passed and all
|
|
# three platforms built, so an upstream change that breaks a patch stops here
|
|
# and reports a failure instead of shipping a broken build.
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '17 6 * * *'
|
|
workflow_dispatch:
|
|
inputs:
|
|
upstream-ref:
|
|
description: Build this upstream tag instead of the newest one
|
|
type: string
|
|
required: false
|
|
revision:
|
|
description: Release the current patches again on the upstream release in upstream.txt, as v1.2.3-2, v1.2.3-3, ...
|
|
type: boolean
|
|
default: false
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: upstream-release
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
detect:
|
|
name: Detect
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
upstream: ${{ steps.check.outputs.upstream }}
|
|
tag: ${{ steps.check.outputs.tag }}
|
|
proceed: ${{ steps.check.outputs.proceed }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Decide what to release
|
|
id: check
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
REQUESTED: ${{ inputs.upstream-ref }}
|
|
REVISION: ${{ inputs.revision }}
|
|
run: |
|
|
set -euo pipefail
|
|
current="$(tr -d '[:space:]' < upstream.txt)"
|
|
if [ "$REVISION" = true ]; then
|
|
# A revision rebuilds what we already ship, not whatever is newest.
|
|
upstream="${REQUESTED:-$current}"
|
|
else
|
|
upstream="${REQUESTED:-$(scripts/latest-upstream.sh)}"
|
|
fi
|
|
echo "upstream=$upstream" >> "$GITHUB_OUTPUT"
|
|
echo "Upstream release: $upstream (we are on $current)"
|
|
|
|
if ! gh release view "$upstream" >/dev/null 2>&1; then
|
|
tag="$upstream"
|
|
elif [ "$REVISION" = true ]; then
|
|
# The first release of an upstream version is its plain tag, which
|
|
# counts as revision 1.
|
|
last="$(
|
|
git ls-remote --tags --refs origin "$upstream-*" |
|
|
sed 's#.*refs/tags/##' |
|
|
awk -v prefix="$upstream-" 'index($0, prefix) == 1 {
|
|
n = substr($0, length(prefix) + 1)
|
|
if (n ~ /^[0-9]+$/) print n
|
|
}' |
|
|
sort -n |
|
|
tail -1
|
|
)"
|
|
tag="$upstream-$(( ${last:-1} + 1 ))"
|
|
else
|
|
echo "$upstream has already been released; nothing to do."
|
|
echo "proceed=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
echo "proceed=true" >> "$GITHUB_OUTPUT"
|
|
echo "Releasing $tag"
|
|
|
|
build:
|
|
name: Build
|
|
needs: detect
|
|
if: needs.detect.outputs.proceed == 'true'
|
|
uses: ./.github/workflows/build.yml
|
|
with:
|
|
upstream-ref: ${{ needs.detect.outputs.upstream }}
|
|
|
|
release:
|
|
name: Release
|
|
needs: [detect, build]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Record the upstream release we build against
|
|
env:
|
|
UPSTREAM: ${{ needs.detect.outputs.upstream }}
|
|
run: |
|
|
set -euo pipefail
|
|
printf '%s\n' "$UPSTREAM" > upstream.txt
|
|
if git diff --quiet -- upstream.txt; then
|
|
echo "upstream.txt already points at $UPSTREAM"
|
|
exit 0
|
|
fi
|
|
git config user.name 'github-actions[bot]'
|
|
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
git commit -m "Track upstream $UPSTREAM" -- upstream.txt
|
|
git push origin HEAD:${{ github.event.repository.default_branch }}
|
|
|
|
- name: Download installers
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
merge-multiple: true
|
|
|
|
- name: Publish the release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
TAG: ${{ needs.detect.outputs.tag }}
|
|
UPSTREAM: ${{ needs.detect.outputs.upstream }}
|
|
run: |
|
|
set -euo pipefail
|
|
ls -la artifacts
|
|
notes="$(cat <<EOF
|
|
Modrinth Enhanced $TAG, built from [Modrinth App $UPSTREAM](https://github.com/modrinth/code/releases/tag/$UPSTREAM).
|
|
|
|
Same app as upstream, with the patches in \`patches/\` applied:
|
|
|
|
- no advertising,
|
|
- no telemetry, crash reporting or survey embeds,
|
|
- offline accounts for singleplayer and offline-mode servers,
|
|
- renamed and re-iconed as Modrinth Enhanced.
|
|
|
|
It keeps using the same data directory as the official Modrinth App,
|
|
so instances, settings and accounts carry over. Do not run both at
|
|
the same time.
|
|
|
|
See the upstream release notes for everything else that changed.
|
|
EOF
|
|
)"
|
|
gh release create "$TAG" \
|
|
--title "Modrinth Enhanced $TAG" \
|
|
--notes "$notes" \
|
|
artifacts/*
|