2190: Tag for release is correctly tagged to branch x.y. r=mergify[bot] a=Diman0

## What type of PR?

Bug-fix

## What does this PR do?
CI/CD had two issues which are addressed by this PR.
- calculating new x.y.z failed for x.y.10+
- tag was not created for branch x.y, but master. This resulted in the release pointing to the wrong commit.

backport is required to make this workflow available for 1.9.

### Related issue(s)
- closes #2124 

## Prerequisites
Before we can consider review and merge, please make sure the following list is done and checked.
If an entry in not applicable, you can check it or remove it from the list.

- [x] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/workflow.html#changelog) entry file.


Co-authored-by: Dimitri Huisman <diman@huisman.xyz>
master
bors[bot] 3 years ago committed by GitHub
commit 3c99bbf695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,7 @@ on:
- staging - staging
- testing - testing
- '1.8' - '1.8'
- '1.9' - '1.9'
- master - master
# test branches, e.g. test-debian # test branches, e.g. test-debian
- test-* - test-*
@ -26,7 +26,7 @@ concurrency: ci-${{ github.ref }}
################################################ ################################################
# Code block that is used as one liner. # Code block that is used as one liner.
##!/bin/bash ##!/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%.*} #root_version=${version%.*}
#patch_version=${version##*.} #patch_version=${version##*.}
#if [ "$patch_version" == "" ] #if [ "$patch_version" == "" ]
@ -73,7 +73,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -149,7 +149,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -221,7 +221,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -293,7 +293,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -365,7 +365,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -437,7 +437,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -509,7 +509,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -587,7 +587,7 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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 - name: Derive PINNED_MAILU_VERSION for staging
if: ${{ env.BRANCH == 'staging' }} if: ${{ env.BRANCH == 'staging' }}
shell: bash shell: bash
@ -649,13 +649,19 @@ jobs:
if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' }}
shell: bash shell: bash
run: | 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: Tag and create release - 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 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 != '' }} if: ${{ env.BRANCH != 'testing' && env.BRANCH != 'staging' && env.BRANCH != 'master' && env.PINNED_MAILU_VERSION != '' }}
uses: ncipollo/release-action@v1 uses: ncipollo/release-action@v1
with: with:
bodyFile: "RELEASE_TEMPLATE.md" bodyFile: "RELEASE_TEMPLATE.md"
commit: ${{ env.GITHUB_SHA }}
tag: ${{ env.PINNED_MAILU_VERSION }} tag: ${{ env.PINNED_MAILU_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

@ -0,0 +1 @@
Fix CI/CD workflow. Tags were not set to the correct commit hash.
Loading…
Cancel
Save