Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(release): align plugins release number to branch name in testing context #5392

Merged
46 changes: 31 additions & 15 deletions .github/workflows/get-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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, <date>.<commit_sha> for others"
core.setOutput('version', version);

- name: "Get release: 1 for testing / stable, <date> 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) {
mushroomempires marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down