Skip to content

Commit

Permalink
Update the release process:
Browse files Browse the repository at this point in the history
* Moved the variables with version in a separate json file, so it's easy to automate changes on it.
* Add scripts to update variables and schemas
* Fix the docker image building
  • Loading branch information
slinkydeveloper committed Oct 16, 2023
1 parent 41cb86e commit 9a832bf
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 29 deletions.
32 changes: 32 additions & 0 deletions .github/actions/install-protoc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Install protoc"
description: "Installs protoc for the given os"
inputs:
protoc-version:
description: "protoc version"
required: false
default: "21.12"
runs:
using: "composite"
steps:
- name: Install protoc for ${{ runner.os }}
env:
LINK: https://github.com/protocolbuffers/protobuf/releases/download
PROTOC_VERSION: ${{ inputs.protoc-version }}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
PROTOC_ZIP=protoc-$PROTOC_VERSION-linux-x86_64.zip
elif [ "$RUNNER_OS" == "macOS" ]; then
PROTOC_ZIP=protoc-$PROTOC_VERSION-osx-x86_64.zip
else
echo "$RUNNER_OS not supported"
exit 1
fi
curl -OL $LINK/v$PROTOC_VERSION/$PROTOC_ZIP
unzip -o $PROTOC_ZIP -d $HOME/.local bin/protoc
unzip -o $PROTOC_ZIP -d $HOME/.local 'include/*'
rm -f $PROTOC_ZIP
echo "$HOME/.local" >> $GITHUB_PATH
chmod +x $HOME/.local/bin/protoc
echo "PROTOC=$HOME/.local/bin/protoc" >> $GITHUB_ENV
echo "PROTOC_INCLUDE=$HOME/.local/include" >> $GITHUB_ENV
shell: bash
65 changes: 60 additions & 5 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
name: Build docker image
name: Build Docker image

on:
workflow_call:
workflow_dispatch:

env:
REGISTRY: 'ghcr.io'
REPOSITORY: ${{ github.repository_owner }}
REGISTRY_USERNAME: ${{ github.actor }}
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-docker-image:
name: Build docker image
uses: restatedev/restate/.github/workflows/docker.yml@main
secrets: inherit
build-and-push-image:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Setup caching
- name: Set up QEMU dependency
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USERNAME }}
password: ${{ env.REGISTRY_TOKEN }}

- name: Extract image name
# Set repository name as image name
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}
# Note: We need this to generate the latest tag until we have a first stable release.
# Check https://github.com/docker/metadata-action/issues/34
flavor: |
latest=true
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Build and Push Docker image
id: build
uses: docker/build-push-action@v3
with:
context: .
file: "docker/Dockerfile"
push: true
tags: ${{ steps.meta.outputs.tags }}
load: false
labels: ${{ steps.meta.outputs.labels }}
platforms: "linux/arm64,linux/amd64"
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
79 changes: 79 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Pre-release updates

on:
workflow_dispatch:
restateVersion:
description: 'Restate version (without prepending v). The Restate repository must have the tag already!'
required: true
type: string
sdkTypescriptVersion:
description: 'sdk-typescript version (without prepending v).'
required: true
type: string
tourVersion:
description: 'tour version (without prepending v).'
required: true
type: string

jobs:
updates:
runs-on: ubuntu-latest
timeout-minutes: 45

steps:
- name: Checkout documentation
uses: actions/checkout@v3

- name: Checkout Restate
uses: actions/checkout@v3
with:
repository: restatedev/restate
ref: v${{ inputs.restateVersion }}
token: ${{ secrets.E2E_CONTENTS_READ_TOKEN }}
path: temp-restate

# We need rust, protoc and just to compile the runtime to generate the docs
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install protoc
uses: ./.github/actions/install-protoc
- name: Setup just
uses: extractions/setup-just@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Update the doc config file
- name: Update restate.config.json with new runtime version
uses: jossef/[email protected]
with:
file: restate.config.json
field: RESTATE_DIST_VERSION
value: ${{ inputs.restateVersion }}
- name: Update restate.config.json with new sdk version
uses: jossef/[email protected]
with:
file: restate.config.json
field: TYPESCRIPT_SDK_VERSION
value: ${{ inputs.sdkTypescriptVersion }}
- name: Update restate.config.json with new tour version
uses: jossef/[email protected]
with:
file: restate.config.json
field: TOUR_VERSION
value: ${{ inputs.tourVersion }}

