From cf328cdf3302abc1a3b322ea2b4d3f49d79364d0 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Tue, 25 Jan 2022 10:14:53 +0000 Subject: [PATCH 1/3] Tag for release is correctly tagged to branch x.y. --- .github/workflows/CI.yml | 32 +++++++++++++++++------------ towncrier/newsfragments/2124.bugfix | 1 + 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 towncrier/newsfragments/2124.bugfix diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c184aaa5..1bb29779 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,7 +5,7 @@ on: - staging - testing - '1.8' - - '1.9' + - '1.9' - master # test branches, e.g. test-debian - test-* @@ -26,7 +26,7 @@ concurrency: ci-${{ github.ref }} ################################################ # Code block that is used as one liner. ##!/bin/bash -#version=$( git tag --list "{{ env.MAILU_VERSION }}.*" | tail -1 ) +#version=$( git tag --sort=version:refname --list "{{ env.MAILU_VERSION }}.*" | tail -1 ) ) #root_version=${version%.*} #patch_version=${version##*.} #if [ "$patch_version" == "" ] @@ -73,7 +73,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -149,7 +149,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -221,7 +221,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -293,7 +293,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -365,7 +365,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -437,7 +437,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -509,7 +509,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -587,7 +587,7 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - name: Derive PINNED_MAILU_VERSION for staging if: ${{ env.BRANCH == 'staging' }} shell: bash @@ -649,13 +649,19 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' }} shell: bash run: | - version=$( git tag --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV - - name: Tag and create release + version=$( git tag --sort=version:refname --list "${{ env.MAILU_VERSION }}.*" | tail -1 );root_version=${version%.*};patch_version=${version##*.};if [ "$patch_version" == "" ]; then pinned_version=${{ env.MAILU_VERSION }}.0; else pinned_version=$root_version.$(expr $patch_version + 1); fi;echo "PINNED_MAILU_VERSION=$pinned_version" >> $GITHUB_ENV + - name: Create tag for branch x.y. + if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' && env.PINNED_MAILU_VERSION != '' }} + shell: bash + run: | + echo git tag ${{ env.PINNED_MAILU_VERSION }} $(/usr/bin/git log -1 --format='%H') + git tag ${{ env.PINNED_MAILU_VERSION }} $(/usr/bin/git log -1 --format='%H') + git push origin ${{ env.PINNED_MAILU_VERSION }} + - name: Create release for tag x.y.z. if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' && env.PINNED_MAILU_VERSION != '' }} uses: ncipollo/release-action@v1 with: bodyFile: "RELEASE_TEMPLATE.md" - commit: ${{ env.GITHUB_SHA }} tag: ${{ env.PINNED_MAILU_VERSION }} token: ${{ secrets.GITHUB_TOKEN }} diff --git a/towncrier/newsfragments/2124.bugfix b/towncrier/newsfragments/2124.bugfix new file mode 100644 index 00000000..af6fdb77 --- /dev/null +++ b/towncrier/newsfragments/2124.bugfix @@ -0,0 +1 @@ +Fix CI/CD workflow. Tags were not set to the correct commit hash. \ No newline at end of file From 5cef8925dc9cb6861884db90821547ce86375ae1 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Tue, 25 Jan 2022 11:42:22 +0000 Subject: [PATCH 2/3] Remove superfluous parentheses --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1bb29779..e833268b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -26,7 +26,7 @@ concurrency: ci-${{ github.ref }} ################################################ # Code block that is used as one liner. ##!/bin/bash -#version=$( git tag --sort=version:refname --list "{{ env.MAILU_VERSION }}.*" | tail -1 ) ) +#version=$( git tag --sort=version:refname --list "{{ env.MAILU_VERSION }}.*" | tail -1 ) #root_version=${version%.*} #patch_version=${version##*.} #if [ "$patch_version" == "" ] From 413ecea4799de030ef1ebb709d47148a8e004cb3 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Wed, 26 Jan 2022 15:54:20 +0000 Subject: [PATCH 3/3] Switched from "$(/usr/bin/git log -1 --format='%H')" to "$(/usr/bin/git rev-parse HEAD)" --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e833268b..8348503b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -654,8 +654,8 @@ jobs: if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' && env.PINNED_MAILU_VERSION != '' }} shell: bash run: | - echo git tag ${{ env.PINNED_MAILU_VERSION }} $(/usr/bin/git log -1 --format='%H') - git tag ${{ env.PINNED_MAILU_VERSION }} $(/usr/bin/git log -1 --format='%H') + echo git tag ${{ env.PINNED_MAILU_VERSION }} $(/usr/bin/git rev-parse HEAD) + git tag ${{ env.PINNED_MAILU_VERSION }} $(/usr/bin/git rev-parse HEAD) git push origin ${{ env.PINNED_MAILU_VERSION }} - name: Create release for tag x.y.z. if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' && env.PINNED_MAILU_VERSION != '' }}