Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

rename RELEASE.sh to make-release.sh for... #187

Merged
merged 2 commits into from
Jan 29, 2020
Merged
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
32 changes: 18 additions & 14 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Below are the steps needed to do a release. But rather than doing them by hand, you can run this script:

https://github.com/eclipse/che-devfile-registry/blob/master/RELEASE.sh
https://github.com/eclipse/che-devfile-registry/blob/master/make-release.sh

HOWEVER, because the master branch is protected from commits, the above script will not be able to commit an update to the VERSION file. Instead it must produce a PR.

Expand All @@ -13,32 +13,36 @@ To github.com:eclipse/che-devfile-registry
! [remote rejected] master -> master (protected branch hook declined)
```

l- create a branch for the release e.g. `7.6.x`
- provide a [PR](https://github.com/eclipse/che-devfile-registry/pull/171) with bumping the [VERSION](https://github.com/eclipse/che-devfile-registry/blob/master/VERSION) file to the `7.6.x` branch
- [![Release Build Status](https://ci.centos.org/buildStatus/icon?subject=release&job=devtools-che-devfile-registry-release/)](https://ci.centos.org/job/devtools-che-devfile-registry-release/) CI is triggered based on the changes in the [`release`](https://github.com/eclipse/che-devfile-registry/tree/release) branch (not `7.6.x`).
- create a branch for the release e.g. `7.8.x`
- provide a [PR](https://github.com/eclipse/che-devfile-registry/pull/171) with bumping the [VERSION](https://github.com/eclipse/che-devfile-registry/blob/master/VERSION) file to the `7.8.x` branch
- [![Release Build Status](https://ci.centos.org/buildStatus/icon?subject=release&job=devtools-che-devfile-registry-release/)](https://ci.centos.org/job/devtools-che-devfile-registry-release/) CI is triggered based on the changes in the [`release`](https://github.com/eclipse/che-devfile-registry/tree/release) branch (not `7.8.x`).

In order to trigger the CI once the [PR](https://github.com/eclipse/che-devfile-registry/pull/171) is merged to the `7.6.x` one needs to:
In order to trigger the CI once the [PR](https://github.com/eclipse/che-devfile-registry/pull/171) is merged to the `7.8.x` one needs to:

```
git fetch origin 7.6.x:7.6.x
git checkout 7.6.x
git fetch origin 7.8.x:7.8.x
git checkout 7.8.x
git branch release -f
git push origin release -f
```

CI will build an image from the [`release`](https://github.com/eclipse/che-devfile-registry/tree/release) branch and push it to [quay.io](https://quay.io/organization/eclipse) e.g [quay.io/eclipse/che-devfile-registry:7.6.0](https://quay.io/repository/eclipse/che-devfile-registry?tab=tags&tag=7.6.0)
[CI](https://ci.centos.org/job/devtools-che-devfile-registry-release/) will build an image from the [`release`](https://github.com/eclipse/che-devfile-registry/tree/release) branch and push it to [quay.io](https://quay.io/organization/eclipse) e.g [quay.io/eclipse/che-devfile-registry:7.8.0](https://quay.io/repository/eclipse/che-devfile-registry?tab=tags&tag=7.8.0)

The last thing is the tag `7.6.0` creation from the `7.6.x` branch
The last thing is the tag `7.8.0` creation from the `7.8.x` branch

```
git checkout 7.6.x
git tag 7.6.0
git push origin 7.6.0
git checkout 7.8.x
git tag 7.8.0
git push origin 7.8.0
```

After the release, the `VERSION` file should be bumped in the master e.g. [`7.7.0-SNAPSHOT`](https://github.com/eclipse/che-devfile-registry/pull/172)
After the release, the `VERSION` file should be bumped in the master branch, e.g. to `7.9.0-SNAPSHOT`.

## Service / Bugfix Release

The release process is very similar to the Major / Minor one, just the existing branch should be used for the `VERSION` file bump e.g. `7.3.x` branch for `7.3.3` release - [PR](https://github.com/eclipse/che-devfile-registry/pull/156) example.
The release process is the same as for the Major / Minor one, but the values passed to the `make-release.sh` script will differ so that work is done in the existing 7.7.x branch.

```
./make-release.sh --repo git@github.com:eclipse/che-devfile-registry --version 7.7.1 --trigger-release
```

59 changes: 36 additions & 23 deletions RELEASE.sh → make-release.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/bin/bash
# Release process automation script.
# Used to create branch/tag, update VERSION files and and trigger release by force pushing changes to the release branch
# Used to create branch/tag, update VERSION files
# and and trigger release by force pushing changes to the release branch

# set to 1 to actually trigger changes in the release branch
TRIGGER_RELEASE=0
NOCOMMIT=0

while [[ "$#" -gt 0 ]]; do
case $1 in
'-t'|'--trigger-release') TRIGGER_RELEASE=1; shift 0;;
'-t'|'--trigger-release') TRIGGER_RELEASE=1; NOCOMMIT=0; shift 0;;
'-r'|'--repo') REPO="$2"; shift 1;;
'-v'|'--version') VERSION="$2"; shift 1;;
'-n'|'--no-commit') NOCOMMIT=1; TRIGGER_RELEASE=0; shift 0;;
esac
shift 1
done
Expand Down Expand Up @@ -53,11 +56,16 @@ if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
git checkout "${BRANCH}"
fi

# change VERSION file + commit change into .x branch
# change VERSION file
echo "${VERSION}" > VERSION
git commit -s -m "[release] Bump to ${VERSION} in ${BRANCH}" VERSION
git pull origin "${BRANCH}"
git push origin "${BRANCH}"

# commit change into branch
if [[ ${NOCOMMIT} -eq 0 ]]; then
COMMIT_MSG="[release] Bump to ${VERSION} in ${BRANCH}"
git commit -s -m "${COMMIT_MSG}" VERSION
git pull origin "${BRANCH}"
git push origin "${BRANCH}"
fi

if [[ $TRIGGER_RELEASE -eq 1 ]]; then
# push new branch to release branch to trigger CI build
Expand Down Expand Up @@ -86,26 +94,31 @@ else
[[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]] && BASE="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"; NEXT="${BASH_REMATCH[3]}"; (( NEXT=NEXT+1 )) # for VERSION=7.7.1, get BASE=7.7, NEXT=2
NEXTVERSION="${BASE}.${NEXT}-SNAPSHOT"
fi

# change VERSION file
echo "${NEXTVERSION}" > VERSION
BRANCH=${BASEBRANCH}
COMMIT_MSG="[release] Bump to ${NEXTVERSION} in ${BRANCH}"
git commit -s -m "${COMMIT_MSG}" VERSION
git pull origin "${BRANCH}"

PUSH_TRY="$(git push origin "${BRANCH}")"
# shellcheck disable=SC2181
if [[ $? -gt 0 ]] || [[ $PUSH_TRY == *"protected branch hook declined"* ]]; then
PR_BRANCH=pr-master-to-${NEXTVERSION}
# create pull request for master branch, as branch is restricted
git branch "${PR_BRANCH}"
git checkout "${PR_BRANCH}"
git pull origin "${PR_BRANCH}"
git push origin "${PR_BRANCH}"
lastCommitComment="$(git log -1 --pretty=%B)"
hub pull-request -o -f -m "${lastCommitComment}
if [[ ${NOCOMMIT} -eq 0 ]]; then
BRANCH=${BASEBRANCH}
# commit change into branch
COMMIT_MSG="[release] Bump to ${NEXTVERSION} in ${BRANCH}"
git commit -s -m "${COMMIT_MSG}" VERSION
git pull origin "${BRANCH}"

PUSH_TRY="$(git push origin "${BRANCH}")"
# shellcheck disable=SC2181
if [[ $? -gt 0 ]] || [[ $PUSH_TRY == *"protected branch hook declined"* ]]; then
PR_BRANCH=pr-master-to-${NEXTVERSION}
# create pull request for master branch, as branch is restricted
git branch "${PR_BRANCH}"
git checkout "${PR_BRANCH}"
git pull origin "${PR_BRANCH}"
git push origin "${PR_BRANCH}"
lastCommitComment="$(git log -1 --pretty=%B)"
hub pull-request -o -f -m "${lastCommitComment}

${lastCommitComment}" -b "${BRANCH}" -h "${PR_BRANCH}"
fi
fi
fi

# cleanup tmp dir
cd /tmp && rm -fr "$TMP"
Expand Down