- name: Run the runtime generate script
run: |
./tools/generate.sh temp-restate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: "[GithubActions] Update Restate '${{ inputs.restateVersion }}' SDK-Typescript '${{ inputs.sdkTypescriptVersion }}' Tour '${{ inputs.tourVersion }}'"
commit-message: "[GithubActions] Update Restate '${{ inputs.restateVersion }}' SDK-Typescript '${{ inputs.sdkTypescriptVersion }}' Tour '${{ inputs.tourVersion }}'"
add-paths: |
restate.config.json
static/schemas/*
docs/references/*
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create new release
name: Release on tag

on:
push:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/trigger-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Trigger release

on:
workflow_dispatch:
version:
description: 'Documentation version (without prepending v).'
required: true
type: string

jobs:
sync-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: production

- name: Merge main -> production and tag it
run: |
git --version
git config user.name github-actions
git config user.email [email protected]
git merge main
git tag v${{ inputs.version }}
git push --follow-tags
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# Restate documentation

This repository contains Restate's documentation.
This repository contains Restate's documentation: https://docs.restate.dev/

In order to serve the documentation under `localhost:3000` you can run the documentation container image:
## Offline use

You can read the Restate documentation offline by downloading the docker image:

```shell
docker run --rm -p 3000:80 ghcr.io/restatedev/documentation:latest
```

This will serve the documentation under `localhost:3000`.

> **Note**
> Make sure that you have access to Github's container registry by [following these instructions](https://github.com/restatedev/restate-dist#container-registry).
You can also check this repository out and build the documentation yourself by following the instructions below.

## Building the documentation
## Developing the documentation

The documentation is built using [Docusaurus 2](https://docusaurus.io/).

Expand All @@ -39,13 +43,21 @@ $ yarn build

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Staging area

The `main` branch of the documentation is continuously deployed at `https://main--docsrestatedev.netlify.app`.

## Releasing the documentation

In order to release the documentation you have to push a tag of the form `vX.Y.Z`.
This will trigger the [release workflow](.github/workflows/release.yml), which builds and publishes and new `restatedev/documentation:vX.Y.Z` container image.
Moreover, it will create a draft [release on Github](https://github.com/restatedev/documentation/releases) that needs manual approval.
Before releasing the documentation, update schemas and version of Restate artifacts, either:

* Automatically by executing the _Pre-release updates_ workflow.
* Manually, as described below.

### Updating the schemas
Once the branch `main` is ready to be released, execute the _Trigger release_ workflow. This will merge `main` into `production` and add a tag.
The `tag` triggers the build of the new `restatedev/documentation:vX.Y.Z` container image and creates a draft [release on Github](https://github.com/restatedev/documentation/releases) that needs manual approval.

### Manually update the schemas

To update the configuration schemas, the default configuration and the Meta OpenAPI document,
clone [Restate](https://github.com/restatedev/restate/) and execute the following:
Expand All @@ -54,14 +66,10 @@ clone [Restate](https://github.com/restatedev/restate/) and execute the followin
$ ./tools/generate.sh <PATH to Restate repo clone>
```

### Upgrading Typescript SDK version

Update the `TYPESCRIPT_SDK_VERSION` value in `docusaurus.config.js`

### Upgrading Restate runtime version

Update the `RESTATE_DIST_VERSION` value in `docusaurus.config.js`
### Manually update artifact versions

### Upgrading Tour version
The config file `restate.config.json` contains versions of various Restate artifacts:

Update the `TOUR_VERSION` value in `docusaurus.config.js`
* Typescript SDK: `TYPESCRIPT_SDK_VERSION`
* Runtime: `RESTATE_DIST_VERSION`
* Tour: `TOUR_VERSION`
2 changes: 1 addition & 1 deletion docs/tour.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This guide is written for:
### Setting up the tutorial
Clone the GitHub repository of the [tutorial](https://github.com/restatedev/tour-of-restate-typescript):
```shell
git clone --depth 1 --branch VAR::TOUR_VERSION [email protected]:restatedev/tour-of-restate-typescript.git
git clone --depth 1 --branch vVAR::TOUR_VERSION [email protected]:restatedev/tour-of-restate-typescript.git
```

This GitHub repository contains the basic skeleton of the NodeJS/Typescript services that you develop in this tutorial.
Expand Down
7 changes: 2 additions & 5 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const variableInjector = require('./src/plugins/variable-injector')
const variablesReplacements = require('./restate.config.json');

const redocusaurus = [
'redocusaurus',
Expand Down Expand Up @@ -56,11 +57,7 @@ const config = {
[
variableInjector, // replaces eg VAR::RESTATE_DIST_VERSION with config strings
{
replacements: {
RESTATE_DIST_VERSION: '0.3.0',
TYPESCRIPT_SDK_VERSION: '0.3.1',
TOUR_VERSION: 'v0.3.2',
},
replacements: variablesReplacements,
}
]
],
Expand Down
5 changes: 5 additions & 0 deletions restate.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"RESTATE_DIST_VERSION": "0.3.0",
"TYPESCRIPT_SDK_VERSION": "0.3.1",
"TOUR_VERSION": "0.3.2"
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This file is not used in compilation. It is here just for a nice editor experience.
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
"baseUrl": "."
"baseUrl": ".",
"resolveJsonModule": true
}
}

0 comments on commit 9a832bf

Please sign in to comment.