Skip to content

Commit

Permalink
[chore] validate version format to prepare-release workflow (#9409)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
enhance the "Automation - Prepare Release" GitHub Actions workflow by
adding version format validation. The workflow now includes a new job,
"validate-version," which checks whether the provided version inputs
match the expected schema

**Link to tracking Issue:** <Issue number if applicable> #7627

---------

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
  • Loading branch information
Sanket-0510 and TylerHelmuth authored Mar 1, 2024
1 parent cb4c1d5 commit 94b5951
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,38 @@ on:
required: true
description: Current version (beta, like 0.69.1). Don't include `v`.
jobs:
#validate-version format
validate-versions:
runs-on: ubuntu-latest

steps:
- name: Validate version format
run: |
validate_beta_version() {
local regex_pattern_beta='^[0-9]+\.[0-9]+\.[0-9]+$'
if [[ ! "$1" =~ $regex_pattern_beta ]]; then
echo "Invalid $2 version format. For beta, it can be 0.1.0 or higher"
exit 1
fi
}
validate_stable_version() {
local regex_pattern_stable='^[1-9][0-9]*\.[0-9]+\.[0-9]+$'
if [[ ! "$1" =~ $regex_pattern_stable ]]; then
echo "Invalid stable version format for $2. Major version must be greater than 1."
exit 1
fi
}
validate_beta_version "${{ inputs.candidate-beta }}" "candidate-beta"
validate_beta_version "${{ inputs.current-beta }}" "current-beta"
validate_stable_version "${{ inputs.candidate-stable }}" "candidate-stable"
validate_stable_version "${{ inputs.current-stable }}" "current-stable"
shell: bash
# Releasing opentelemetry-collector
prepare-release:
needs:
- validate-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down

0 comments on commit 94b5951

Please sign in to comment.