Skip to content

Update GitHub Actions workflows to use latest actions and improve tag… #22

Update GitHub Actions workflows to use latest actions and improve tag…

Update GitHub Actions workflows to use latest actions and improve tag… #22

Workflow file for this run

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]}"
SUFFIX="${BASH_REMATCH[2]}"
echo "OSCLASS_VERSION=${RAW_VERSION}" >> $GITHUB_ENV
echo "BASE_VERSION=${BASE_VERSION}" >> $GITHUB_ENV
echo "SUFFIX=${SUFFIX}" >> $GITHUB_ENV
echo "Extracted version: ${RAW_VERSION}, Base: ${BASE_VERSION}, Suffix: ${SUFFIX}"
else
echo "Invalid OSCLASS_VERSION format: ${RAW_VERSION}"
exit 1
fi
- name: Check if Tag Exists
id: check_tag
run: |
git fetch --tags --quiet
if git tag --list "${OSCLASS_VERSION}" | grep -q "^${OSCLASS_VERSION}$"; then
echo "Tag ${OSCLASS_VERSION} already exists. Skipping release."
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "Tag ${OSCLASS_VERSION} does not exist. Proceeding with release."
echo "TAG_EXISTS=false" >> $GITHUB_ENV
shell: bash
env:
OSCLASS_VERSION: ${{ env.OSCLASS_VERSION }}
- name: Stop if Tag Exists
if: ${{ env.TAG_EXISTS == 'true' }}
run: echo "Tag already exists. Exiting."
- name: Create Release Tag
if: ${{ env.TAG_EXISTS == 'false' }}
run: |
git tag -a "${OSCLASS_VERSION}" -m "Release ${OSCLASS_VERSION}"
git push origin "${OSCLASS_VERSION}"
- name: Run Build Script
if: ${{ env.TAG_EXISTS == 'false' }}
run: sh ./.build.sh
- name: Create GitHub Release
if: ${{ env.TAG_EXISTS == 'false' }}
uses: softprops/action-gh-release@v2
with:
files: release/osclass_v${{ env.OSCLASS_VERSION }}.zip
tag_name: ${{ env.OSCLASS_VERSION }}
name: Release ${{ env.OSCLASS_VERSION }}
prerelease: ${{ env.SUFFIX != '' }}