Skip to content

Commit aa7923f

Browse files
committed
update readme and finalize script
Signed-off-by: Jordan Dubrick <[email protected]>
1 parent c951b62 commit aa7923f

File tree

2 files changed

+74
-34
lines changed

2 files changed

+74
-34
lines changed

release/README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Cutting New Releases
22

33
## Requirements
4-
<!--
5-
TODO: Make this more official and up to date
6-
-->
7-
- GitHub CLI (Insert Link Here)
8-
- User logged into CLI with write access to registry-support repo
4+
5+
- SSH key setup with GitHub
6+
- See [GitHub documentation](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) for more information
7+
- Write access to the [devfile/registry-support](https://github.com/devfile/registry-support) repository
98

109
## Process
1110
<!--
@@ -16,5 +15,40 @@ TODO: Update this process for the various ways to run the script
1615
2. Or "I want to cut version 2.1.0, which is a Minor release"
1716
2. Set the appropriate environment variables
1817
1. `VERSION`
18+
- In the form [Major].[Minor].[Patch]
1919
2. `RELEASE_TYPE`
20-
3. `RELEASE_CANDIDATE` - optional, defaults to `false` if unset
20+
- One of [major, minor, patch]
21+
3. `RELEASE_CANDIDATE`
22+
- Defaults to `false` if unset
23+
- Only applicable for `major` release types
24+
25+
## Examples
26+
27+
Major release v1.1.1
28+
```
29+
export VERISON=1.1.1
30+
export RELEASE_TYPE=major
31+
bash release.sh
32+
```
33+
34+
Major release v2.0.0 that is a release candidate
35+
```
36+
export VERSION=2.0.0
37+
export RELEASE_CANDIDATE=true
38+
export RELEASE_TYPE=major
39+
bash release.sh
40+
```
41+
42+
Minor release v2.1.0
43+
```
44+
export VERSION=2.1.0
45+
export RELEASE_TYPE=minor
46+
bash release.sh
47+
```
48+
49+
Patch release v2.1.1
50+
```
51+
export VERSION=2.1.1
52+
export RELEASE_TYPE=patch
53+
bash release.sh
54+
```

release/release.sh

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,45 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
fetch_push_prior_release () {
19+
git fetch $upstream_name --tags
20+
LATEST_TAG=$(git tag --sort=-v:refname | head -n 1)
21+
MODIFIED_TAG=$(echo "$LATEST_TAG" | awk -F. '{print $1 "." $2 ".x"}') # convert to [major].[minor].x format from [major].[minor].[patch]
22+
git branch release/$MODIFIED_TAG $LATEST_TAG
23+
git push $upstream_name release/$MODIFIED_TAG
24+
git branch -D release/$MODIFIED_TAG
25+
}
26+
27+
# append rc for release-candidate if necessary
28+
tag_and_push () {
29+
final_version="v$VERSION"
30+
if [ "$1" == "rc" ]; then
31+
final_version+="-rc"
32+
fi
33+
git tag $final_version
34+
git push $upstream_name $final_version
35+
}
36+
1837
TYPES=(
1938
"major"
2039
"minor"
40+
"patch"
2141
)
2242

2343
UPSTREAM="https://github.com/devfile/registry-support.git"
2444

25-
2645
# $VERSION has to be set by the user in [major].[minor].[patch] format
2746
if [ -z "${VERSION}" ]; then
2847
echo "Environment variable \$VERSION not set. Aborting ..."
2948
exit 1
3049
fi
3150

32-
# RELEASE_CANDIDATE should be set to true for major version release candidates
51+
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
52+
echo "Environment variable \$VERSION set to "$VERSION". Must be in [major].[minor].[patch] format ..."
53+
exit 1
54+
fi
55+
56+
# RELEASE_CANDIDATE should be set to true only for major version release candidates
3357
if [ -z "${RELEASE_CANDIDATE}" ]; then
3458
echo "Environment variable \$RELEASE_CANDIDATE not set. Defaulting to false ..."
3559
RELEASE_CANDIDATE=false
@@ -54,12 +78,9 @@ else
5478
fi
5579
fi
5680

57-
exit 0
58-
5981
# Set upstream repo tracking if not already set
6082
upstream_name=$(git remote -v | awk -v url="$UPSTREAM" '$2 == url {print $1; exit}')
6183

62-
# Setup upstream if not set
6384
if [ -n "$upstream_name" ]; then
6485
echo "Upstream repo found ... Name = $upstream_name, url=$UPSTREAM"
6586
else
@@ -69,30 +90,15 @@ else
6990
upstream_name="release-upstream"
7091
fi
7192

72-
7393
if [ "${RELEASE_TYPE}" == "major" ] && [ "${RELEASE_CANDIDATE}" == "true" ]; then
7494
# the release associated with this tag will be a pre-release, and we should be moving the code to a rc/<name> branch alongside the prev release
75-
echo "Major release and release-candidate"
76-
fetch_push_prior_commit
77-
git push $upstream_name $upstream_name/main:rc/$VERSION
78-
git tag $VERSION-rc
79-
git push $upstream_name $VERSION-rc
95+
fetch_push_prior_release
96+
git push $upstream_name $upstream_name/main:refs/heads/rc/$VERSION
97+
tag_and_push rc
98+
elif [ "${RELEASE_TYPE}" == "patch" ]; then
99+
tag_and_push
80100
else
81101
# major/minor normal workflow
82-
echo "Major or Minor release"
83-
fetch_push_prior_commit
84-
# Create new tag in upstream
85-
git tag $VERSION
86-
git push $upstream_name $VERSION
87-
fi
88-
89-
fetch_push_prior_commit () {
90-
git fetch $upstream_name --tags
91-
LATEST_TAG=$(git tag --sort=-v:refname | head -n 1)
92-
MODIFIED_TAG=$(echo "$LATEST_TAG" | awk -F. '{print $1 "." $2 ".x"}') # convert to [major].[minor].x format from [major].[minor].[patch]
93-
git checkout -b test-fetch-tag $LATEST_TAG #TODO: fix the test-fetch-tag to something better
94-
git push $upstream_name release/$MODIFIED_TAG
95-
96-
# navigate back to main
97-
git checkout main
98-
}
102+
fetch_push_prior_release
103+
tag_and_push
104+
fi

0 commit comments

Comments
 (0)