8000 Automate release by Trojan295 · Pull Request #461 · capactio/capact · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Automate release #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ed3dcc0
test
Trojan295 Aug 23, 2021
0913ebe
add script for release
Trojan295 Aug 23, 2021
d6785b5
fix permissions
Trojan295 Aug 23, 2021
09e07d4
setup git
Trojan295 Aug 23, 2021
be035d4
add permissions
Trojan295 Aug 23, 2021
14708cb
remove modifying workflow
Trojan295 Aug 23, 2021
6830c08
push stuff
Trojan295 Aug 23, 2021
1399c11
use PAT and envs
Trojan295 Aug 23, 2021
bca2983
fix
Trojan295 Aug 23, 2021
fea2ff7
rework
Trojan295 Aug 24, 2021
d5b1dbe
commentout tests
Trojan295 Aug 24, 2021
5c119f3
fix
Trojan295 Aug 24, 2021
614e4d4
add tags build trigger to main build
Trojan295 Aug 24, 2021
c81f69d
fix workflows
Trojan295 Aug 24, 2021
8f768a9
fix
Trojan295 Aug 24, 2021
a743660
rework
Trojan295 Aug 24, 2021
6c19a03
commit
Aug 24, 2021
95749f3
Prepare 0.5.0 release
Aug 24, 2021
d2f8f3b
test
Aug 24, 2021
e5e2c3e
revert versions
Aug 24, 2021
8faadd8
single workflow
Aug 24, 2021
dba18ea
dont tag in prerelease
Aug 24, 2021
08f5c61
short build time
Aug 24, 2021
294e7ee
fix
Aug 24, 2021
2b77818
Update CHANGELOG.md [skip ci]
Aug 24, 2021
d4b25b6
Update CHANGELOG.md [skip ci]
Aug 24, 2021
b350201
Update CHANGELOG.md [skip ci]
Aug 24, 2021
44d0c3a
add gren
Aug 24, 2021
456a30a
Make bugfix
Trojan295 Aug 24, 2021
b463351
Add super feature
Trojan295 Aug 24, 2021
c9549ba
Prepare 0.5.0 release
Aug 24, 2021
7ecb88d
simplify
Trojan295 Aug 24, 2021
9e3a97e
Revert "Prepare 0.5.0 release"
Trojan295 Aug 24, 2021
e01735c
add GCS creds
Trojan295 Aug 24, 2021
4e79b04
login to ghrc registry
Trojan295 Aug 24, 2021
39c4d13
change gren template
Trojan295 Aug 25, 2021
22c93f6
upx and all arch
Trojan295 Aug 25, 2021
84a89e9
remove arch
Trojan295 Aug 25, 2021
62bfaa4
fix to work in release-branch
Trojan295 Aug 25, 2021
99e7796
short build
Trojan295 Aug 25, 2021
00f34e4
adjustments for upstream
Trojan295 Aug 26, 2021
c6b7f69
fixes
Trojan295 Aug 26, 2021
cfaa7b5
fixes
Trojan295 Aug 26, 2021
ab40c27
fixes
Trojan295 Aug 26, 2021
23a6e29
fixes, trigger CI
Trojan295 Aug 26, 2021
9f03df4
rename PAT env
Trojan295 Aug 26, 2021
b522c7f
fix
Trojan295 Aug 26, 2021
374afab
fix creds issue
Trojan295 Aug 26, 2021
f02e60b
after review
Trojan295 Aug 27, 2021
8b8f9f7
add permissions
Trojan295 Aug 27, 2021
0590ba5
Merge branch 'main' into automate-release
Trojan295 Sep 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions .github/workflows/branch-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ on:
- "!**.md"
branches:
- "main"
- "release-0.2"
- "release-0.3"
- "release-0.4"
- "release-*"

jobs:
entry-tests:
name: Lint and test code
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -56,7 +53,6 @@ jobs:
matrix-infra: ${{ steps.set-matrix-infra.outputs.matrix }}
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -80,7 +76,6 @@ jobs:
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -101,7 +96,6 @@ jobs:
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -123,7 +117,6 @@ jobs:
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -141,7 +134,6 @@ jobs:
if: github.ref == 'refs/heads/main'
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -164,7 +156,6 @@ jobs:
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -207,7 +198,6 @@ jobs:
needs: [ entry-tests, build-app, build-tests ]
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -248,7 +238,6 @@ jobs:
if: github.ref == 'refs/heads/main'
permissions:
contents: read

env:
CAPACT_CREDENTIALS_STORE_FILE_PASSPHRASE: "no-pass"
CAPACT_CREDENTIALS_STORE_BACKEND: "file"
Expand Down Expand Up @@ -287,13 +276,11 @@ jobs:
--namespace 'capact-system' \
--phase 'SUCCEEDED'


slackNotification:
name: Slack Notification
runs-on: ubuntu-latest
needs: [ update-cluster ]
if: always()

steps:
- name: Slack Notification
if: ${{ always() && needs.update-cluster.result != 'success' }}
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/make-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Make release

# Required secrets:
# GCS_CREDS - Credentials to Google Cloud Storage for binary and chart releases
# GH_PAT - GitHub username with personal access token with permissions to make commits to repository, must be in format "<username>:<PAT>"

