Skip to content

Commit bcc14fe

Browse files
authored
Release workflow (#88)
* Release workflow Closes #72 This change proposes to start using semver from the get-go. This means the `edge` particle would go last, so we'd start with `0.0.1-edge`. The charts' `version` and `appVersion` entries would match that, with `version` being able to drift when chart-only changes happen (I added details into the `RELEASE.md` file). After multiple edge releases we could issue the stable by bumping the minor part and dropping the suffix: `0.1.0`. Unlike linkerd2, the latest image tag (currently `0.0.1-edge`) is hard-coded into the `values.yaml` file. It needs to be manually bumped on each release, but this allows people (and us during testing) to consume the chart directly from the source code without any preprocessing. As described in `RELEASE.md`, after having merged the release notes in `CHANGES.md`, one would need to tag `main` and that triggers the new `release.yml` workflow, which: - builds and pushes the docker image - runs the integration tests pulling that image - creates the release in github (currently won't hold any assets, just the change notes) - will publish the chart into the `https://helm.linkerd.io` helm repo.
1 parent 65d9ce4 commit bcc14fe

File tree

9 files changed

+283
-6
lines changed

9 files changed

+283
-6
lines changed

.github/workflows/release.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+*"
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
DOCKER_REGISTRY: ghcr.io/linkerd
13+
14+
jobs:
15+
16+
docker-build:
17+
runs-on: ubuntu-20.04
18+
timeout-minutes: 10
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
22+
- name: Docker build
23+
uses: ./.github/actions/docker-build
24+
with:
25+
docker-registry: ${{ env.DOCKER_REGISTRY }}
26+
docker-tag: ${{ github.ref_name }}
27+
docker-target: linux-amd64
28+
docker-push: 1
29+
docker-ghcr-username: ${{ secrets.DOCKER_GHCR_USERNAME }}
30+
docker-ghcr-pat: ${{ secrets.DOCKER_GHCR_PAT }}
31+
component: failover
32+
33+
integration-tests:
34+
runs-on: ubuntu-20.04
35+
timeout-minutes: 10
36+
needs: [docker-build]
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
40+
- name: Set up Helm
41+
uses: azure/setup-helm@a517f2ff6560563a369e16ca7c7d136b6164423f
42+
- name: Create cluster
43+
uses: AbsaOSS/k3d-action@5d155528f6d4a35f72c4cf3590e22fa0dde1e28a
44+
with:
45+
cluster-name: testing
46+
- name: Install linkerd
47+
run: |
48+
curl -sL https://run.linkerd.io/install-edge | sh
49+
export PATH=$PATH:~/.linkerd2/bin
50+
linkerd install | kubectl apply -f -
51+
linkerd check
52+
- name: Install linkerd-smi
53+
run: |
54+
helm repo add linkerd-smi https://linkerd.github.io/linkerd-smi
55+
helm repo up
56+
helm install linkerd-smi -n linkerd-smi --create-namespace --wait linkerd-smi/linkerd-smi
57+
- name: Install current linkerd-failover
58+
run: |
59+
helm install linkerd-failover -n linkerd-failover --create-namespace --wait \
60+
--set image.registry=${{ env.DOCKER_REGISTRY }} \
61+
--set image.tag=${{ github.ref_name }} \
62+
charts/linkerd-failover
63+
- name: Test routing to primary
64+
uses: ./.github/actions/failover-test
65+
with:
66+
westReplicas: 1
67+
westShouldReceiveTraffic: true
68+
centralReplicas: 1
69+
centralShouldReceiveTraffic: false
70+
eastReplicas: 1
71+
eastShouldReceiveTraffic: false
72+
- name: Test failover to secondaries
73+
uses: ./.github/actions/failover-test
74+
with:
75+
westReplicas: 0
76+
westShouldReceiveTraffic: false
77+
centralReplicas: 1
78+
centralShouldReceiveTraffic: true
79+
eastReplicas: 1
80+
eastShouldReceiveTraffic: true
81+
- name: Test removal of one secondary
82+
uses: ./.github/actions/failover-test
83+
with:
84+
westReplicas: 0
85+
westShouldReceiveTraffic: false
86+
centralReplicas: 0
87+
centralShouldReceiveTraffic: false
88+
eastReplicas: 1
89+
eastShouldReceiveTraffic: true
90+
- name: Test reestablishment of primary
91+
uses: ./.github/actions/failover-test
92+
with:
93+
westReplicas: 1
94+
westShouldReceiveTraffic: true
95+
centralReplicas: 0
96+
centralShouldReceiveTraffic: false
97+
eastReplicas: 1
98+
eastShouldReceiveTraffic: false
99+
100+
gh-release:
101+
name: Create GH release
102+
timeout-minutes: 10
103+
runs-on: ubuntu-20.04
104+
needs: [integration-tests]
105+
permissions:
106+
contents: write
107+
steps:
108+
- name: Checkout code
109+
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
110+
- name: Extract release notes
111+
run: |
112+
. bin/_release.sh
113+
extract_release_notes NOTES.md
114+
- name: Create release
115+
id: create_release
116+
uses: softprops/action-gh-release@fb0163a75bee697a9cfec2c931801de7c7f10042
117+
with:
118+
draft: false
119+
prerelease: false
120+
body_path: NOTES.md
121+
122+
chart-deploy:
123+
name: Helm chart deploy
124+
timeout-minutes: 10
125+
runs-on: ubuntu-20.04
126+
needs: [gh-release]
127+
steps:
128+
- name: Checkout code
129+
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
130+
- name: Set up Helm
131+
uses: azure/setup-helm@a517f2ff6560563a369e16ca7c7d136b6164423f
132+
- name: Log into GCP
133+
uses: 'google-github-actions/auth@8d125895b958610ec414ca4dae010257eaa814d3'
134+
with:
135+
credentials_json: ${{ secrets.LINKERD_SITE_TOKEN }}
136+
- name: Helm chart creation and upload
137+
run: |
138+
mkdir -p target/helm
139+
helm --app-version "${{ github.ref_name }}" -d target/helm package charts/linkerd-failover
140+
# backup index file before changing it
141+
gsutil cp gs://helm.linkerd.io/edge/index.yaml "target/helm/index-pre-failover-${{ github.ref_name }}".yaml
142+
helm repo index --url https://helm.linkerd.io/edge/ --merge "target/helm/index-pre-failover-${{ github.ref_name }}".yaml target/helm
143+
gsutil rsync target/helm gs://helm.linkerd.io/edge

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changes
2+
3+
## 0.0.1-edge
4+
5+
First release!
6+
7+
Please check the README.md for instructions.

RELEASE.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Linkerd-failover Release
2+
3+
This document contains instructions for releasing the Linkerd-failover
4+
extension.
5+
6+
## Version schema
7+
8+
### Example
9+
10+
```text
11+
0.0.1-edge
12+
0.0.2-edge
13+
0.0.3-edge
14+
0.1.0
15+
0.2.0-edge
16+
0.2.1-edge
17+
0.2.2-edge
18+
...
19+
0.1.1 (maintenance release for 0.1.0 stable)
20+
...
21+
22+
```
23+
24+
### Explanation
25+
26+
Note we use semver, both for edge and stable releases. Edge releases use the
27+
pattern `major.minor.patch-edge` and stable releases just drop the `edge`
28+
suffix.
29+
30+
Successive edge releases only bump the patch part, regardless of how big the
31+
changes are. When an edge release is ready to become the next stable release, we
32+
bump the minor part (or major if there are backwards-incompatible changes) and
33+
drop the `edge` suffix. The following edge release will bump the minor part, as
34+
to leave room for maintenance releases of the previous stable release.
35+
36+
## Release procedure
37+
38+
### 1. Create the release branch
39+
40+
Create a branch in the `linkerd-failover` repo, `username/X.X.X-edge` (replace
41+
with your username and the actual release number).
42+
43+
### 2. Update the Helm charts versions
44+
45+
- Update the `appVersion` in the `Chart.yaml` files for the `linkerd-failover`
46+
and `linkerd-failover` charts. `appVersion` should match the actual
47+
version/tag.
48+
- Also update their `version` entry. During the first few releases this will
49+
match `appVersion`, but may drift apart in the future when there are changes
50+
to the chart templates but no changes in the underlying `failover` docker
51+
image.
52+
- Update the `tag` entry in the `linkerd-failover` chart with the same value you
53+
used for `version`.
54+
55+
Rules for changes in the `version` entry:
56+
57+
- patch bump for minor changes
58+
- minor bump for additions/removals
59+
- major bump for backwards-incompatible changes, most notably changes that
60+
change the structure of `values.yaml`
61+
62+
Finally, keep in mind chart version changes require updating the charts README
63+
files (through `bin/helm-docs`).
64+
65+
### 3. Update the release notes
66+
67+
On this branch, add the release notes for this version in `CHANGES.md`.
68+
69+
Note: To see all of the changes since the previous release, run the command
70+
below in the `linkerd-failover` repo.
71+
72+
```bash
73+
git log Y.Y.Y-edge..HEAD
74+
```
75+
76+
### 4. Post a PR that includes the changes
77+
78+
This PR needs an approval from a "code owner." Feel free to ping one of the code
79+
owners if you've gotten feedback and approvals from other team members.
80+
81+
### 5. Merge release notes branch, then create the release tag
82+
83+
After the review has passed and the branch has been merged, follow the
84+
instructions below to properly create and push the release tag from the
85+
appropriate branch. Replace `TAG` below with the `appVersion` you used in step 2
86+
above.
87+
88+
**Note**: This will create a GPG-signed tag, so users must have GPG signing
89+
setup in their local git config.
90+
91+
```bash
92+
git checkout main git pull notes=$(. "bin"/_release.sh; extract_release_notes)
93+
git tag -s -F "$notes" TAG
94+
git push origin TAG
95+
```

bin/_release.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC2120
3+
# (disabling SC2120 so that we can use functions with optional args
4+
# see https://github.com/koalaman/shellcheck/wiki/SC2120#exceptions )
5+
6+
set -eu
7+
8+
extract_release_notes() {
9+
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
10+
rootdir=$( cd "$bindir"/.. && pwd )
11+
12+
if [ $# -eq 0 ]
13+
then
14+
# Make temporary file to save the release commit message into.
15+
tmp=$(mktemp -t release-commit-message.XXX.txt)
16+
else
17+
tmp="$rootdir/$1"
18+
fi
19+
20+
# Save commit message into temporary file.
21+
#
22+
# Match each occurrence of the regex and increment `n` by 1. While n == 1
23+
# (which is true only for the first section) print that line of `CHANGES.md`.
24+
# This ends up being the first section of release changes.
25+
awk '/^## [0-9]+\.[0-9]+\.[0-9]+.*/{n++} n==1' "$rootdir"/CHANGES.md > "$tmp"
26+
27+
echo "$tmp"
28+
}

charts/linkerd-failover-tests/Chart.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ keywords:
77
kubeVersion: ">=1.20.0-0"
88
sources:
99
- https://github.com/linkerd/linkerd-failover/
10-
version: 0.1.0
10+
appVersion: 0.0.1-edge
11+
version: 0.0.1-edge
1112
icon: https://linkerd.io/images/logo-only-200h.png
1213
maintainers:
1314
- name: Linkerd authors

charts/linkerd-failover-tests/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!-- markdownlint-disable -->
22
# linkerd-failover-tests
33

4-
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square)
4+
![Version: 0.0.1-edge](https://img.shields.io/badge/Version-0.0.1--edge-informational?style=flat-square)
55
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
6+
![AppVersion: 0.0.1-edge](https://img.shields.io/badge/AppVersion-0.0.1--edge-informational?style=flat-square)
67

78
**Homepage:** <https://linkerd.io>
89

charts/linkerd-failover/Chart.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ keywords:
77
kubeVersion: ">=1.20.0-0"
88
sources:
99
- https://github.com/linkerd/linkerd-failover/
10-
version: 0.1.0
10+
appVersion: 0.0.1-edge
11+
version: 0.0.1-edge
1112
icon: https://linkerd.io/images/logo-only-200h.png
1213
maintainers:
1314
- name: Linkerd authors

charts/linkerd-failover/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<!-- markdownlint-disable -->
22
# linkerd-failover
33

4-
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square)
4+
![Version: 0.0.1-edge](https://img.shields.io/badge/Version-0.0.1--edge-informational?style=flat-square)
55
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
6+
![AppVersion: 0.0.1-edge](https://img.shields.io/badge/AppVersion-0.0.1--edge-informational?style=flat-square)
67

78
**Homepage:** <https://linkerd.io>
89

@@ -52,7 +53,7 @@ Kubernetes: `>=1.20.0-0`
5253

5354
| Key | Type | Default | Description |
5455
|-----|------|---------|-------------|
55-
| image | object | `{"name":"failover","registry":"cr.l5d.io/linkerd","tag":"latest"}` | Docker image |
56+
| image | object | `{"name":"failover","registry":"cr.l5d.io/linkerd","tag":"0.0.1-edge"}` | Docker image |
5657
| logFormat | string | `"plain"` | Log format (`plain` or `json`) |
5758
| logLevel | string | `"linkerd=info,warn"` | Log level |
5859
| selector | string | `nil` | Determines which `TrafficSplit` instances to consider for failover. If empty, defaults to failover.linkerd.io/controlled-by={{ .Release.Name }} |

charts/linkerd-failover/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ logFormat: plain
88
image:
99
registry: cr.l5d.io/linkerd
1010
name: failover
11-
tag: latest
11+
tag: 0.0.1-edge
1212

1313
# -- Determines which `TrafficSplit` instances to consider for failover. If
1414
# empty, defaults to failover.linkerd.io/controlled-by={{ .Release.Name }}

0 commit comments

Comments
 (0)