Fixed tag generation for releases

This commit is contained in:
Alexey Pustovalov 2021-10-19 00:37:32 +03:00
parent 77a1230ed4
commit dccea453a9
2 changed files with 40 additions and 13 deletions

View File

@ -34,7 +34,7 @@ jobs:
os: ${{ steps.os.outputs.list }}
database: ${{ steps.database.outputs.list }}
components: ${{ steps.components.outputs.list }}
current_branch: ${{ steps.branch_info.outputs.current_branch }}
is_default_branch: ${{ steps.branch_info.outputs.is_default_branch }}
steps:
- name: Checkout repository
uses: actions/checkout@v2.3.4
@ -79,7 +79,20 @@ jobs:
- name: Get branch info
id: branch_info
uses: tj-actions/branch-names@v5
run: |
github_ref="${{ github.ref }}"
result=false
if [[ "$github_ref" == "refs/tags/"* ]]; then
github_ref=${github_ref%.*}
fi
github_ref=${github_ref##*/}
if [[ "$github_ref" == "${{ env.LATEST_BRANCH }}" ]]; then
result=true
fi
echo "::set-output name=is_default_branch::$result"
build_base:
timeout-minutes: 90
@ -127,9 +140,9 @@ jobs:
type=semver,pattern={{version}},suffix=-${{ matrix.os }}
type=ref,event=branch,prefix=${{ matrix.os }}-,suffix=-latest
type=ref,event=branch,suffix=-${{ matrix.os }}-latest
type=raw,enable=${{ needs.init_build.outputs.is_default_branch == 'true' }},value=${{matrix.os}}-latest
type=raw,enable=${{ (needs.init_build.outputs.is_default_branch == 'true') && ( github.event_name == 'push' ) }},value=${{matrix.os}}-latest
flavor: |
latest=${{ (matrix.os == 'alpine') && (needs.init_build.outputs.current_branch == env.LATEST_BRANCH) }}
latest=${{ (matrix.os == 'alpine') && ( github.event_name == 'push' ) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
- name: Build ${{ env.BASE_BUILD_NAME }}/${{ matrix.os }} and push
id: docker_build
@ -200,9 +213,9 @@ jobs:
type=semver,pattern={{version}},suffix=-${{ matrix.os }}
type=ref,event=branch,prefix=${{ matrix.os }}-,suffix=-latest
type=ref,event=branch,suffix=-${{ matrix.os }}-latest
type=raw,enable=${{ needs.init_build.outputs.is_default_branch == 'true' }},value=${{matrix.os}}-latest
type=raw,enable=${{ (needs.init_build.outputs.is_default_branch == 'true') && ( github.event_name == 'push' ) }},value=${{matrix.os}}-latest
flavor: |
latest=${{ (matrix.os == 'alpine') && (needs.init_build.outputs.current_branch == env.LATEST_BRANCH) }}
latest=${{ (matrix.os == 'alpine') && ( github.event_name == 'push' ) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
- name: Download SHA256 tag build-base:${{ matrix.os }}
uses: actions/download-artifact@v2.0.10
@ -299,9 +312,9 @@ jobs:
type=semver,pattern={{version}},suffix=-${{ matrix.os }}
type=ref,event=branch,prefix=${{ matrix.os }}-,suffix=-latest
type=ref,event=branch,suffix=-${{ matrix.os }}-latest
type=raw,enable=${{ needs.init_build.outputs.is_default_branch == 'true' }},value=${{matrix.os}}-latest
type=raw,enable=${{ (needs.init_build.outputs.is_default_branch == 'true') && ( github.event_name == 'push' ) }},value=${{matrix.os}}-latest
flavor: |
latest=${{ (matrix.os == 'alpine') && (needs.init_build.outputs.current_branch == env.LATEST_BRANCH) }}
latest=${{ (matrix.os == 'alpine') && ( github.event_name == 'push' ) && ( needs.init_build.outputs.is_default_branch == 'true' ) }}
- name: Download SHA256 tag for ${{ steps.build_base_image.outputs.build_base }}:${{ matrix.os }}
uses: actions/download-artifact@v2.0.10

View File

@ -34,7 +34,7 @@ jobs:
outputs:
os: ${{ steps.os.outputs.list }}
components: ${{ steps.components.outputs.list }}
current_branch_branch: ${{ steps.branch_info.outputs.current_branch }}
is_default_branch: ${{ steps.branch_info.outputs.is_default_branch }}
steps:
- name: Checkout repository
uses: actions/checkout@v2.3.4
@ -68,7 +68,21 @@ jobs:
- name: Get branch info
id: branch_info
uses: tj-actions/branch-names@v5
shell: bash
run: |
github_ref="${{ github.ref }}"
result=false
if [[ "$github_ref" == "refs/tags/"* ]]; then
github_ref=${github_ref%.*}
fi
github_ref=${github_ref##*/}
if [[ "$github_ref" == "${{ env.LATEST_BRANCH }}" ]]; then
result=true
fi
echo "::set-output name=is_default_branch::$result"
build_base:
timeout-minutes: 70
@ -110,7 +124,7 @@ jobs:
type=semver,pattern={{version}},suffix=-${{ steps.base_os_tag.outputs.os_tag }},prefix=${{ matrix.component }}-
type=ref,event=branch,prefix=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-,suffix=-latest
type=ref,event=branch,suffix=-${{ steps.base_os_tag.outputs.os_tag }}-latest,prefix=${{ matrix.component }}-
type=raw,enable=${{ needs.init_build.outputs.is_default_branch == 'true' }},value=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-latest
type=raw,enable=${{ ( needs.init_build.outputs.is_default_branch == 'true' ) && ( github.event_name == 'push' ) }},value=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-latest
flavor: |
latest=false
@ -206,7 +220,7 @@ jobs:
type=semver,pattern={{version}},suffix=-${{ steps.base_os_tag.outputs.os_tag }},prefix=${{ matrix.component }}-
type=ref,event=branch,prefix=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-,suffix=-latest
type=ref,event=branch,suffix=-${{ steps.base_os_tag.outputs.os_tag }}-latest,prefix=${{ matrix.component }}-
type=raw,enable=${{ needs.init_build.outputs.is_default_branch == 'true' }},value=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-latest
type=raw,enable=${{ ( needs.init_build.outputs.is_default_branch == 'true' ) && ( github.event_name == 'push' ) }},value=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-latest
flavor: |
latest=false
@ -314,7 +328,7 @@ jobs:
type=semver,pattern={{version}},suffix=-${{ steps.base_os_tag.outputs.os_tag }}
type=ref,event=branch,prefix=${{ steps.base_os_tag.outputs.os_tag }}-,suffix=-latest
type=ref,event=branch,suffix=-${{ steps.base_os_tag.outputs.os_tag }}-latest
type=raw,enable=${{ needs.init_build.outputs.is_default_branch == 'true' }},value=${{ steps.base_os_tag.outputs.os_tag }}-latest
type=raw,enable=${{ ( needs.init_build.outputs.is_default_branch == 'true' ) && ( github.event_name == 'push' ) }},value=${{ matrix.component }}-${{ steps.base_os_tag.outputs.os_tag }}-latest
flavor: |
latest=false