Skip to content

Commit

Permalink
Refactor GitHub Actions workflow to improve OSCLASS_VERSION extractio…
Browse files Browse the repository at this point in the history
…n and add debug step
  • Loading branch information
navjottomer committed Jan 22, 2025
1 parent 1e1e070 commit 0ca891c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
name: Release Workflow

on:
push:
branches:
- develop

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Extract OSCLASS_VERSION
id: extract_version
run: |
RAW_VERSION=$(grep -oP "(?<=define\\('OSCLASS_VERSION', ')[^']+" oc-includes/osclass/default-constants.php)
# Validate version and extract major.minor.patch and optional suffix
if [[ "${RAW_VERSION}" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(\.(dev[0-9]*|beta[0-9]*|rc[0-9]*))?$ ]]; then
BASE_VERSION="${BASH_REMATCH[1]}"
Expand All @@ -32,10 +28,13 @@ jobs:
echo "Invalid OSCLASS_VERSION format: ${RAW_VERSION}"
exit 1
fi
- name: Debug OSCLASS_VERSION
run: echo "OSCLASS_VERSION=${{ env.OSCLASS_VERSION }}"

- name: Check if Tag Exists
id: check_tag
shell: bash
run: |
git fetch --tags --quiet
if git tag --list "${OSCLASS_VERSION}" | grep -q "^${OSCLASS_VERSION}$"; then
Expand All @@ -44,8 +43,8 @@ jobs:
else
echo "Tag ${OSCLASS_VERSION} does not exist. Proceeding with release."
echo "TAG_EXISTS=false" >> $GITHUB_ENV
shell: bash
fi
- name: Stop if Tag Exists
if: ${{ env.TAG_EXISTS == 'true' }}
run: echo "Tag already exists. Exiting."
Expand All @@ -67,5 +66,4 @@ jobs:
files: release/osclass_v${{ env.OSCLASS_VERSION }}.zip
tag_name: ${{ env.OSCLASS_VERSION }}
name: Release ${{ env.OSCLASS_VERSION }}
prerelease: ${{ env.SUFFIX != '' }}

prerelease: ${{ env.SUFFIX != '' }}

0 comments on commit 0ca891c

Please sign in to comment.