diff --git a/.github/workflows/get-environment.yml b/.github/workflows/get-environment.yml index e97a2d0a3f..d79bc9339e 100644 --- a/.github/workflows/get-environment.yml +++ b/.github/workflows/get-environment.yml @@ -246,24 +246,40 @@ jobs: - name: Get version id: get_version - run: | - if [[ "${{ inputs.version_file }}" == "" ]]; then - VERSION=$(date '+%Y%m%d') - elif [[ "${{ inputs.version_file }}" == */*.yaml ]]; then - VERSION=$(grep 'version: ' ${{ inputs.version_file }} | cut -d' ' -f2 | tr -d '"') - else - VERSION=$(grep VERSION ${{ inputs.version_file }} | cut -d "'" -f 2) - fi - echo "version=$(echo $VERSION)" >> $GITHUB_OUTPUT - shell: bash + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + let version = ''; + + if ('${{ steps.get_stability.outputs.stability }}' === 'testing') { + const branchName = "${{ github.ref_name }}"; + const matches = branchName.match(/^(?:release|hotfix)-(\d{8})$/); + if (matches) { + version = matches[1]; + } else { + throw new Error('invalid version'); + } + } else { + const currentDate = new Date(); + version = `${currentDate.getFullYear()}${("0" + (currentDate.getMonth() + 1)).slice(-2)}00`; + } - - name: "Get release: 1 for testing / stable, . for others" + core.setOutput('version', version); + + - name: "Get release: 1 for testing / stable, for others" id: get_release - run: | - RELEASE=$(date '+%H%M%S') + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + let release = ''; - echo "release=$RELEASE" >> $GITHUB_OUTPUT - shell: bash + if (${{ contains(fromJSON('["testing", "unstable"]') , steps.get_stability.outputs.stability) }} === true) { + release = "1" + } else { + release = Date.now() + } + + core.setOutput('release', release); - name: "Get release type: hotfix, release or not defined if not a release" id: get_release_type