Bin
2025-12-17 2e6c955be321cefd7e0c4a3031eab805e0a5a303
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: "Release: Cut off release branch"
 
on:
  workflow_dispatch:
    inputs:
      version:
        description: 'Release version'
        required: true
        type: string
      ref:
        description: 'Commit SHA or ref name or tag'
        required: true
        default: 'develop'
        type: string
 
env:
  RELEASE_BRANCH_PREFIX: "ls-release/"
 
jobs:
  draft-new-release:
    name: "Draft new release/hotfix"
    runs-on: ubuntu-latest
    outputs:
      next_develop_version: ${{ steps.calculate_branch_name_and_version.outputs.next_develop_version }}
      release_version: ${{ steps.calculate_branch_name_and_version.outputs.release_version }}
      release_branch: ${{ steps.calculate_branch_name_and_version.outputs.release_branch }}
    steps:
      - uses: hmarr/debug-action@v3.0.0
 
      - name: Checkout
        uses: actions/checkout@v6
        with:
          token: ${{ secrets.GIT_PAT }}
          ref: ${{ inputs.ref }}
          submodules: 'recursive'
          fetch-depth: 2147483647
 
      - name: Configure git
        shell: bash
        run: |
          set -xeuo pipefail
          git config --global user.name 'robot-ci-heartex'
          git config --global user.email 'robot-ci-heartex@users.noreply.github.com'
 
      - name: Calculate branch name and version
        id: calculate_branch_name_and_version
        shell: bash
        env:
          VERSION: "${{ inputs.version }}"
        run: |
          set -xeuo pipefail
          
          regexp='^[v]?([0-9]+)\.([0-9]+)\.0$';
          
          if [[ "${VERSION}" =~ $regexp ]]; then
              first="${BASH_REMATCH[1]}"
              second="${BASH_REMATCH[2]}"
              third="0"
          else
              echo "::error::${VERSION} does not mach the regexp ${regexp}"
              exit 1
          fi
          
          release_version="${first}.${second}.${third}"
          release_branch="${{ env.RELEASE_BRANCH_PREFIX }}${first}.${second}.${third}"
          next_develop_version="${first}.$(($second + 1)).0.dev0"
          
          echo "release_branch=${release_branch}" >> "${GITHUB_OUTPUT}"
          echo "release_version=${release_version}" >> "${GITHUB_OUTPUT}"
          echo "next_develop_version=${next_develop_version}" >> "${GITHUB_OUTPUT}"
 
      - name: Cut release branch
        shell: bash
        run: |
          set -xeuo pipefail
          
          git checkout -b "${{ steps.calculate_branch_name_and_version.outputs.release_branch }}"
          echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
          git push origin HEAD:refs/heads/${{ steps.calculate_branch_name_and_version.outputs.release_branch }}
 
  set-version-default-branch:
    name: 'Set version in default branch'
    uses: ./.github/workflows/release-set-version.yml
    needs:
      - draft-new-release
    with:
      version: ${{ needs.draft-new-release.outputs.next_develop_version }}
      branch: ${{ github.event.repository.default_branch }}
    permissions:
      contents: write
    secrets: inherit
 
  update-feature-flags:
    name: "Update feature flags in release branch"
    needs:
      - draft-new-release
    permissions:
      contents: write
    uses: ./.github/workflows/feature-flags-update.yml
    with:
      ref: ${{ needs.draft-new-release.outputs.release_branch }}
    secrets: inherit
 
  set-version-release-branch:
    name: 'Set version in release branch'
    uses: ./.github/workflows/release-set-version.yml
    needs:
      - update-feature-flags
      - draft-new-release
    with:
      version: ${{ needs.draft-new-release.outputs.release_version }}
      branch: ${{ needs.draft-new-release.outputs.release_branch }}
    permissions:
      contents: write
    secrets: inherit