From fc54e34858362c8687b926c0527879c25e3f3e8f Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Wed, 27 Mar 2024 15:54:01 +0100 Subject: [PATCH 01/18] fix docker tag --- .github/workflows/docker.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3e86ce4..7fead88 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -39,10 +39,8 @@ jobs: VERSION_STRIP=${VERSION#v} MINOR=${VERSION_STRIP%.*} MAJOR=${MINOR%.*} - TAGS="$TAGS,${REGISTRY}${IMAGE}:${MINOR},${REGISTRY}${IMAGE}:${MAJOR},${REGISTRY}${IMAGE}:latest" - # elif [ "${{ github.event_name }}" = "push" ]; then - # TAGS="$TAGS,${REGISTRY}${IMAGE}:sha-${GITHUB_SHA::8}" - fi + TAGS="$TAGS,${REGISTRY}${IMAGE}:latest" + echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "tags=${TAGS}" >> $GITHUB_OUTPUT echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT From 65a7e8c5248f632cd650d217b7119911a91b28bf Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Wed, 27 Mar 2024 15:55:18 +0100 Subject: [PATCH 02/18] fix condition --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7fead88..49844af 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -40,7 +40,7 @@ jobs: MINOR=${VERSION_STRIP%.*} MAJOR=${MINOR%.*} TAGS="$TAGS,${REGISTRY}${IMAGE}:latest" - + fi echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "tags=${TAGS}" >> $GITHUB_OUTPUT echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT From b2e3d929248c88e8355bfc427c0807bc60ec33b8 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 28 Mar 2024 12:00:06 +0100 Subject: [PATCH 03/18] add major minor tag --- .github/workflows/docker.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 49844af..b961274 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,12 +1,12 @@ name: Docker Build on: schedule: - - cron: "0 22 * * 0" # every sunday at 10pm + - cron: '0 22 * * 0' # every sunday at 10pm push: branches: - - "main" + - 'main' tags: - - "v?[0-9]+.[0-9]+.[0-9]+*" + - 'v?[0-9]+.[0-9]+.[0-9]+*' pull_request: jobs: @@ -37,9 +37,10 @@ jobs: TAGS="${REGISTRY}${IMAGE}:${VERSION}" if [[ $VERSION =~ ^v?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then VERSION_STRIP=${VERSION#v} + TAGS="${REGISTRY}${IMAGE}:${VERSION_STRIP}" MINOR=${VERSION_STRIP%.*} MAJOR=${MINOR%.*} - TAGS="$TAGS,${REGISTRY}${IMAGE}:latest" + TAGS="$TAGS,${REGISTRY}${IMAGE}:${MINOR},${REGISTRY}${IMAGE}:${MAJOR},${REGISTRY}${IMAGE}:latest" fi echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "tags=${TAGS}" >> $GITHUB_OUTPUT @@ -48,7 +49,7 @@ jobs: - name: Set up GO uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: '1.21' - name: Build GO app run: | GOOS=linux CGO_ENABLED=0 go build -o app @@ -97,8 +98,8 @@ jobs: if: ${{ github.event_name != 'pull_request' }} with: image-ref: ${{ steps.env.outputs.tags }} - format: "table" - exit-code: "1" + format: 'table' + exit-code: '1' ignore-unfixed: true - vuln-type: "os,library" - severity: "CRITICAL,HIGH" + vuln-type: 'os,library' + severity: 'CRITICAL,HIGH' From 6602002e6eaefc75447ffd8e19265f2834728778 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Wed, 10 Apr 2024 18:11:57 +0200 Subject: [PATCH 04/18] allow bump for helm --- .github/workflows/version_bump.yml | 67 ++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 7e34c62..3c79251 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -1,24 +1,73 @@ -name: Bump helm app version +name: Bump version on: - push: - tags: - - "v?[0-9]+.[0-9]+.[0-9]+*" + pull_request: + branches: + - 'main' + types: + - closed permissions: contents: write pull-requests: write jobs: - bump_version: + bump_helm_version: + if: | + (github.event.pull_request.merged == true) && + (contains(github.event.pull_request.labels.*.name, 'helm-patch') || + contains(github.event.pull_request.labels.*.name, 'helm-minor') || + contains(github.event.pull_request.labels.*.name, 'helm-major')) runs-on: ubuntu-latest steps: + - name: Install semver + run: | + pip3 install semver + - uses: actions/checkout@v4 + - name: Bump helm version + run: | + label_names='${{ toJSON(github.event.pull_request.labels) }}' + relevant_labels=$(echo $label_names | jq '[.[] | select((.name == "helm-patch") or (.name == "helm-minor") or (.name == "helm-major"))]') + length=$(echo $relevant_labels | jq 'length') + if [ $length != 1 ]; then echo "More than one or none label has been defined. Exiting." && exit 1;fi + + version_bump_type=$(echo $relevant_labels | jq -r '.[] | .name') + version_bump_type=${version_bump#"helm-"} + + current_version=$(sed -n -e 's/^.*version: //p' charts/ca-injector/Chart.yaml) + new_version=$(semver bump -i $version_bump_type $current_version) + + sed -i "s/version:.*/version: $new_version/g" charts/ca-injector/Chart.yaml + bump_app_version: + if: | + (github.event.pull_request.merged == true) && + (contains(github.event.pull_request.labels.*.name, 'app-patch') || + contains(github.event.pull_request.labels.*.name, 'app-minor') || + contains(github.event.pull_request.labels.*.name, 'app-minor')) + runs-on: ubuntu-latest + steps: + - name: Install semver + run: | + pip3 install semver - uses: actions/checkout@v4 - - name: Bump appVersion + - name: Bump helm version run: | - sed -i 's/appVersion:.*/appVersion: ${{ github.ref_name }}/g' charts/ca-injector/Chart.yaml + label_names='${{ toJSON(github.event.pull_request.labels) }}' + relevant_labels=$(echo $label_names | jq '[.[] | select((.name == "app-patch") or (.name == "app-minor") or (.name == "app-major"))]') + length=$(echo $relevant_labels | jq 'length') + if [ $length != 1 ]; then echo "More than one or none label has been defined. Exiting." && exit 1;fi + version_bump_type=$(echo $relevant_labels | jq -r '.[] | .name') + version_bump_type=${version_bump#"app-"} + + current_version=$(sed -n -e 's/^.*appVersion: //p' charts/ca-injector/Chart.yaml) + new_version=$(semver bump -i $version_bump_type $current_version) + + sed -i "s/appVersion:.*/appVersion: $new_version/g" charts/ca-injector/Chart.yaml + + create_pull_request: + runs-on: ubuntu-latest + steps: - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: - title: "Add app version ${{ github.ref_name }}" - base: main + title: 'Bump version' From 1c7206b2490eba7b7b21b6130e962b0d8daea0e0 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Wed, 10 Apr 2024 18:12:57 +0200 Subject: [PATCH 05/18] remove 'v' prefix --- .github/workflows/docker.yml | 11 +++++------ charts/ca-injector/Chart.yaml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b961274..59901ad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,7 @@ on: branches: - 'main' tags: - - 'v?[0-9]+.[0-9]+.[0-9]+*' + - '[0-9]+.[0-9]+.[0-9]+*' pull_request: jobs: @@ -35,12 +35,11 @@ jobs: VERSION=pr-${{ github.event.number }} fi TAGS="${REGISTRY}${IMAGE}:${VERSION}" - if [[ $VERSION =~ ^v?[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then - VERSION_STRIP=${VERSION#v} - TAGS="${REGISTRY}${IMAGE}:${VERSION_STRIP}" - MINOR=${VERSION_STRIP%.*} + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="${REGISTRY}${IMAGE}:${VERSION}" + MINOR=${VERSION%.*} MAJOR=${MINOR%.*} - TAGS="$TAGS,${REGISTRY}${IMAGE}:${MINOR},${REGISTRY}${IMAGE}:${MAJOR},${REGISTRY}${IMAGE}:latest" + TAGS="$TAGS,${REGISTRY}${IMAGE}:${MINOR},${REGISTRY}${IMAGE}:${MAJOR}" fi echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "tags=${TAGS}" >> $GITHUB_OUTPUT diff --git a/charts/ca-injector/Chart.yaml b/charts/ca-injector/Chart.yaml index 74b0e0a..1409b76 100644 --- a/charts/ca-injector/Chart.yaml +++ b/charts/ca-injector/Chart.yaml @@ -21,4 +21,4 @@ version: 0.1.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: v0.1.11 +appVersion: 0.1.11 From 5de5ee73f6de55c5ac483f0f239a7337412a95b3 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Wed, 10 Apr 2024 18:24:42 +0200 Subject: [PATCH 06/18] add release instruction --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index c7fdf1f..5072207 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,29 @@ in your helm chart's appropriate annotations section. `ca.crt` can be changed by configuration `caBundle.crt` in any of the typical ways (config files at `/etc/ca-injector.yaml`, `$HOME/.config/ca-injector.yaml`, or environment variable `CAINJECTOR_CABUNDLE_CRT`). + + +## Release + +### App +To trigger a new tagged docker build, create a git tag based on the format '[0-9]+.[0-9]+.[0-9]+*'. This will trigger the docker build accordingly. + +### Helm +In case the appVersion is increased, the helm Chart version should also be increased. +In case the helm Chart version is increased, the appVersion does not have to be increased as well. + + +Option 1: +Manually set version and/or appVersion within Helm Chart. The Helm release workflow will create a new release in case the helm Chart version has changed. + +Option 2: +Add one or two(app and helm) of the following labels to your PR: +- app-major +- app-minor +- app-patch +- helm-major +- helm-minor +- helm-patch + +According to the label, appVersion and/or helm version will be bumped and a PullRequest will be created. After this PR has benn closed, the Helm release workflow will create a new release in case the helm Chart version has changed. + From 6344dd77369714e20aa05a45378b1a978f131ec5 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:15:35 +0200 Subject: [PATCH 07/18] allow test run --- .github/workflows/version_bump.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 3c79251..64de6a7 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - 'main' + - 'task/fix-docker-tags' types: - closed From acfeb08c28c6e5f44ab559f03d1118d9a9fb09a6 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:16:20 +0200 Subject: [PATCH 08/18] only bump from main --- .github/workflows/version_bump.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 64de6a7..3c79251 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - 'main' - - 'task/fix-docker-tags' types: - closed From d30638c9af443545753743a16fa4ed7b6fdb2570 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:24:08 +0200 Subject: [PATCH 09/18] allow multiple branches bumping --- .github/workflows/version_bump.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 3c79251..c1e246a 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - 'main' + - 'task/fix-docker-tags' + - 'Test' + types: - closed From 464701feadd71efa5e95195bf32dd1cb4c6f68a2 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:24:40 +0200 Subject: [PATCH 10/18] remove branch trigger --- .github/workflows/version_bump.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index c1e246a..da1c174 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -5,7 +5,6 @@ on: branches: - 'main' - 'task/fix-docker-tags' - - 'Test' types: - closed From 867b93b82cb84c438e477aa9ff0169f41aeb2e2f Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:39:17 +0200 Subject: [PATCH 11/18] install via apt, fix label name --- .github/workflows/version_bump.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index da1c174..f14abf3 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Install semver run: | - pip3 install semver + sudo apt-get update && sudo apt-get install python3-semver - uses: actions/checkout@v4 - name: Bump helm version run: | @@ -45,12 +45,12 @@ jobs: (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'app-patch') || contains(github.event.pull_request.labels.*.name, 'app-minor') || - contains(github.event.pull_request.labels.*.name, 'app-minor')) + contains(github.event.pull_request.labels.*.name, 'app-major')) runs-on: ubuntu-latest steps: - name: Install semver run: | - pip3 install semver + sudo apt-get update && sudo apt-get install python3-semver - uses: actions/checkout@v4 - name: Bump helm version run: | From 1b53bb69a4ec53285b5ce2be5bdc79eb868c8828 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:51:40 +0200 Subject: [PATCH 12/18] use steps inside one job --- .github/workflows/version_bump.yml | 40 +++++++++++------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index f14abf3..ccf2dc3 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -14,19 +14,19 @@ permissions: pull-requests: write jobs: - bump_helm_version: - if: | - (github.event.pull_request.merged == true) && - (contains(github.event.pull_request.labels.*.name, 'helm-patch') || - contains(github.event.pull_request.labels.*.name, 'helm-minor') || - contains(github.event.pull_request.labels.*.name, 'helm-major')) + bump_version: runs-on: ubuntu-latest steps: - name: Install semver run: | - sudo apt-get update && sudo apt-get install python3-semver + pip install semver - uses: actions/checkout@v4 - name: Bump helm version + if: | + (github.event.pull_request.merged == true) && + (contains(github.event.pull_request.labels.*.name, 'helm-patch') || + contains(github.event.pull_request.labels.*.name, 'helm-minor') || + contains(github.event.pull_request.labels.*.name, 'helm-major')) run: | label_names='${{ toJSON(github.event.pull_request.labels) }}' relevant_labels=$(echo $label_names | jq '[.[] | select((.name == "helm-patch") or (.name == "helm-minor") or (.name == "helm-major"))]') @@ -37,22 +37,15 @@ jobs: version_bump_type=${version_bump#"helm-"} current_version=$(sed -n -e 's/^.*version: //p' charts/ca-injector/Chart.yaml) - new_version=$(semver bump -i $version_bump_type $current_version) + new_version=$(python -m semver bump -i $version_bump_type $current_version) sed -i "s/version:.*/version: $new_version/g" charts/ca-injector/Chart.yaml - bump_app_version: - if: | - (github.event.pull_request.merged == true) && - (contains(github.event.pull_request.labels.*.name, 'app-patch') || - contains(github.event.pull_request.labels.*.name, 'app-minor') || - contains(github.event.pull_request.labels.*.name, 'app-major')) - runs-on: ubuntu-latest - steps: - - name: Install semver - run: | - sudo apt-get update && sudo apt-get install python3-semver - - uses: actions/checkout@v4 - - name: Bump helm version + - name: Bump App version + if: | + (github.event.pull_request.merged == true) && + (contains(github.event.pull_request.labels.*.name, 'app-patch') || + contains(github.event.pull_request.labels.*.name, 'app-minor') || + contains(github.event.pull_request.labels.*.name, 'app-major')) run: | label_names='${{ toJSON(github.event.pull_request.labels) }}' relevant_labels=$(echo $label_names | jq '[.[] | select((.name == "app-patch") or (.name == "app-minor") or (.name == "app-major"))]') @@ -62,13 +55,10 @@ jobs: version_bump_type=${version_bump#"app-"} current_version=$(sed -n -e 's/^.*appVersion: //p' charts/ca-injector/Chart.yaml) - new_version=$(semver bump -i $version_bump_type $current_version) + new_version=$(python -m semver bump -i $version_bump_type $current_version) sed -i "s/appVersion:.*/appVersion: $new_version/g" charts/ca-injector/Chart.yaml - create_pull_request: - runs-on: ubuntu-latest - steps: - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: From 630167a2dea67a263ecfbde97368b283bd6bdcc7 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 10:55:12 +0200 Subject: [PATCH 13/18] fix var reference --- .github/workflows/version_bump.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index ccf2dc3..6448a24 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -34,7 +34,7 @@ jobs: if [ $length != 1 ]; then echo "More than one or none label has been defined. Exiting." && exit 1;fi version_bump_type=$(echo $relevant_labels | jq -r '.[] | .name') - version_bump_type=${version_bump#"helm-"} + version_bump_type=${version_bump_type#"helm-"} current_version=$(sed -n -e 's/^.*version: //p' charts/ca-injector/Chart.yaml) new_version=$(python -m semver bump -i $version_bump_type $current_version) @@ -52,7 +52,7 @@ jobs: length=$(echo $relevant_labels | jq 'length') if [ $length != 1 ]; then echo "More than one or none label has been defined. Exiting." && exit 1;fi version_bump_type=$(echo $relevant_labels | jq -r '.[] | .name') - version_bump_type=${version_bump#"app-"} + version_bump_type=${version_bump_type#"app-"} current_version=$(sed -n -e 's/^.*appVersion: //p' charts/ca-injector/Chart.yaml) new_version=$(python -m semver bump -i $version_bump_type $current_version) From 47facace74bfa9289859910e47ddd4fa70b5e01e Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 11:33:40 +0200 Subject: [PATCH 14/18] remove manual git tag being required --- .github/workflows/app_release.yml | 38 ++++++++++++++++++++++++++++++ .github/workflows/docker.yml | 12 ++++++---- .github/workflows/version_bump.yml | 7 ++++-- README.md | 3 ++- 4 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/app_release.yml diff --git a/.github/workflows/app_release.yml b/.github/workflows/app_release.yml new file mode 100644 index 0000000..b4ac8df --- /dev/null +++ b/.github/workflows/app_release.yml @@ -0,0 +1,38 @@ +name: Tag + +on: + pull_request: + branches: + - 'main' + - 'task/fix-docker-tags' + types: + - closed + paths: + - 'charts/ca-injector/Chart.yaml' + +jobs: + create_tag: + if: | + (github.event.pull_request.merged == true) && + contains(github.event.pull_request.labels.*.name, 'automatic_app_release') + runs-on: ubuntu-latest + outputs: + new_tag: ${{ steps.tag_version.outputs.new_tag }} + steps: + - uses: actions/checkout@v4 + - name: Receive version + run: | + new_app_version=$(sed -n -e 's/^.*appVersion: //p' charts/ca-injector/Chart.yaml) + echo "new_app_version=${new_app_version}" >> $GITHUB_ENV + - name: create git tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{ env.new_app_version }} + trigger_docker_build: + needs: [create_tag] + uses: ./.github/workflows/docker.yml + secrets: inherit + with: + tag: ${{ needs.create_tag.outputs.new_tag }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 59901ad..62f5912 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,9 +5,13 @@ on: push: branches: - 'main' - tags: - - '[0-9]+.[0-9]+.[0-9]+*' + - 'task/fix-docker-tags' pull_request: + workflow_call: + inputs: + tag: + type: string + required: true jobs: build: @@ -24,8 +28,8 @@ jobs: VERSION=noop if [ "${{ github.event_name }}" = "schedule" ]; then VERSION=edge - elif [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} + elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + VERSION=${{ inputs.tag }} elif [[ $GITHUB_REF == refs/heads/* ]]; then VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 6448a24..97349b9 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -37,7 +37,7 @@ jobs: version_bump_type=${version_bump_type#"helm-"} current_version=$(sed -n -e 's/^.*version: //p' charts/ca-injector/Chart.yaml) - new_version=$(python -m semver bump -i $version_bump_type $current_version) + new_version=$(python -m semver bump $version_bump_type $current_version) sed -i "s/version:.*/version: $new_version/g" charts/ca-injector/Chart.yaml - name: Bump App version @@ -55,11 +55,14 @@ jobs: version_bump_type=${version_bump_type#"app-"} current_version=$(sed -n -e 's/^.*appVersion: //p' charts/ca-injector/Chart.yaml) - new_version=$(python -m semver bump -i $version_bump_type $current_version) + new_version=$(python -m semver bump $version_bump_type $current_version) sed -i "s/appVersion:.*/appVersion: $new_version/g" charts/ca-injector/Chart.yaml + echo "PR_LABELS=automatic_app_release" >> $GITHUB_ENV + - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: title: 'Bump version' + labels: ${{ env.PR_LABELS }} diff --git a/README.md b/README.md index 5072207..54c1db5 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,8 @@ or environment variable `CAINJECTOR_CABUNDLE_CRT`). ## Release ### App -To trigger a new tagged docker build, create a git tag based on the format '[0-9]+.[0-9]+.[0-9]+*'. This will trigger the docker build accordingly. +To trigger a new tagged docker build, create a PR with label 'automatic_app_release'. The app Version within the helm chart will be used as reference for the container tag. +This will be done automatically by below mentioned workflow. ### Helm In case the appVersion is increased, the helm Chart version should also be increased. From 64d35f27074b44ae3886f73c588450a330840a58 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 11:39:54 +0200 Subject: [PATCH 15/18] describe workflow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54c1db5..e34e95e 100644 --- a/README.md +++ b/README.md @@ -92,5 +92,5 @@ Add one or two(app and helm) of the following labels to your PR: - helm-minor - helm-patch -According to the label, appVersion and/or helm version will be bumped and a PullRequest will be created. After this PR has benn closed, the Helm release workflow will create a new release in case the helm Chart version has changed. +According to the label, appVersion and/or helm version will be bumped and a PullRequest will be created. The Pull request will include label 'automatic_app_release' to trigger above mentioned workflow. After this PR has benn closed, the Helm release workflow will create a new release in case the helm Chart version has changed. From 27829c1b80967d9d04c2bd08b6ab0c33ebbf30e0 Mon Sep 17 00:00:00 2001 From: felixZdi <93919627+felixZdi@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:40:59 +0000 Subject: [PATCH 16/18] [create-pull-request] automated change --- charts/ca-injector/Chart.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/ca-injector/Chart.yaml b/charts/ca-injector/Chart.yaml index 1409b76..ce4fcbe 100644 --- a/charts/ca-injector/Chart.yaml +++ b/charts/ca-injector/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.0 +version: 0.1.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: 0.1.11 +appVersion: 0.1.12 From 10b785ab8fd6b2b65aa72ce0a072c68eadc66763 Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 11:59:36 +0200 Subject: [PATCH 17/18] only trigger from main --- .github/workflows/app_release.yml | 4 ++-- .github/workflows/docker.yml | 1 - .github/workflows/version_bump.yml | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/app_release.yml b/.github/workflows/app_release.yml index b4ac8df..0b90ceb 100644 --- a/.github/workflows/app_release.yml +++ b/.github/workflows/app_release.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - 'main' - - 'task/fix-docker-tags' types: - closed paths: @@ -14,7 +13,7 @@ jobs: create_tag: if: | (github.event.pull_request.merged == true) && - contains(github.event.pull_request.labels.*.name, 'automatic_app_release') + contains(github.event.pull_request.labels.*.name, 'helm_app_version_update') runs-on: ubuntu-latest outputs: new_tag: ${{ steps.tag_version.outputs.new_tag }} @@ -30,6 +29,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} custom_tag: ${{ env.new_app_version }} + tag_prefix: '' trigger_docker_build: needs: [create_tag] uses: ./.github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 62f5912..b15e403 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,7 +5,6 @@ on: push: branches: - 'main' - - 'task/fix-docker-tags' pull_request: workflow_call: inputs: diff --git a/.github/workflows/version_bump.yml b/.github/workflows/version_bump.yml index 97349b9..4eec03d 100644 --- a/.github/workflows/version_bump.yml +++ b/.github/workflows/version_bump.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - 'main' - - 'task/fix-docker-tags' types: - closed @@ -59,10 +58,10 @@ jobs: sed -i "s/appVersion:.*/appVersion: $new_version/g" charts/ca-injector/Chart.yaml - echo "PR_LABELS=automatic_app_release" >> $GITHUB_ENV + echo "PR_LABELS=helm_app_version_update" >> $GITHUB_ENV - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: - title: 'Bump version' + title: 'Bump Helm Chart versions' labels: ${{ env.PR_LABELS }} From fef7813c8c3edf6165435eb10a777b32c524975d Mon Sep 17 00:00:00 2001 From: Felix Bechter Date: Thu, 11 Apr 2024 11:59:44 +0200 Subject: [PATCH 18/18] update label name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e34e95e..5cdd6f1 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ or environment variable `CAINJECTOR_CABUNDLE_CRT`). ## Release ### App -To trigger a new tagged docker build, create a PR with label 'automatic_app_release'. The app Version within the helm chart will be used as reference for the container tag. +To trigger a new tagged docker build, create a PR with label 'helm_app_version_update'. The app Version within the helm chart will be used as reference for the container tag. This will be done automatically by below mentioned workflow. ### Helm @@ -92,5 +92,5 @@ Add one or two(app and helm) of the following labels to your PR: - helm-minor - helm-patch -According to the label, appVersion and/or helm version will be bumped and a PullRequest will be created. The Pull request will include label 'automatic_app_release' to trigger above mentioned workflow. After this PR has benn closed, the Helm release workflow will create a new release in case the helm Chart version has changed. +According to the label, appVersion and/or helm version will be bumped and a PullRequest will be created. The Pull request will include label 'helm_app_version_update' to trigger above mentioned workflow. After this PR has benn closed, the Helm release workflow will create a new release in case the helm Chart version has changed.