mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(release): version a pull request like a nightly of its base branch
- a pull request into next took the preview version in release.json, which still names 4.6.0-beta.1 once 4.6.0 is released, so its image sorted before 4.6.0
This commit is contained in:
+5
-2
@@ -132,7 +132,7 @@ The nightly workflow publishes a nightly twice a day when its branch has a new c
|
||||
| after 5.1.0 | `5.2.0-alpha.0.20261016.1` |
|
||||
|
||||
- It comes from `next`, or from the lowest release branch while one is in progress: `release/v5.1` takes it over once it is cut and hands it back once `5.1.0` is released
|
||||
- The base is the prerelease `preview` of that branch sets in `release.json`, else its next version with `-alpha.0`, which is never released
|
||||
- The base is the `preview` version of that branch in `release.json` while it is ahead of the newest stable version, a plain one with `-alpha.0`. Otherwise it is the next version with `-alpha.0`, which is never released. A pull request takes the same base
|
||||
- N counts up per day and base
|
||||
- No git tag and no GitHub release, only its image tag, the moving `nightly` tag and the nightly channel of the CDN
|
||||
|
||||
@@ -148,8 +148,11 @@ Print what the next run builds with `scripts/plan-version.sh --main`.
|
||||
|
||||
## Pull requests
|
||||
|
||||
Every push to a pull request from a branch of this repository publishes `ghcr.io/coollabsio/coolify:pr-<number>`, versioned `<version of the base branch>-pr.<number>`. Pull request 1234 into `next` is `pr-1234` with the version `4.6.0-beta.1-pr.1234`, which sorts after `4.6.0-beta.1` and its nightlies and before `4.6.0-beta.2`.
|
||||
The pull request workflow builds every pull request and publishes the image of a pull request from a branch of this repository as `ghcr.io/coollabsio/coolify:pr-<number>`. Its version is `<base>-pr.<number>`, with the base a nightly of its base branch takes, or the stable version for `main`:
|
||||
|
||||
- Into `next`: `4.6.0-beta.1-pr.1234` after `4.6.0-beta.1`, or `4.7.0-alpha.0-pr.1234` before the first alpha of 4.7.0
|
||||
- Into `main`: `4.5.3-pr.1234`
|
||||
- PHP's `version_compare` sorts it after its base and the nightlies of the base and before the next prerelease or release, so an instance on it updates to the release that ships it
|
||||
- Pull requests from forks and Dependabot are built, not published
|
||||
- A push to a pull request from `main`, `next`, a release branch or a patch branch that changes `release.json` is not built, the release workflow builds it
|
||||
- Pull request builds are published to ghcr.io only, as the Docker Hub credentials are in the `release` environment, which no pull request run can use
|
||||
|
||||
+40
-19
@@ -28,6 +28,7 @@ cd "$(dirname "$0")/.."
|
||||
main() {
|
||||
[[ "$OPTION" =~ ^(--build|--release|--tags|--nightly|--main)?$ ]] || die "'$OPTION' is not an option, expected --build, --release, --tags, --nightly, --main or none"
|
||||
read_version
|
||||
print_build_version
|
||||
fetch_origin
|
||||
print_tags
|
||||
print_next_build
|
||||
@@ -45,10 +46,21 @@ read_version() {
|
||||
[[ ! "$branch" =~ ^(next|release/v[0-9]+\.[0-9]+)$ ]] || channel=preview
|
||||
version="$(artifact_version "$channel")"
|
||||
[ -n "$version" ] || die "$VERSION_FILE has no $channel version of $ARTIFACT"
|
||||
if [ "$OPTION" = --build ]; then
|
||||
echo "$version${PULL_REQUEST:+-pr.$PULL_REQUEST}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
print_build_version() {
|
||||
[ "$OPTION" = --build ] || return 0
|
||||
if [ -n "$PULL_REQUEST" ] && [ "$channel" = preview ]; then
|
||||
tags="$(git ls-remote --tags --refs origin | sed 's|.*refs/tags/||' | filter_release_tags | sort -V)" || die "could not list the tags of origin"
|
||||
line="${branch#release/v}"
|
||||
[ "$line" != "$branch" ] || line=""
|
||||
revision=HEAD
|
||||
select_newest_stable
|
||||
select_preview_base
|
||||
version="$base"
|
||||
fi
|
||||
echo "$version${PULL_REQUEST:+-pr.$PULL_REQUEST}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
fetch_origin() {
|
||||
@@ -87,7 +99,7 @@ print_next_build() {
|
||||
base="$(artifact_version stable <(git show "$revision:$VERSION_FILE" 2> /dev/null))"
|
||||
[ -n "$base" ] || die "main has no stable version of $ARTIFACT in $VERSION_FILE, expected the release process there"
|
||||
else
|
||||
select_nightly_base
|
||||
select_preview_base
|
||||
fi
|
||||
[ -z "$UPSTREAM" ] || current_version="${current_version#*-v}"
|
||||
build="$base.$(date -u +%Y%m%d)"
|
||||
@@ -103,8 +115,7 @@ print_next_build() {
|
||||
}
|
||||
|
||||
select_nightly_branch() {
|
||||
stable="$(tag_versions <<< "$tags" | awk '!/-/' | newest)"
|
||||
stable="${stable:-$(artifact_version stable)}"
|
||||
select_newest_stable
|
||||
line="$(git for-each-ref --format='%(refname:lstrip=4)' 'refs/remotes/origin/release/v*' | sed -n 's/^v\([0-9]*\.[0-9]*\)$/\1/p' | sort -V \
|
||||
| while read -r release; do ! newer "$release.0" "$stable" || { echo "$release" && break; }; done)"
|
||||
branch="${line:+release/v$line}"
|
||||
@@ -112,18 +123,6 @@ select_nightly_branch() {
|
||||
revision="$(git rev-parse "origin/$branch")"
|
||||
}
|
||||
|
||||
select_nightly_base() {
|
||||
version="$(artifact_version preview <(git show "$revision:$VERSION_FILE"))"
|
||||
if [ -n "$line" ]; then
|
||||
base="$line.0-alpha.0"
|
||||
[[ "$version" != "$line.0-"* ]] || base="$version"
|
||||
elif [[ "$version" == *-* ]] && newer "$version" "$stable"; then
|
||||
base="$version"
|
||||
else
|
||||
base="$(next_version "$stable" minor)-alpha.0"
|
||||
fi
|
||||
}
|
||||
|
||||
check_branch() {
|
||||
[[ "$branch" =~ ^(main|next|v([0-9]+(\.[0-9]+)?)\.x|release/v([0-9]+\.[0-9]+))$ ]] || die "${branch:-a detached HEAD} releases nothing"
|
||||
line="${BASH_REMATCH[2]}${BASH_REMATCH[4]}"
|
||||
@@ -233,6 +232,24 @@ print_releases() {
|
||||
jq -sc . <<< "$releases"
|
||||
}
|
||||
|
||||
select_newest_stable() {
|
||||
stable="$(tag_versions <<< "$tags" | awk '!/-/' | newest)"
|
||||
stable="${stable:-$(artifact_version stable)}"
|
||||
}
|
||||
|
||||
select_preview_base() {
|
||||
version="$(artifact_version preview <(git show "$revision:$VERSION_FILE"))"
|
||||
if [ -n "$line" ]; then
|
||||
base="$line.0-alpha.0"
|
||||
[[ "$version" != "$line.0-"* ]] || base="$version"
|
||||
elif newer "$version" "$stable"; then
|
||||
base="$version"
|
||||
[[ "$version" == *-* ]] || base="$version-alpha.0"
|
||||
else
|
||||
base="$(next_version "$stable" minor)-alpha.0"
|
||||
fi
|
||||
}
|
||||
|
||||
artifact_version() {
|
||||
jq -r --arg channel "$1" --arg artifact "$ARTIFACT" '.[$channel][$artifact] // empty' "${2:-$VERSION_FILE}"
|
||||
}
|
||||
@@ -313,7 +330,11 @@ moving_tags() {
|
||||
}
|
||||
|
||||
release_tags() {
|
||||
git tag --list "$@" | grep -E "^v${UPSTREAM:+[^-]+-v}[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?$" || true
|
||||
git tag --list "$@" | filter_release_tags
|
||||
}
|
||||
|
||||
filter_release_tags() {
|
||||
grep -E "^v${UPSTREAM:+[^-]+-v}[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?$" || true
|
||||
}
|
||||
|
||||
tag_versions() {
|
||||
|
||||
Reference in New Issue
Block a user