Files
gitea/snap/part-gitea-pull.sh
bircni 8a553332f7 ci: skip reverted commits in release notes, publish tagged snaps to stable (#39657)
Release notes: revert commits and the commits they revert are now left
out of the git-cliff changelog. A step before git-cliff finds commits
whose subject starts with "revert", reads the PR numbers on their revert
lines, and writes both SHAs to `.cliffignore`.

Snap: since the move from Launchpad to GitHub Actions, every build was
uploaded to `latest/edge`, including the stable-grade build that
`part-gitea-pull.sh` makes for an unreleased tag. Launchpad used to
release those builds to candidate and stable automatically. Without
that, v28.0.0 had to be promoted by hand and v28.1.0 stayed in edge.
Stable-grade snaps now go to `latest/stable` and `latest/candidate`;
main builds still go to edge. Candidate has to be updated too because
the pull script compares against it.

---------

Signed-off-by: bircni <bircni@icloud.com>
2026-10-08 11:35:03 +02:00

64 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
set -e
if [ ! -f go.mod ] || [ ! -d snap ]; then
echo "This script should be run from the root of the gitea repository"
exit 1
fi
if [ -z "$SNAPCRAFT_PROJECT_NAME" ]; then
echo "No snapcraft build env, continue with mocking ...."
craftctl() { echo "* mocking craftctl: $*"; }
snap() { echo "* mocking snap: $*"; }
else
echo "Add working directory to git safe.directory ..."
git config --global --add safe.directory "$PWD"
fi
# How it works:
# * release-nightly-snapcraft.yml builds the snap on every push to the default branch (e.g.: main during 1.27 dev period)
# * "override-pull" step gets the latest tag by date (e.g.: v1.26.1)
# * use "snap info gitea" to get the latest released tag, which is the version in the "latest/candidate" channel
# * if the latest tag is not released yet, checkout that tag and build it with grade "stable",
# the workflow publishes it to "latest/stable" and "latest/candidate"
# * otherwise, build the main branch with grade "devel", the workflow publishes it to "latest/edge"
# * "override-build" step uses build script from the checked out commit to build
# This approach highly depends on the "main" branch's push: a new tag is only published by the next push after it.
# To debug the logic:
# * last_committed_tag=v1.26.1 last_released_tag=v1.26.0 ./snap/part-gitea-pull.sh
# it will checkout tag v1.26.1, and build that for "stable"
# * last_committed_tag=v1.26.1 last_released_tag=v1.26.1 recent_tag=v1.27.0-dev-205 ./snap/part-gitea-pull.sh
# it will still use the current branch, and build it for "devel"
[ -z "$last_committed_tag" ] && last_committed_tag="$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags | tail -n 1)"
[ -z "$last_released_tag" ] && last_released_tag="$(snap info gitea | awk '$1 == "latest/candidate:" { print $2 }')"
if [ "${last_committed_tag}" != "${last_released_tag}" ]; then
# if the latest tag has not been released to stable, build that tag instead of default branch.
echo "Build last committed tag ${last_committed_tag} for new release, fetching and checking out ..."
git fetch --quiet
git checkout --quiet "${last_committed_tag}"
# HINT: after this, the "build" step will use that commit's "part-gitea-build.sh", but not this one's
else
echo "Build current branch $(git branch --show-current) @ $(git rev-parse HEAD)"
fi
# possible tag names:
# * v1.27.0-dev-205-gce089f498b
# * v1.26.1
# * v1.22.0-rc1-2816-gce089f498b
# then normalize it to semver format: v1.2.3+dev.205.gce089f498b
[ -z "$recent_tag" ] && recent_tag="$(git describe --always --tags)"
echo "Use recent tag $recent_tag to determine version and grade"
version_main="$(echo "$recent_tag" | cut -d'-' -f1)"
version_ext="$(echo "$recent_tag" | cut -d'-' -s -f2- | sed -e 'y/-/./')"
[ -n "$version_ext" ] && grade=devel || grade=stable
version="${version_main}"
[ -n "$version_ext" ] && version="${version}+${version_ext}"
craftctl set version="$version"
craftctl set grade="$grade"