Skip to content

Commit

Permalink
Update GitHub Actions workflows to use latest actions and improve tag…
Browse files Browse the repository at this point in the history
… existence check
  • Loading branch information
navjottomer committed Jan 22, 2025
1 parent 961820c commit f664b5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
29 changes: 15 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
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 @@ -36,16 +36,16 @@ jobs:
- name: Check if Tag Exists
id: check_tag
run: |
git fetch --tags
if git rev-parse "refs/tags/${OSCLASS_VERSION}" >/dev/null 2>&1; 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 }}
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' }}
Expand All @@ -63,9 +63,10 @@ jobs:

- name: Create GitHub Release
if: ${{ env.TAG_EXISTS == 'false' }}
uses: softprops/action-gh-release@v1
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 != '' }}
prerelease: ${{ env.SUFFIX != '' }}

4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4','8.0', '8.1', '8.2', '8.3' ]
php-versions: ['8.2', '8.3', '8.4' ]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
Expand Down

0 comments on commit f664b5c

Please sign in to comment.