on:
workflow_dispatch:
inputs:
version:
description: Version in SemVer (e.g. '0.5.0')
required: true

jobs:
make-release:
name: Make release
runs-on: ubuntu-latest
environment: Release
permissions:
contents: write
packages: write
pull-requests: read
issues: read
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Git credentials
# Replacing the GH Action token with PAT is required to trigger the branch-build workflow on a commit:
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
run: |
git remote remove origin
git remote add origin https://${{secrets.GH_PAT}}@github.com/${{github.repository}}.git
git config --global user.email "contact@capact.io"
git config --global user.name "Capact Bot"
- name: Setup environment
run: |
. ./hack/ci/setup-env.sh
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{env.GO_VERSION}}
- name: Set up GoReleaser
run: go install github.com/goreleaser/goreleaser@v0.173.2
- name: Set up GCS
uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GCS_CREDS }}
export_default_credentials: true
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push release commits and tag
env:
RELEASE_VERSION: "${{ github.event.inputs.version }}"
run: ./hack/make-release.sh
- name: Run GoReleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make release-binaries
- name: Generate release notes
run: |
npm install -g github-release-notes
gren release -d -T "${{ secrets.GITHUB_TOKEN }}" --tags "v${{ github.event.inputs.version }}" --override
- name: Release Helm charts
run: make release-charts
11 changes: 8 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ builds:
- linux
- windows
- darwin
goarch: &build-arch
- "386"
- amd64
- arm64
hooks: &build-hooks
# Install upx first, https://github.com/upx/upx/releases
post: upx -9 "{{ .Path }}"
Expand All @@ -32,6 +36,7 @@ builds:
- id: populator
env: *build-env
goos: *build-goos
goarch: *build-arch
hooks: *build-hooks
main: ./cmd/populator
binary: 'populator-{{ .Os }}-{{ .Arch }}'
Expand Down Expand Up @@ -73,6 +78,6 @@ blobs:
folder: '{{ .Tag }}'

release:
# You can disable this pipe in order to not upload any artifacts.
# Defaults to false.
disable: true
github:
owner: capactio
name: capact
8 changes: 8 additions & 0 deletions .grenrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dataSource: prs
groupBy:
"🚨 Breaking": [breaking]
"🔧 Bug Fixes": [bug]
"🚀 Enhancements": [enhancement]
template:
issue: "- {{name}} [{{text}}]({{url}}) ([@{{user_login}}]({{user_url}}))"
group: "\n### {{heading}}\n"
71 changes: 71 additions & 0 deletions hack/make-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -e

CURRENT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
REPO_ROOT_DIR=$(cd "${CURRENT_DIR}/.." && pwd)
readonly CURRENT_DIR
readonly REPO_ROOT_DIR


release::update_helm_charts_version() {
local -r release_version="$1"
local -r deploy_dir="${REPO_ROOT_DIR}/deploy/kubernetes/charts"

for d in "${deploy_dir}"/*/ ; do
sed -i.bak "s/^version: .*/version: ${release_version}/g" "${d}/Chart.yaml"
done
}

release::make_prepare_release_commit() {
local -r version="$1"
local -r branch="$2"

git add .
git commit -m "Prepare ${version} release"
git push origin "${branch}"
}

release::set_capact_images_in_charts() {
local -r image_tag="$1"
sed -E -i.bak "s/overrideTag: \".+\"/overrideTag: \"${image_tag}\"/g" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/values.yaml"
}

release::set_hub_manifest_source_branch() {
local -r branch="$1"
sed -E -i.bak "s/branch: .+/branch: ${branch}/g" "${REPO_ROOT_DIR}/deploy/kubernetes/charts/capact/charts/hub-public/values.yaml"
}

release::make_release_commit() {
local -r version="$1"
local -r release_branch="$2"
local -r tag="v${version}"

git add .
git commit -m "Set fixed Capact image tag and Populator source branch"
git tag "${tag}"
git push origin "${release_branch}"
git push origin "${tag}"
}

# required inputs:
# RELEASE_VERSION - new version in SemVer format: x.y.z
[ -z "${RELEASE_VERSION}" ] && echo "Need to set RELEASE_VERSION" && exit 1;

SOURCE_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
RELEASE_VERSION_MAJOR_MINOR="$(echo "${RELEASE_VERSION}" | sed -E 's/([0-9]+\.[0-9])\.[0-9]/\1/g')"
RELEASE_BRANCH="release-${RELEASE_VERSION_MAJOR_MINOR}"

main() {
release::update_helm_charts_version "${RELEASE_VERSION}"
release::make_prepare_release_commit "${RELEASE_VERSION}" "${SOURCE_BRANCH}"

local -r capact_image_tag=$(git rev-parse --short HEAD | sed 's/.$//')
git checkout -B "${RELEASE_BRANCH}"

release::set_capact_images_in_charts "${capact_image_tag}"
release::set_hub_manifest_source_branch "${RELEASE_BRANCH}"
release::make_release_commit "${RELEASE_VERSION}" "${RELEASE_BRANCH}"
}

main
0