Skip to content
This repository was archived by the owner on Jun 27, 2022. It is now read-only.

Commit 4fb89e1

Browse files
committed
ci: Introduce automated releases for kubernetes-utils (#4586)
1 parent 1ed054f commit 4fb89e1

13 files changed

+282
-74
lines changed

.github/workflows/pre-release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Pre-Release
2+
on:
3+
workflow_dispatch:
4+
env:
5+
NODE_VERSION: 14
6+
KEPTN_BOT_NAME: "Keptn Bot"
7+
KEPTN_BOT_EMAIL: "keptn-bot <[email protected]>"
8+
RELEASE_NOTES_FILE: "RELEASE-BODY.md"
9+
PRERELEASE_KEYWORD: "next"
10+
defaults:
11+
run:
12+
shell: bash
13+
jobs:
14+
test:
15+
strategy:
16+
matrix:
17+
go-version: [1.16.x]
18+
platform: [ubuntu-latest]
19+
runs-on: ${{ matrix.platform }}
20+
env:
21+
GO111MODULE: "on"
22+
GOPROXY: "https://proxy.golang.org"
23+
steps:
24+
- name: Install Go
25+
uses: actions/[email protected]
26+
with:
27+
go-version: ${{ matrix.go-version }}
28+
- name: Checkout code
29+
uses: actions/[email protected]
30+
- name: Test
31+
run: go test -race -v ./...
32+
pre-release:
33+
name: Pre-Release
34+
runs-on: ubuntu-20.04
35+
needs: [test]
36+
steps:
37+
- name: Checkout repo
38+
uses: actions/checkout@v2
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Set up Node.js
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: ${{ env.NODE_VERSION }}
46+
47+
- name: Configure Git
48+
env:
49+
KEPTN_BOT_NAME: ${{ env.KEPTN_BOT_NAME }}
50+
KEPTN_BOT_EMAIL: ${{ env.KEPTN_BOT_EMAIL }}
51+
run: |
52+
git config user.name "$KEPTN_BOT_NAME"
53+
git config user.email "$KEPTN_BOT_EMAIL"
54+
55+
- name: Prepare GitHub Release Notes
56+
run: |
57+
npx standard-version@^9.3.1 --prerelease "${{ env.PRERELEASE_KEYWORD }}" -i "${{ env.RELEASE_NOTES_FILE }}" --skip.commit --skip.tag --header ""
58+
59+
- name: Enhance Release Notes with Build Metadata
60+
run: |
61+
echo "#### Build Information" >> "${{ env.RELEASE_NOTES_FILE }}"
62+
echo "" >> "${{ env.RELEASE_NOTES_FILE }}"
63+
echo "**GitHub Actions Run:** $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> "${{ env.RELEASE_NOTES_FILE }}"
64+
65+
- name: Create pre-release package
66+
id: create-release-package
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
69+
run: |
70+
echo "🚀 Creating pre-release package now..."
71+
npx standard-version@^9.3.1 --prerelease "${{ env.PRERELEASE_KEYWORD }}" --skip.commit --skip.changelog
72+
73+
echo "::set-output name=tag-name::$(git describe --tags --abbrev=0)"
74+
echo "⚡️ Pushing changes to remote repository..."
75+
git push --follow-tags
76+
77+
- name: Create GitHub Release
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
80+
RELEASE_TAG: ${{ steps.create-release-package.outputs.tag-name }}
81+
run: |
82+
gh release create "$RELEASE_TAG" --prerelease --notes-file "${{ env.RELEASE_NOTES_FILE }}" --title "$RELEASE_TAG"

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
env:
5+
NODE_VERSION: 14
6+
KEPTN_BOT_NAME: "Keptn Bot"
7+
KEPTN_BOT_EMAIL: "keptn-bot <[email protected]>"
8+
RELEASE_NOTES_FILE: "RELEASE-BODY.md"
9+
defaults:
10+
run:
11+
shell: bash
12+
jobs:
13+
test:
14+
strategy:
15+
matrix:
16+
go-version: [1.16.x]
17+
platform: [ubuntu-latest]
18+
runs-on: ${{ matrix.platform }}
19+
env:
20+
GO111MODULE: "on"
21+
GOPROXY: "https://proxy.golang.org"
22+
steps:
23+
- name: Install Go
24+
uses: actions/[email protected]
25+
with:
26+
go-version: ${{ matrix.go-version }}
27+
- name: Checkout code
28+
uses: actions/[email protected]
29+
- name: Test
30+
run: go test -race -v ./...
31+
release:
32+
name: "Release"
33+
runs-on: ubuntu-20.04
34+
needs: [test]
35+
steps:
36+
- name: Checkout repo
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Set up Node.js
42+
uses: actions/setup-node@v2
43+
with:
44+
node-version: ${{ env.NODE_VERSION }}
45+
46+
- name: Configure Git
47+
env:
48+
KEPTN_BOT_NAME: ${{ env.KEPTN_BOT_NAME }}
49+
KEPTN_BOT_EMAIL: ${{ env.KEPTN_BOT_EMAIL }}
50+
run: |
51+
git config user.name "$KEPTN_BOT_NAME"
52+
git config user.email "$KEPTN_BOT_EMAIL"
53+
54+
- name: Prepare GitHub Release Notes
55+
run: |
56+
# Delete pre-release tags to be able to generate a changelog from last 'real' release
57+
# This is a workaround for a known limitation of standard-version
58+
# Reference: https://github.com/conventional-changelog/standard-version/issues/203#issuecomment-872415140
59+
git tag -l | grep -vE '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$' | xargs git tag -d
60+
61+
npx standard-version@^9.3.1 -i "${{ env.RELEASE_NOTES_FILE }}" --skip.commit --skip.tag --header ""
62+
63+
- name: Temporarily disable "include administrators" branch protection
64+
uses: benjefferies/branch-protection-bot@6d0ac2b2d9bfd39794b017f8241adb7da7f0ab98 # [email protected]
65+
with:
66+
access_token: ${{ secrets.KEPTN_BOT_TOKEN }}
67+
branch: ${{ github.event.repository.default_branch }}
68+
enforce_admins: false
69+
70+
- name: Create release package
71+
id: create-release-package
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
74+
run: |
75+
echo "🚀 Creating release package now..."
76+
npx standard-version@^9.3.1
77+
78+
echo "::set-output name=tag-name::$(git describe --tags --abbrev=0)"
79+
80+
echo "Fetching previously deleted old tags..."
81+
git fetch origin --tags -f
82+
echo "⚡️ Pushing changes to remote repository..."
83+
git push --follow-tags
84+
85+
- name: Enable "include administrators" branch protection
86+
uses: benjefferies/branch-protection-bot@6d0ac2b2d9bfd39794b017f8241adb7da7f0ab98 # [email protected]
87+
if: always() # Force to always run this step to ensure "include administrators" is always turned back on
88+
with:
89+
access_token: ${{ secrets.KEPTN_BOT_TOKEN }}
90+
branch: ${{ github.event.repository.default_branch }}
91+
enforce_admins: true
92+
93+
- name: Create GitHub Release
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
96+
RELEASE_TAG: ${{ steps.create-release-package.outputs.tag-name }}
97+
run: |
98+
gh release create "$RELEASE_TAG" --draft --notes-file "${{ env.RELEASE_NOTES_FILE }}" --title "$RELEASE_TAG"

.versionrc.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"preMajor": true,
3+
"issueUrlFormat": "https://github.com/keptn/keptn/issues/{{id}}",
4+
"scripts": {
5+
"postchangelog": "./gh-actions-scripts/post-changelog-actions.sh"
6+
},
7+
"types": [
8+
{
9+
"type": "feat",
10+
"section": "Features"
11+
},
12+
{
13+
"type": "fix",
14+
"section": "Bug Fixes"
15+
},
16+
{
17+
"type": "chore",
18+
"section": "Other"
19+
},
20+
{
21+
"type": "docs",
22+
"section": "Docs"
23+
},
24+
{
25+
"type": "perf",
26+
"section": "Performance"
27+
},
28+
{
29+
"type": "build",
30+
"hidden": true
31+
},
32+
{
33+
"type": "ci",
34+
"hidden": true
35+
},
36+
{
37+
"type": "refactor",
38+
"section": "Refactoring"
39+
},
40+
{
41+
"type": "revert",
42+
"hidden": true
43+
},
44+
{
45+
"type": "style",
46+
"hidden": true
47+
},
48+
{
49+
"type": "test",
50+
"hidden": true
51+
}
52+
]
53+
}

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## [0.9.0](https://github.com/keptn/kubernetes-utils/compare/v0.8.3...v0.9.0)
2+
3+
### Features
4+
5+
- Updated external dependencies
6+
7+
### [0.8.3](https://github.com/keptn/kubernetes-utils/compare/v0.8.2...v0.8.3)
8+
9+
### Features
10+
11+
- Updated external dependencies
12+
13+
### [0.8.2](https://github.com/keptn/kubernetes-utils/compare/v0.8.1...v0.8.2)
14+
15+
### Features
16+
17+
- Added Go Version 1.16 support
18+
19+
### [0.8.1](https://github.com/keptn/kubernetes-utils/compare/v0.8.0...v0.8.1)
20+
21+
### Bug Fixes
22+
23+
- Updated and cleaned up several kubernetes/helm related dependencies
24+
25+
## [0.8.0](https://github.com/keptn/kubernetes-utils/compare/v0.2.0...v0.8.0)
26+
27+
### Features
28+
29+
- Return the git commit ID in the `GetChart()` function [2530](https://github.com/keptn/keptn/issues/2530)
30+
- Moved Auto-PR from Travis CI to GitHub actions [#2750](https://github.com/keptn/keptn/2750)
31+
- Moved unit tests from Travis CI to GitHub actions [#2796](https://github.com/keptn/keptn/2796)
32+
- Added functions to support Keptn Smart Auth [#2733](https://github.com/keptn/keptn/2733)
33+
34+
### Bug Fixes
35+
36+
- Added a timeout mechanism for the `WaitForDeploymentToBeRolledOut()` function [2578](https://github.com/keptn/keptn/issues/2578)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
echo "Removing sign-off messages from changelog..."
4+
for file in {CHANGELOG,RELEASE-BODY}.md; do
5+
if [ -f "$file" ]; then
6+
echo "Replacing content in $file"
7+
# Reference: https://stackoverflow.com/a/1252191
8+
sed -e ':a' -e 'N' -e '$!ba' -e 's/\nSigned-off-by: .* <.*@.*>\n/ /g' "$file" > tmp
9+
mv tmp "$file"
10+
else
11+
echo "Not replacing anything since $file does not exist."
12+
fi
13+
done

releasenotes/releasenotes_V0.8.1.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

releasenotes/releasenotes_V0.8.2.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

releasenotes/releasenotes_V0.8.3.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

releasenotes/releasenotes_V0.9.0.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

releasenotes/releasenotes_v0.1.0.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)