Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/release/round.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ A patch build (`{{BASE}}-N`) counts as a final release.

### Prepare

- [ ] Second round onwards: fixes for this version are merged on `main` and backported to `stable-{{BASE}}` (`/backport to stable-{{BASE}}` on the merged PR)
- [ ] Second round onwards and patch versions: fixes for this version are merged on `main` and backported to `{{BRANCH}}` (`/backport to {{BRANCH}}` on the merged PR)
- [ ] [Prepare release](https://github.com/Euro-Office/release/actions/workflows/prepare.yml) with `{{VERSION}}`
- [ ] CI is green on the release PRs of [DocumentServer](https://github.com/Euro-Office/DocumentServer/pulls?q=head%3Arelease%2Fv{{VERSION}}) and [DesktopEditors](https://github.com/Euro-Office/DesktopEditors/pulls?q=head%3Arelease%2Fv{{VERSION}})
- [ ] QA the PR builds (linked in the PR comments): packages on the supported distributions, Docker image, desktop installers
- [ ] Blockers are fixed or moved
- [ ] Approve and merge both release PRs (from the second round on they target `stable-{{BASE}}`)
- [ ] Approve and merge both release PRs (they target `{{BRANCH}}` once it exists)

### Tag

- [ ] [Tag release](https://github.com/Euro-Office/release/actions/workflows/tag.yml) with `{{VERSION}}`, approve the `release` environment deployment
- [ ] Second round onwards, before the next round: merge the `forward-port/v{{VERSION}}` PRs on `main` of [DocumentServer](https://github.com/Euro-Office/DocumentServer/pulls?q=head%3Aforward-port%2Fv{{VERSION}}) and [DesktopEditors](https://github.com/Euro-Office/DesktopEditors/pulls?q=head%3Aforward-port%2Fv{{VERSION}})
- [ ] Second round onwards and patch versions, before the next round: merge the `forward-port/v{{VERSION}}` PRs on `main` of [DocumentServer](https://github.com/Euro-Office/DocumentServer/pulls?q=head%3Aforward-port%2Fv{{VERSION}}) and [DesktopEditors](https://github.com/Euro-Office/DesktopEditors/pulls?q=head%3Aforward-port%2Fv{{VERSION}})
- [ ] Tag builds are green: [DocumentServer](https://github.com/Euro-Office/DocumentServer/actions/workflows/release.yml?query=branch%3Av{{VERSION}}), [DesktopEditors](https://github.com/Euro-Office/DesktopEditors/actions/workflows/build.yml?query=branch%3Av{{VERSION}})

A rebuild re-runs the build of the same tag. A content change needs a new version.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
else
echo "::error::invalid version: $VERSION"; exit 1
fi
render() { sed -e "s/{{VERSION}}/$VERSION/g" -e "s/{{BASE}}/$base/g" -e "s/{{BUILD}}/$build/g" "$1"; }
branch=stable-${base%.*}
render() { sed -e "s/{{VERSION}}/$VERSION/g" -e "s/{{BASE}}/$base/g" -e "s/{{BUILD}}/$build/g" -e "s/{{BRANCH}}/$branch/g" "$1"; }

title="Release $base"
url=$(gh issue list -R "$GITHUB_REPOSITORY" --search "\"$title\" in:title" --json title,url \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
[ "$DRY_RUN" != true ] || args+=(--dry-run)
./release.sh tag "$VERSION" "${args[@]}"

- name: Forward-port changelog and version to main
- name: Forward-port the changelog to main
if: ${{ !inputs.dry_run }}
env:
GH_TOKEN: ${{ secrets.EO_ROBOT_GITHUB_TOKEN }}
Expand Down
65 changes: 34 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,56 @@ Releases DocumentServer and DesktopEditors with one version and tags it across a

## Releasing

A version (`9.3.6`) is released in rounds: one or more release candidates (`9.3.6-rc.1`, `9.3.6-rc.2`) and the final release, later maybe [patch builds](#patch-builds) (`9.3.6-1`). Each round:
We follow [semantic versioning](https://semver.org). `main` builds the next minor or major version (9.4.0) with features. Each minor version gets one long-lived `stable-X.Y` branch (`stable-9.3`) that only gets backported fixes, so its patch releases (9.3.9, 9.3.10) stay fix-only. We maintain the newest line and the previous one: fixes go to the newest by default, security and important bug fixes also to the previous one.

1. Run **Release issue** with the version. The first round opens the `Release 9.3.6` issue that tracks blockers and the milestone ([template](.github/release/issue.md)); every round adds its [checklist](.github/release/round.md) as a comment. Follow that checklist.
2. Run **Prepare release** with the version. It pins every submodule to its latest default-branch commit, or from the second round on to the latest commit of `stable-9.3.6` (shared submodules get the same commit in both products), bumps `VERSION` / `VERSION.txt`, prepends `CHANGELOG.md` and opens a `release/v<version>` PR in each product. The PR builds are the ones to QA.
A version (`9.4.0`) is released in rounds: one or more release candidates (`9.4.0-rc.1`, `9.4.0-rc.2`) and the final release, later maybe [patch builds](#patch-builds) (`9.4.0-1`). Each round:

1. Run **Release issue** with the version. The first round opens the `Release 9.4.0` issue that tracks blockers and the milestone ([template](.github/release/issue.md)); every round adds its [checklist](.github/release/round.md) as a comment. Follow that checklist.
2. Run **Prepare release** with the version. It pins every submodule to the latest commit of `stable-9.4`, or of the default branch while that branch does not exist yet (shared submodules get the same commit in both products), bumps `VERSION` / `VERSION.txt`, prepends `CHANGELOG.md` and opens a `release/v<version>` PR in each product. The PR builds are the ones to QA.
3. Review and merge the release PRs.
4. Run **Tag release** with the same version and approve the `release` environment. It checks the merged PRs and that shared submodules match, then tags every submodule and finally the products, which starts their builds. The first tag of a version also creates `stable-9.3.6` at the tagged commit in every repo.
5. The tag builds publish the GitHub releases, images and packages: rc tags as prereleases, the final tag as latest. The Nextcloud Office desktop installers still have to be signed and uploaded by hand.
4. Run **Tag release** with the same version and approve the `release` environment. It checks the merged PRs and that shared submodules match, then tags every submodule and finally the products, which starts their builds. The first tag of a minor version (`9.4.0-rc.1`) also creates `stable-9.4` at the tagged commit in every repo.
5. The tag builds publish the GitHub releases, images and packages: rc tags as prereleases, final tags as stable. Only the highest stable version becomes latest. The Nextcloud Office desktop installers still have to be signed and uploaded by hand.

Everything after the first round only gets what is backported: merge a fix on `main` first (label it `backport-request` so it is not forgotten), then comment `/backport to stable-9.4` on the merged PR. The release PRs of these rounds target the branch, so **Tag release** opens a `forward-port/v<version>` PR on `main` with the round's `CHANGELOG.md` section. `main` keeps its own version. Locally: `./release.sh forward-port 9.4.0 --dry-run`.

Later rounds only get what is backported: merge a fix on `main` first, then comment `/backport to stable-9.3.6` on the merged PR. The release PRs of these rounds target the branch, so **Tag release** opens a `forward-port/v<version>` PR on `main` with the round's `CHANGELOG.md` section and, after a final release or patch build, moves `VERSION` on `main` to the next patch version (9.3.6 → 9.3.7) unless `main` is already ahead. The next rc.1 sets the real next version. Locally: `./release.sh forward-port 9.3.6 --dry-run`.
The changelog covers the changes since the highest release below the version, so a 9.3.10 after 9.4.0 lists the changes since 9.3.9.

Turn off `bump_submodules` to keep the submodule commits the products already point at (`--no-bump` locally); `tag` still checks that shared submodules match.

`products` limits a release to `ds` or `de`. The skipped product does not get that version.

### Hotfixes

A hotfix of a released version is the next patch version, released from a branch of the previous one and usually without rc rounds. For a hotfix of 9.3.6:
### Patch versions

1. Create `stable-9.3.7` at the head of `stable-9.3.6` in both products and every submodule:
```sh
for repo in DocumentServer DesktopEditors $(for p in DocumentServer DesktopEditors; do
gh api "repos/Euro-Office/$p/contents/.gitmodules" -H 'Accept: application/vnd.github.raw'
done | sed -nE 's#.*github\.com/Euro-Office/([^/]+)\.git$#\1#p' | sort -u); do
sha=$(gh api "repos/Euro-Office/$repo/git/ref/heads/stable-9.3.6" --jq .object.sha) &&
gh api "repos/Euro-Office/$repo/git/refs" -f ref=refs/heads/stable-9.3.7 -f sha="$sha" >/dev/null &&
echo "$repo: created stable-9.3.7 at $sha"
done
```
2. Merge the fix on `main` and comment `/backport to stable-9.3.7` on the merged PR.
3. Release `9.3.7` as above. Since `stable-9.3.7` exists, prepare pins from it, the release PRs target it and the changelog covers the changes since `v9.3.6`.

The next feature release from `main` then becomes 9.3.8 or 9.4.0. Letter suffixes like `9.3.6-hotfix.1` build as prereleases (`9.3.6-0~hotfix.1`), which apt and dnf sort before `9.3.6-0`.
A patch version (`9.3.9`) is released from `stable-9.3` like any round, usually without rc rounds: backport the fixes, then release it. Prepare refuses a patch version without its `stable-X.Y` branch. Letter suffixes like `9.3.9-hotfix.1` build as prereleases (`9.3.9-0~hotfix.1`), which apt and dnf sort before `9.3.9-0`.

### Patch builds

Dependency bumps and small fixes of a released version can ship as a patch build instead of a new patch version: `9.3.7-1` is build number 1 of 9.3.7 (`9.3.7` itself is build 0).
Dependency bumps and small fixes of the newest patch version of a line can ship as a patch build instead of a new patch version: `9.3.9-1` is build number 1 of 9.3.9 (`9.3.9` itself is build 0).

| | 9.3.7 | 9.3.7-1 |
| | 9.3.9 | 9.3.9-1 |
|---|---|---|
| deb/rpm | `9.3.7-0` | `9.3.7-1` |
| Windows | `9.3.7.0` | `9.3.7.1` |
| download dir | `9.3.7/0` | `9.3.7/1` |
| deb/rpm | `9.3.9-0` | `9.3.9-1` |
| Windows | `9.3.9.0` | `9.3.9.1` |
| download dir | `9.3.9/0` | `9.3.9/1` |

1. Backport the changes to `stable-9.3` (`/backport to stable-9.3`).
2. Release `9.3.9-1` as above, without rc rounds: QA the release PR builds. Prepare pins from `stable-9.3` and the changelog covers the changes since `v9.3.9`. The build is stable: APT/DNF and releases, `latest` only if it is the highest stable version.

1. Backport the changes to `stable-9.3.7` (`/backport to stable-9.3.7`).
2. Release `9.3.7-1` as above, without rc rounds: QA the release PR builds. Prepare pins from `stable-9.3.7` and the changelog covers the changes since `v9.3.7`. The build is stable: APT/DNF, `latest` images and releases.
`9.3.9-0` and prereleases of patch builds (`9.3.9-1-rc.1`) are rejected, both would sort wrong. Once 9.3.10 shipped, `9.3.9-2` is no longer possible. Use a new patch version (9.3.10) for fixes users should notice.

`9.3.7-0` and prereleases of patch builds (`9.3.7-1-rc.1`) are rejected, both would sort wrong. Use a new patch version (9.3.8) for fixes users should notice.
### Creating a stable branch by hand

`stable-9.3` predates this flow and was created by hand from `stable-9.3.8`, in both products and every submodule:

```sh
for repo in DocumentServer DesktopEditors $(for p in DocumentServer DesktopEditors; do
gh api "repos/Euro-Office/$p/contents/.gitmodules" -H 'Accept: application/vnd.github.raw'
done | sed -nE 's#.*github\.com/Euro-Office/([^/]+)\.git$#\1#p' | sort -u); do
sha=$(gh api "repos/Euro-Office/$repo/git/ref/heads/stable-9.3.8" --jq .object.sha) &&
gh api "repos/Euro-Office/$repo/git/refs" -f ref=refs/heads/stable-9.3 -f sha="$sha" >/dev/null &&
echo "$repo: created stable-9.3 at $sha"
done
```

## Local use

Expand Down
41 changes: 20 additions & 21 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ valid_version() { [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+|-[1-9][0-9]*)
# A numeric suffix (v9.3.7-1) is a patch build of a stable release.
is_stable() { [[ $1 =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$ ]]; }
is_patch() { [[ $1 =~ ^v[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$ ]]; }
# Only X.Y.0 and its rounds may start from main, later patch versions and patch builds need stable-X.Y.
needs_branch() { [[ $1 =~ ^v[0-9]+\.[0-9]+\.([0-9]+) ]] && { [ "${BASH_REMATCH[1]}" != 0 ] || is_patch "$1"; }; }

# stdin: tags, newest first. A stable release compares against the previous stable one.
# stdin: tags. Prints the highest release below <tag>, so a 9.3.10 after 9.4.0 compares against 9.3.9.
# A stable release compares against the previous stable one.
previous_tag() {
local re='v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?'
local re='v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?' key t
is_stable "$1" || re='v[0-9]+\.[0-9]+\.[0-9]+(-[0-9a-z.]+)?'
grep -Ex "$re" | grep -vxF "$1" | head -n 1 || true
key=$(version_key "$1")
{ grep -Ex "$re" || true; } | while read -r t; do echo "$(version_key "$t") $t"; done |
awk -v k="$key" '($1 "") < (k "") { print }' | sort | tail -n 1 | cut -d ' ' -f 2
}

release_branch() { echo "stable-${1%%-*}"; }
# One long-lived branch per minor version: 9.3.6-rc.1, 9.3.7 and 9.3.7-1 all release from stable-9.3.
release_branch() { local v=${1%%-*}; echo "stable-${v%.*}"; }

# Sortable key of 9.3.7, v9.3.7-rc.1 or 9.3.7-1: prereleases sort before the release, patch builds after it.
version_key() {
Expand Down Expand Up @@ -175,13 +181,6 @@ insert_changelog() {
# stdin: a changelog. Prints the section of <tag>.
changelog_section() { awk -v h="## $1" '/^## / { on = $0 == h } on'; }

# Version of main (<current>) after the final release <version>: at least the next patch version.
main_version() {
local next=${2%%-*}
next=${next%.*}.$((${next##*.} + 1))
if [[ $(version_key "${1%%-*}") < $(version_key "$next") ]]; then echo "$next"; else echo "$1"; fi
}

# Keeps the existing trailing-newline style of the version file.
write_version() { if [ -n "$(tail -c 1 "$1")" ]; then printf '%s' "$2" >"$1"; else echo "$2" >"$1"; fi; }

Expand All @@ -208,7 +207,7 @@ notes_product() {
git ls-remote --exit-code "https://github.com/$OWNER/$repo.git" "refs/heads/$BRANCH" >/dev/null || rc=$?
case $rc in
0) ref=refs/heads/$BRANCH base=$BRANCH ;;
2) ! is_patch "$TAG" || die "$repo: patch build $TAG needs $BRANCH, release the version first or use --products" ;;
2) ! needs_branch "$TAG" || die "$repo: $TAG needs $BRANCH, the first tag of ${BRANCH#stable-}.0 creates it (or by hand, see README.md)" ;;
*) die "$repo: cannot look up $BRANCH" ;;
esac
echo "$base" >"$out.base"
Expand Down Expand Up @@ -310,12 +309,12 @@ cmd_prepare() {
fi
}

# Rounds from a stable branch never reach main: copy their changelog section to main and,
# after a final release, move main to the next patch version so its builds sort after the release.
# Rounds from a stable branch never reach main: copy their changelog section to main.
# main keeps its own version, the next minor or major.
cmd_forward_port() {
local p repo vfile dir url
local p repo dir url
for p in $PRODUCTS; do
read -r repo vfile < <(product "$p")
read -r repo _ < <(product "$p")
dir="$WORK/$repo"
gh api "repos/$OWNER/$repo/contents/CHANGELOG.md?ref=$TAG" -H 'Accept: application/vnd.github.raw' |
changelog_section "$TAG" >"$WORK/$repo.section.md"
Expand All @@ -324,7 +323,6 @@ cmd_forward_port() {
git -C "$dir" checkout -q -b "forward-port/$TAG"
[ -f "$dir/CHANGELOG.md" ] || die "$repo: main has no CHANGELOG.md"
grep -qxF "## $TAG" "$dir/CHANGELOG.md" || insert_changelog "$dir/CHANGELOG.md" "$WORK/$repo.section.md" "$TAG"
! is_stable "$TAG" || write_version "$dir/$vfile" "$(main_version "$(tr -d '[:space:]' <"$dir/$vfile")" "$VERSION")"
if git -C "$dir" diff --quiet; then
log "$repo: main already has $TAG"
continue
Expand All @@ -338,7 +336,7 @@ cmd_forward_port() {
url=$(gh pr view "forward-port/$TAG" -R "$OWNER/$repo" --json url --jq .url 2>/dev/null) ||
url=$(gh pr create -R "$OWNER/$repo" --base main --head "forward-port/$TAG" \
--title "chore(release): forward-port $TAG to main" \
--body "Changelog of $TAG and, after a final release, the next patch version on \`main\`. Release PRs from \`$BRANCH\` do not reach \`main\`.")
--body "Changelog of $TAG on \`main\`. Release PRs from \`$BRANCH\` do not reach \`main\`.")
log "$repo: $url"
done
}
Expand Down Expand Up @@ -417,7 +415,7 @@ cmd_tag() {
log "$slug: tagged $TAG"
done <"$WORK/todo"

# The first tag of a version branches every repo, so later rounds only get what is backported.
# The first tag of a minor version branches every repo, so later rounds and patch versions only get what is backported.
while read -r slug sha; do
if gh api "repos/$slug/git/ref/heads/$BRANCH" >/dev/null 2>&1; then
log "$slug: $BRANCH exists"
Expand All @@ -437,8 +435,9 @@ main() {
return
fi
if [ "${1:-}" = notes ]; then
# A prerelease placeholder makes previous_tag pick the latest tag of any kind, its missing branch pins default branches.
TAG=v0.0.0-next.1 BRANCH=$(release_branch 0.0.0) BUMP=true PRODUCTS="ds de" SINCE="" WORK=$(mktemp -d)
# A prerelease placeholder above every version makes previous_tag pick the highest tag of any kind,
# its missing branch pins default branches.
TAG=v999999.0.0-next.1 BRANCH=$(release_branch 999999.0.0) BUMP=true PRODUCTS="ds de" SINCE="" WORK=$(mktemp -d)
: >"$WORK/pins"
cmd_notes
return
Expand Down
Loading
Loading