ci: release revisions of an upstream version

This commit is contained in:
Felitendo committed 2026-09-14 20:05:08 +02:00
1 parent 109171e355
commit d93955cbce
2 files changed
+48 -18

No files matched your search

+44 -18
View File
@@ -16,8 +16,8 @@ on:
description: Build this upstream tag instead of the newest one description: Build this upstream tag instead of the newest one
type: string type: string
required: false required: false
force: revision:
description: Release even if this version was already released description: Release the current patches again on the upstream release in upstream.txt, as v1.2.3-2, v1.2.3-3, ...
type: boolean type: boolean
default: false default: false
@@ -33,30 +33,55 @@ jobs:
name: Detect name: Detect
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
upstream: ${{ steps.check.outputs.upstream }}
tag: ${{ steps.check.outputs.tag }} tag: ${{ steps.check.outputs.tag }}
proceed: ${{ steps.check.outputs.proceed }} proceed: ${{ steps.check.outputs.proceed }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Find the newest upstream release - name: Decide what to release
id: check id: check
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
REQUESTED: ${{ inputs.upstream-ref }} REQUESTED: ${{ inputs.upstream-ref }}
FORCE: ${{ inputs.force }} REVISION: ${{ inputs.revision }}
run: | run: |
set -euo pipefail set -euo pipefail
tag="${REQUESTED:-$(scripts/latest-upstream.sh)}"
current="$(tr -d '[:space:]' < upstream.txt)" current="$(tr -d '[:space:]' < upstream.txt)"
echo "tag=$tag" >> "$GITHUB_OUTPUT" if [ "$REVISION" = true ]; then
echo "Newest upstream release: $tag (we are on $current)" # A revision rebuilds what we already ship, not whatever is newest.
upstream="${REQUESTED:-$current}"
if gh release view "$tag" >/dev/null 2>&1 && [ "$FORCE" != 'true' ]; then
echo "$tag has already been released; nothing to do."
echo "proceed=false" >> "$GITHUB_OUTPUT"
else else
echo "proceed=true" >> "$GITHUB_OUTPUT" upstream="${REQUESTED:-$(scripts/latest-upstream.sh)}"
fi 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: build:
name: Build name: Build
@@ -64,7 +89,7 @@ jobs:
if: needs.detect.outputs.proceed == 'true' if: needs.detect.outputs.proceed == 'true'
uses: ./.github/workflows/build.yml uses: ./.github/workflows/build.yml
with: with:
upstream-ref: ${{ needs.detect.outputs.tag }} upstream-ref: ${{ needs.detect.outputs.upstream }}
release: release:
name: Release name: Release
@@ -75,17 +100,17 @@ jobs:
- name: Record the upstream release we build against - name: Record the upstream release we build against
env: env:
TAG: ${{ needs.detect.outputs.tag }} UPSTREAM: ${{ needs.detect.outputs.upstream }}
run: | run: |
set -euo pipefail set -euo pipefail
printf '%s\n' "$TAG" > upstream.txt printf '%s\n' "$UPSTREAM" > upstream.txt
if git diff --quiet -- upstream.txt; then if git diff --quiet -- upstream.txt; then
echo "upstream.txt already points at $TAG" echo "upstream.txt already points at $UPSTREAM"
exit 0 exit 0
fi fi
git config user.name 'github-actions[bot]' git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -m "Track upstream $TAG" -- upstream.txt git commit -m "Track upstream $UPSTREAM" -- upstream.txt
git push origin HEAD:${{ github.event.repository.default_branch }} git push origin HEAD:${{ github.event.repository.default_branch }}
- name: Download installers - name: Download installers
@@ -98,11 +123,12 @@ jobs:
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.detect.outputs.tag }} TAG: ${{ needs.detect.outputs.tag }}
UPSTREAM: ${{ needs.detect.outputs.upstream }}
run: | run: |
set -euo pipefail set -euo pipefail
ls -la artifacts ls -la artifacts
notes="$(cat <<EOF notes="$(cat <<EOF
Modrinth Enhanced built from [Modrinth App $TAG](https://github.com/modrinth/code/releases/tag/$TAG). 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: Same app as upstream, with the patches in \`patches/\` applied:
+4
View File
@@ -163,6 +163,10 @@ scripts/prepare.sh
published a newer release than `upstream.txt`, it rebuilds against it and — only if every published a newer release than `upstream.txt`, it rebuilds against it and — only if every
platform built and every check passed — commits the bump, tags it with the upstream version and platform built and every check passed — commits the bump, tags it with the upstream version and
publishes a release with the installers. publishes a release with the installers.
- **Revisions** of the same upstream release are published by running Upstream release by hand
with `revision` ticked. It builds the upstream release in `upstream.txt` again with the current
patches and publishes it as `v0.21.2-2`, `v0.21.2-3` and so on. The app and installers still
carry the upstream version: RPM and the Windows installers do not accept a suffix in it.
`scripts/check.sh` is what makes the automation trustworthy. A patch can apply cleanly and still `scripts/check.sh` is what makes the automation trustworthy. A patch can apply cleanly and still
stop doing its job if upstream moves the thing it was holding down, so the checks assert the stop doing its job if upstream moves the thing it was holding down, so the checks assert the