Skip to content

Commit e9d01b0

Browse files
authored
Merge pull request #57 from robobario/release-workflow
Add release workflow
2 parents 3c9cf47 + 9979d94 commit e9d01b0

File tree

5 files changed

+138
-7
lines changed

5 files changed

+138
-7
lines changed

.github/scripts/setVersions.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# usage: setVersions.sh pomVersion
3+
4+
if [[ $# != 1 ]]; then
5+
echo "Illegal number of parameters" >&2
6+
exit 1
7+
fi
8+
mvn -B versions:set -DgenerateBackupPoms=false -DnewVersion=${1}
9+
sed --in-place --regexp-extended "s|flink-sql-runner-dist-([^[:space:]]*)\.tar.gz|flink-sql-runner-dist-${1}.tar.gz|g" Dockerfile

.github/workflows/integration.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: Build
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main", "releases-**" ]
6+
tags: [ "[0-9]+.[0-9]+.[0-9]+" ]
67
pull_request:
78
types: [ opened, synchronize, reopened ]
89

@@ -35,7 +36,7 @@ jobs:
3536
run: mvn -B clean verify -Pcoverage
3637

3738
- name: Test Image Build
38-
if: github.ref_name != 'main'
39+
if: github.event_name == 'pull_request'
3940
uses: docker/build-push-action@v6
4041
with:
4142
context: .
@@ -44,23 +45,30 @@ jobs:
4445
file: Dockerfile
4546

4647
- name: Login to Quay
47-
if: github.event_name == 'push' && github.ref_name == 'main'
48+
if: github.event_name == 'push'
4849
uses: docker/login-action@v3
4950
with:
5051
registry: "${{ secrets.IMAGE_REPO_HOSTNAME }}"
5152
username: "${{ secrets.IMAGE_REPO_USERNAME }}"
5253
password: "${{ secrets.IMAGE_REPO_PASSWORD }}"
5354

5455
- name: Image metadata
55-
if: github.event_name == 'push' && github.ref_name == 'main'
56+
if: github.event_name == 'push'
5657
id: meta
5758
uses: docker/metadata-action@v5
5859
with:
5960
images: |
60-
quay.io/streamshub/flink-sql-runner
61+
${{ secrets.IMAGE_REPO_HOSTNAME }}/${{ secrets.IMAGE_REPO_NAMESPACE }}/flink-sql-runner
62+
tags: |
63+
type=ref,event=branch
64+
type=ref,event=tag
65+
flavor: |
66+
latest=false
67+
prefix=
68+
suffix=
6169
6270
- name: Build and Push Image
63-
if: github.event_name == 'push' && github.ref_name == 'main'
71+
if: github.event_name == 'push'
6472
uses: docker/build-push-action@v6
6573
with:
6674
context: .
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Create Release Transition PR
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
description: 'Branch to transition'
7+
required: false
8+
default: 'main'
9+
newVersion:
10+
description: 'New Version'
11+
required: true
12+
default: '0.0.1-SNAPSHOT'
13+
transition:
14+
type: choice
15+
description: Choose
16+
options:
17+
- DEVELOPMENT_TO_RELEASE
18+
- RELEASE_TO_DEVELOPMENT
19+
jobs:
20+
create-transition-pr:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ github.event.inputs.branch }}
27+
- name: Set up Java
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '17'
31+
distribution: 'temurin'
32+
cache: maven
33+
- name: Update Sources
34+
run: |
35+
.github/scripts/setVersions.sh "${{ github.event.inputs.newVersion }}"
36+
- name: Test maven build
37+
run: mvn -B clean verify
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
- name: Set up Docker Buildx
41+
id: buildx
42+
uses: docker/setup-buildx-action@v3
43+
- name: Test Build Image
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: .
47+
platforms: linux/amd64,linux/arm64
48+
push: false
49+
file: Dockerfile
50+
- name: Create Pull Request
51+
uses: peter-evans/create-pull-request@v7
52+
with:
53+
# use token so that the created PR will trigger other actions, default GITHUB_TOKEN does not do this
54+
token: ${{ secrets.RELEASE_TOKEN }}
55+
commit-message: "Update to ${{ github.event.inputs.newVersion }}"
56+
branch: "release-transition-${{ github.event.inputs.branch }}-${{ github.event.inputs.newVersion }}"
57+
signoff: true
58+
title: "Release Transition ${{ github.event.inputs.branch }} from ${{ github.event.inputs.transition }}: ${{github.event.inputs.newVersion}}"
59+
body: "Release Transition ${{ github.event.inputs.branch }} from ${{ github.event.inputs.transition }}: ${{github.event.inputs.newVersion}}"
60+
labels: release

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@ We welcome your contributions to the Flink SQL project! To ensure a smooth colla
5252
* **Build Success**: Make sure the build passes without errors.
5353
* **Code Quality**: Your code must pass SonarCloud code analysis checks.
5454
* **Unit Tests**: Update existing unit tests for any modifications and write new tests for new features.
55-
* **System Tests**: Repository developers can trigger [Packit CI](tmt/README.md/#packit-as-a-service-for-pr-check) for running system tests.
55+
* **System Tests**: Repository developers can trigger [Packit CI](tmt/README.md/#packit-as-a-service-for-pr-check) for running system tests.
56+
57+
## Releasing
58+
59+
Follow the [Releasing](RELEASING.md) guide.

RELEASING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Releasing
2+
3+
Currently the only external artefact for a release is the SQL runner image in quay.io.
4+
5+
The automation builds and pushes images to quay on push to:
6+
1. main (image will be tagged as main eg quay.io/streamshub/flink-sql-runner:main )
7+
2. branches named release-** (image will be tagged as branch name eg release-0.0 will be tagged at quay.io/streamshub/flink-sql-runner:release-0.0)
8+
3. semver-like tag push (image will be tagged with the git tag, for example git tag 0.0.1 -> quay.io/streamshub/flink-sql-runner:0.0.1)
9+
10+
For the branches targeted above we can use github Actions to transition them between two states:
11+
12+
1. Snapshot, where the maven versions are SNAPSHOT and the image references in the deployments use the branch name as image tag.
13+
2. Release, where the maven version are non-SNAPSHOT and the image references in the deployments point at a tagged image.
14+
15+
## Prerequisites
16+
You must have permissions to execute manual GitHub Actions workflows and the ability to push tags to this repository
17+
18+
The repository must have a `RELEASE_PAT` secret containing a non-expired GitHub Personal Access Token with write permissions for this repositories contents and PRs.
19+
20+
## To Release a Branch that is in Development
21+
22+
1. Run the [Create Release Transition PR workflow](https://github.com/streamshub/flink-sql/actions/workflows/release-transition.yaml) setting:
23+
- Branch to transition: the branch you want to release (typically main)
24+
- New Version: if your development branch is on 0.0.1-SNAPSHOT in the maven projects, you would set this to 0.0.1
25+
- Choose: `DEVELOPMENT_TO_RELEASE`
26+
2. This will create a PR. After CI has run against this PR, review, approve and merge it.
27+
3. Fetch the branch changes locally and tag the merge commit as `${version}`. So if you are releasing `0.0.1`, run `git tag -a 0.0.1 -m 0.0.1` and push the tag up.
28+
4. This tag push will trigger [integration.yaml](https://github.com/streamshub/flink-sql/actions/workflows/integration.yaml) to push a `0.0.1` tagged image to quay.io,
29+
matching the references in the deployment YAML that were set in the transition PR.
30+
31+
## To Transition a Branch back to Development after Release
32+
33+
1. Run the [Create Release Transition PR workflow](https://github.com/streamshub/flink-sql/actions/workflows/release-transition.yaml) setting:
34+
- Branch to transition: the branch you want to release (typically main)
35+
- New Version: the next development version, so if you released 0.0.1 this might now be 0.0.2-SNAPSHOT
36+
- Choose: `RELEASE_TO_DEVELOPMENT`
37+
2. This will create a PR. After CI has run against this PR, review, approve and merge it.
38+
3. The branch will now have the pom versions set to your new version (like 0.0.2-SNAPSHOT)
39+
40+
## Working with Backports/Bugfixes
41+
42+
If we ever needed to release an older version for some reason (like we wanted to put out a bugfixed 0.0.2 but main has moved far ahead)
43+
44+
1. Branch off the tag you want to work from, the release branch name must start with `release-`. So if we discovered a bug in 0.0.1 and wanted
45+
to release a new 0.0.2 containing the bugfix, we could run `git branch -b release-0.0.2 0.0.1` and push `release-0.0.2` to github.
46+
2. Transition the new `release-0.0.2` branch to Development following the process above, setting the branch to `release-0.0.2` in the action
47+
and the new version to 1.0.2-SNAPSHOT
48+
3. Make code changes
49+
4. Release the branch following the process above, setting the branch to `release-0.0.2` in the action and new version `0.0.2`
50+
5. As above, tag the latest commit in `release-0.0.2` as `0.0.2` and push it up. The automation will produce an image tagged 0.0.2 in quay.io

0 commit comments

Comments
 (0)