Skip to content

Commit

Permalink
feat: document release process; bump go,node,python sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Dec 27, 2023
1 parent 75307f8 commit b6585ec
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 37 deletions.
Binary file added .github/images/release-engine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/release-sdk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Releasing

This describes the release process of the engine and SDKs.

## Overview

The release process is make up of two parts:

1. The release of the engine
2. The release of the SDKs

The engine is released first because the SDKs depend on the engine.

The entire process is made up of a series of GitHub Actions workflows that are triggered by a GitHub release.

We use [release-please](https://github.com/googleapis/release-please>) to generate the CHANGELOGs and create the GitHub releases and tags for each component (engine and each SDK).

Release Please supports this via a [monorepo](https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md) configuration where we can version and release each component independently.

## Release Process

### Engine

<p align="center">
<img src=".github/images/release-engine.png" width=600 />
</p>

1. Create a new release in the [flipt-engine](./flipt-engine) by merging a change to the `main` branch that would trigger a release via conventional commits.
2. Wait for the release-please workflow to complete. This will create a new release and tag for the engine.
3. The `package-engine` workflow will run, building the engine for each supported platform and publishing the artifacts to the GitHub release.

### SDKs

<p align="center">
<img src=".github/images/release-sdk.png" width=600 />
</p>

#### Single SDK

1. Create a new release in the SDK by merging a change to the `main` branch that would trigger a release via conventional commits for that SDK. This will create a new release and tag for the SDK.
2. To update the SDK to use the new engine, you'll need to trigger a change that release-please will pick up.
3. To do this, you can run the following command from the root of the repository:

```bash
./build/bump.sh <language|all>
```

Where `<language>` is the name of the SDK you want to trigger a change for.

```bash
./build/bump.sh ruby
```

4. Create a commit for the version you want to release: <https://github.com/googleapis/release-please#how-do-i-change-the-version-number>
5. Push the commit to the `main` branch.
6. Wait for the release-please workflow to complete. This will create a release PR for the SDK.
7. Merge the release PR for the SDK.
8. Release please will create a new release and tag for the SDK.
9. The `package-[name]-sdk` workflow will run, building the SDK for each supported platform and publishing the package to the supported package manager (e.g. RubyGems for Ruby).

#### All SDKs

1. Repeat step 3 above, but instead of passing a language, pass `all`.

```bash
./build/bump.sh all
```

2. Create a `feat` or `fix` commit depending on the type of change you want to release. See: [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
3. Push or merge the commit to the `main` branch.
4. Wait for the release-please workflow to complete. This will create a release PR, updating all of the SDKs appropriately.
5. Merge the release PR.
6. Release please will create a new release and tag for each SDK.
7. The `package-[name]-sdk` workflow will run, building the SDK for each supported platform and publishing the package to the supported package manager (e.g. RubyGems for Ruby).
81 changes: 44 additions & 37 deletions build/bump.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
#!/bin/bash

# This script updates the README.md file in a specified 'flipt-client-<name>' directory with the current UTC date and time on the first line.
# It optionally takes a semantic version number to commit the changes with a specific message format for release purposes.
# If a version is provided, it stages and commits the file with the message "chore: release as {version}" and "Release-As: {version}".
#
# Usage: ./bump.sh <name> [version]
# This script updates the README.md file in a specified 'flipt-client-<language>' directory with the current UTC date and time on the first line.
# Usage: ./bump.sh <language|all>
#
# This is used as a workaround for `release-please` to be able to create a release PR for the client libraries independently
# See: https://github.com/googleapis/release-please/issues/1905

if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
echo "Usage: ./bump.sh <name> [version]"
exit 1
fi

NAME=$1
DIRECTORY="flipt-client-$NAME"
FILE="$DIRECTORY/README.md"
DATE_COMMENT="<!-- Last updated: $(date -u) -->"
VERSION=$2 # Optional version argument

# Create the directory if it doesn't exist
mkdir -p "$DIRECTORY"
#!/bin/bash

# Function to prepend text to a file
prepend() {
Expand All @@ -34,28 +19,50 @@ prepend() {
mv "$temp_file" "$file"
}

# Check if the README.md exists
if [ -f "$FILE" ]; then
# Check if the first line contains the date stamp
if head -n 1 "$FILE" | grep -q "<!-- Last updated:"; then
# Replace the first line with the new date
tail -n +2 "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE"
prepend "$FILE" "$DATE_COMMENT"
# Function to update a single README.md file
update_readme() {
local directory=$1
local file="$directory/README.md"
local date_comment="<!-- Last updated: $(date -u) -->" # Using UTC date and time

# Create the directory if it doesn't exist
mkdir -p "$directory"

# Check if the README.md exists
if [ -f "$file" ]; then
# Check if the first line contains the date stamp
if head -n 1 "$file" | grep -q "<!-- Last updated:"; then
# Replace the first line with the new date
tail -n +2 "$file" > "$file.tmp" && mv "$file.tmp" "$file"
fi
else
# Prepend the date stamp if the first line doesn't contain it
prepend "$FILE" "$DATE_COMMENT"
# Touch the file to ensure it exists for the prepend operation
touch "$file"
fi
else
# Create README.md and write the date stamp if the file doesn't exist
echo "$DATE_COMMENT" > "$FILE"
fi

# Prepend the date stamp
prepend "$file" "$date_comment"

# Commit changes with a specific message format
if [ -n "$VERSION" ]; then
# Add the file to the staging area
git add "$FILE"
git commit -m "chore: release as $VERSION" -m "Release-As: $VERSION"
echo "Updated $file"
}

# Check the number of arguments provided
if [ "$#" -lt 1 ] ; then
echo "Usage: ./bump.sh <language|all>"
exit 1
fi

echo "Updated $FILE"
NAME=$1
VERSION=$2 # Optional version argument

if [ "$NAME" == "all" ]; then
# Loop through each directory starting with 'flipt-client-'
for directory in flipt-client-*/; do
if [ -d "$directory" ]; then
update_readme "$directory"
fi
done
else
DIRECTORY="flipt-client-$NAME"
update_readme "$DIRECTORY"
fi
1 change: 1 addition & 0 deletions flipt-client-go/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- Last updated: Wed Dec 27 19:41:34 UTC 2023 -->
# Flipt Client Go

The `flipt-client-go` directory contains the Go source code for the Flipt client-side flipt client.
Expand Down
1 change: 1 addition & 0 deletions flipt-client-node/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- Last updated: Wed Dec 27 19:41:34 UTC 2023 -->
# Flipt Client Node

[![npm](https://img.shields.io/npm/v/@flipt-io/flipt-client?label=%40flipt-io%2Fflipt-client)](https://www.npmjs.com/package/@flipt-io/flipt-client)
Expand Down
1 change: 1 addition & 0 deletions flipt-client-python/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- Last updated: Wed Dec 27 19:41:34 UTC 2023 -->
# Flipt Client Python

[![pypi](https://img.shields.io/pypi/v/flipt-client.svg)](https://pypi.org/project/flipt-client)
Expand Down

0 comments on commit b6585ec

Please sign in to comment.