Skip to content

Commit

Permalink
refactor(release): align plugins release number to branch name in tes…
Browse files Browse the repository at this point in the history
…ting context (#5392)

Co-authored-by: Kevin Duret <[email protected]>
  • Loading branch information
mushroomempires and kduret authored Jan 16, 2025
1 parent 8ad485f commit dfda070
Showing 1 changed file with 31 additions and 15 deletions.
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) {
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

0 comments on commit dfda070

Please sign in to comment.