-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor create_release workflow to make automatic release * add check_version workflow * refactor doc´ker build * refactor helm build * refactor create_release.yaml * change version to 1.0.0 * fix path ref * add missing v * refactor workflows * Enhance CI Workflow: Check for Version Bump and appVersion Changes (#44) * feat: additional approval on Version change * fix: combine version bump check and approve by label * fix: adjust label name * fix: remove tag comparison * fix: base_ref * fix: some naming changes * Fix syntax Co-authored-by: Jonathan Mayer <[email protected]> * refactor check-for-release.yaml * fix dependency * resolve merge conflicts * add label removing * chore: syntax * change message * removed not needed if checks * removal of new release * fix errors in workflows * fix appVersion variable mismatch --------- Co-authored-by: Johannes <[email protected]> Co-authored-by: Jonathan Mayer <[email protected]>
- Loading branch information
1 parent
43bd005
commit d19831b
Showing
6 changed files
with
189 additions
and
55 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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Check for new release | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, labeled] | ||
|
||
jobs: | ||
check_for_release: | ||
name: Check For Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check for appVersion changes | ||
run: | | ||
echo "Checking for appVersion changes..." | ||
if git diff origin/${{ github.base_ref }} -- deployments/chart/Chart.yaml | grep -qe "^[+-]appVersion: "; then | ||
app_version_change=$(echo "version changed") | ||
echo "app_version_change=$app_version_change" >> $GITHUB_ENV | ||
else | ||
app_version_change=$(echo "No appVersion changes detected.") | ||
echo "app_version_change=$app_version_change" >> $GITHUB_ENV | ||
fi | ||
- name: Remove new version label | ||
if: ${{ env.app_version_change == 'No appVersion changes detected.' }} | ||
run: | | ||
echo "No appVersion changes detected. Removing new version label" | ||
gh pr edit ${{ github.event.pull_request.number }} --remove-label "new release" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Fail if changes occured | ||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'new release') }} | ||
run: | | ||
if [ "${{ env.app_version_change }}" == "version changed" ]; then | ||
echo "Version changed, exiting..." | ||
exit 1 | ||
else | ||
echo "No appVersion changes detected." | ||
fi | ||
- name: Remove approval label | ||
run: | | ||
gh pr edit ${{ github.event.pull_request.number }} --remove-label "needs approval" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
post_message: | ||
name: Post Message To Warn Of New Release | ||
runs-on: ubuntu-latest | ||
needs: check_for_release | ||
if: ${{ failure() && !contains(github.event.pull_request.labels.*.name, 'needs approval') }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Extract appVersion | ||
id: extract_appversion | ||
run: | | ||
appversion=$(yq e '.appVersion' ./deployments/chart/Chart.yaml) | ||
echo "appversion=$appversion" >> $GITHUB_ENV | ||
- name: Post warning comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: "⚠️ Warning: Merging this PR will result in a new release because the `appVersion` in Chart.yaml has changed to `${{ env.appversion }}`. Please confirm this by adding the `new release` label before merging." | ||
|
||
- name: Set a label on the pull request | ||
run: | | ||
gh pr edit ${{ github.event.pull_request.number }} --add-label "needs approval" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,83 @@ | ||
name: Check for new version | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- deployments/chart/Chart.yaml | ||
|
||
jobs: | ||
check_versions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version_change: ${{ steps.check_for_version_change.outputs.version_change }} | ||
app_version_change: ${{ steps.check_for_appVersion_change.outputs.app_version_change }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check for appVersion change | ||
id: check_for_appVersion_change | ||
run: | | ||
app_version_change=$(git diff main HEAD~1 -- deployments/chart/Chart.yaml | grep -qe "^[+-]appVersion: " && echo "appVersion changed" || echo "appVersion didn't change") | ||
echo "app_version_change=$app_version_change" >> $GITHUB_OUTPUT | ||
- name: Check for version change | ||
id: check_for_version_change | ||
run: | | ||
version_change=$(git diff main HEAD~1 -- deployments/chart/Chart.yaml | grep -qe "^[+-]version: " && echo "version changed" || echo "version didn't change") | ||
echo "version_change=$version_change" >> $GITHUB_OUTPUT | ||
build_new_chart: | ||
runs-on: ubuntu-latest | ||
needs: check_versions | ||
if: ${{ needs.check_versions.outputs.version_change == 'version changed' }} | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Extract Chart Version | ||
id: chart_version | ||
run: | | ||
version=$(yq e '.version' ./deployments/chart/Chart.yaml) | ||
echo "version=$version" >> $GITHUB_ENV | ||
- name: Dispatch Event to build new helm chart | ||
uses: peter-evans/repository-dispatch@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: caas-team/GoKubeDownscaler | ||
event-type: build-new-chart | ||
client-payload: '{"version": "${{ env.version }}"}' | ||
|
||
release_new_version: | ||
runs-on: ubuntu-latest | ||
needs: check_versions | ||
if: ${{ needs.check_versions.outputs.app_version_change == 'appVersion changed' }} | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Extract App Version | ||
id: app_version | ||
run: | | ||
app_version=$(yq e '.appVersion' ./deployments/chart/Chart.yaml) | ||
echo "app_version=$app_version" >> $GITHUB_ENV | ||
- name: Dispatch Event to create new release | ||
uses: peter-evans/repository-dispatch@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: caas-team/GoKubeDownscaler | ||
event-type: release-new-version | ||
client-payload: '{"appVersion": "${{ env.app_version }}"}' |
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 |
---|---|---|
@@ -1,25 +1,20 @@ | ||
name: Create Release | ||
name: Create new release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
repository_dispatch: | ||
types: [release-new-version] | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
create_release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Create GitHub Release | ||
id: create_release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ github.ref_name }} | ||
name: ${{ github.ref_name }} | ||
tag: v${{ github.event.client_payload.appVersion }} | ||
name: v${{ github.event.client_payload.appVersion }} | ||
generateReleaseNotes: true |
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 |
---|---|---|
@@ -1,38 +1,16 @@ | ||
# Build and push Image | ||
name: Build and push Image | ||
|
||
on: | ||
push: | ||
repository_dispatch: | ||
types: [release-new-version] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check Version Format in Tag | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: nowsprinting/[email protected] | ||
id: check-version | ||
with: | ||
prefix: "v" | ||
|
||
- name: Set tag | ||
id: set-tag | ||
run: | | ||
SHORT_SHA=$(git rev-parse --short HEAD) | ||
TAG1="dev" | ||
TAG2="commit-$SHORT_SHA" | ||
if [[ "${{ steps.check-version.outputs.is_valid }}" == 'true' ]]; then | ||
TAG1="latest" | ||
TAG2="${{ steps.check-version.outputs.full_without_prefix }}" | ||
fi | ||
echo "TAG1=$TAG1" >> $GITHUB_ENV | ||
echo "TAG2=$TAG2" >> $GITHUB_ENV | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
|
@@ -41,8 +19,8 @@ jobs: | |
mtr.devops.telekom.de/caas/go-kube-downscaler | ||
ghcr.io/caas-team/gokubedownscaler | ||
tags: | | ||
${{ env.TAG1 }} | ||
${{ env.TAG2 }} | ||
latest | ||
${{ github.event.client_payload.appVersion }} | ||
- name: Install Cosign | ||
uses: sigstore/cosign-installer@main | ||
|
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
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