-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: introduce pre-release and release flows
Signed-off-by: Paolo Chila <[email protected]>
- Loading branch information
Showing
4 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,7 @@ jobs: | |
id: docker_build | ||
uses: keptn/gh-automation/.github/actions/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
TAGS: | | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
BUILD_ARGS: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Create Pre-Release | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
pre-release: | ||
needs: test | ||
name: Pre-Release | ||
uses: keptn/gh-automation/.github/workflows/[email protected] | ||
|
||
docker_build: | ||
needs: [pre-release] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Docker Build | ||
uses: keptn/gh-automation/.github/actions/[email protected] | ||
with: | ||
TAGS: | | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
BUILD_ARGS: | | ||
version=${{ env.VERSION }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
helm_chart_build: | ||
needs: [pre-release, docker_build] | ||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | ||
|
||
- name: Upload Helm Chart as release asset | ||
env: | ||
RELEASE_TAG: ${{ needs.pre-release.outputs.RELEASE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "$RELEASE_TAG" installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Create Release | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: Unit tests | ||
uses: ./.github/actions/unit-tests | ||
|
||
release: | ||
needs: test | ||
name: Release | ||
uses: keptn/gh-automation/.github/workflows/[email protected] | ||
|
||
docker_build: | ||
needs: [release] | ||
name: Docker Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Docker Build | ||
uses: keptn/gh-automation/.github/actions/[email protected] | ||
with: | ||
TAGS: | | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}:${{ env.VERSION }} | ||
BUILD_ARGS: | | ||
version=${{ env.VERSION }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
helm_chart_build: | ||
needs: [release, docker_build] | ||
|
||
name: Build Helm Charts | ||
runs-on: ubuntu-20.04 | ||
env: | ||
VERSION: ${{ needs.release.outputs.RELEASE_TAG }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/[email protected] | ||
|
||
- name: Load CI Environment from .ci_env | ||
id: load_ci_env | ||
uses: c-py/action-dotenv-to-setenv@v3 | ||
with: | ||
env-file: .ci_env | ||
|
||
- name: Build Helm Charts | ||
id: build_helm_charts | ||
run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | ||
|
||
- name: Upload Helm Chart as release asset | ||
env: | ||
RELEASE_TAG: ${{ needs.release.outputs.RELEASE_TAG }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release upload "$RELEASE_TAG" installer/*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2181 | ||
|
||
VERSION=$1 # e.g., 0.7.2-next.0 | ||
APP_VERSION=$2 # e.g., 0.7.2-next.0+1234 | ||
IMAGE=$3 # e.g., prometheus-service | ||
|
||
if [ $# -ne 3 ]; then | ||
echo "Usage: $0 VERSION APP_VERSION IMAGE" | ||
exit | ||
fi | ||
|
||
if [ -z "$VERSION" ]; then | ||
echo "No Version set, exiting..." | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$APP_VERSION" ]; then | ||
echo "No Image Tag set, defaulting to version" | ||
APP_VERSION=$VERSION | ||
fi | ||
|
||
|
||
# replace "appVersion: latest" with "appVersion: $VERSION" in all Chart.yaml files | ||
# find . -name Chart.yaml -exec sed -i -- "s/appVersion: latest/appVersion: ${APP_VERSION}/g" {} \; | ||
# find . -name Chart.yaml -exec sed -i -- "s/version: latest/version: ${VERSION}/g" {} \; | ||
|
||
mkdir installer/ | ||
|
||
# #################### | ||
# HELM CHART | ||
# #################### | ||
BASE_PATH=. | ||
CHARTS_PATH=chart | ||
|
||
helm package ${BASE_PATH}/${CHARTS_PATH} --app-version "$APP_VERSION" --version "$VERSION" | ||
if [ $? -ne 0 ]; then | ||
echo "Error packaging installer, exiting..." | ||
exit 1 | ||
fi | ||
|
||
mv "${IMAGE}-${VERSION}.tgz" "installer/${IMAGE}-${VERSION}.tgz" | ||
|
||
#verify the chart | ||
helm template "installer/${IMAGE}-${VERSION}.tgz" --dry-run > /dev/null | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "::error Helm Chart for ${IMAGE} has templating errors -exiting" | ||
exit 1 | ||
fi | ||
|
||
echo "Generated files:" | ||
echo " - installer/${IMAGE}-${VERSION}.tgz" |