summaryrefslogtreecommitdiff
path: root/hack/create-release-pr.sh
blob: 19dda338fec7fd3b3818ad3bd027de90264ba098 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

### This script creates a new release PR
# - install gh cli and semver-cli (go install github.com/davidrjonas/semver-cli@latest)
# - create and push "release-X.Y" branch
# - checkout this branch locally
# - run this script from repo root: ./hack/create-release-pr.sh
# - merge the PR
# It will trigger the release workflow that would create release draft on github

RELEASE_BRANCH="$(git rev-parse --abbrev-ref HEAD || true)"
set -eux
set -o pipefail

### look for latest on-branch tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match "*${RELEASE_BRANCH##release-}*" 2>/dev/null || true)

if [ -n "$PREVIOUS_TAG" ]; then
    NEW_VERSION=$(semver-cli inc patch $PREVIOUS_TAG)
else
    NEW_VERSION="${RELEASE_BRANCH##release-}.0"
fi

echo $NEW_VERSION > VERSION

IMAGE_TAG="v${NEW_VERSION}"
make manifests

git checkout -b "feat/new-version-${NEW_VERSION}"
git commit -m "Release ${NEW_VERSION}" VERSION manifests/
git push --set-upstream origin "feat/new-version-${NEW_VERSION}"
gh label --repo $(git remote get-url origin) create --force release
gh pr --repo $(git remote get-url origin) \
    create \
    --base ${RELEASE_BRANCH} \
    --title "Release ${NEW_VERSION}" \
    --body  "Release ${NEW_VERSION}" \
    --label release
git checkout -