Skip to content

Update Fabric Version #34

Update Fabric Version

Update Fabric Version #34

Workflow file for this run

name: Update Fabric Version
on:
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
pull-requests: write
jobs:
check-fabric-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer
- name: Check for new Fabric release
id: check_release
run: |
# Get the latest release version from GitHub API
LATEST_VERSION=$(curl -s https://api.github.com/repos/danielmiessler/fabric/releases/latest | jq -r '.tag_name')
echo "Latest fabric version: $LATEST_VERSION"
# Get current version from composer.json
CURRENT_VERSION=$(jq -r '.repositories[0].package.version' composer.json)
echo "Current fabric version: $CURRENT_VERSION"
# Compare versions
if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
echo "New version available: $LATEST_VERSION"
echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "update_needed=true" >> $GITHUB_OUTPUT
else
echo "No update needed"
echo "update_needed=false" >> $GITHUB_OUTPUT
fi
- name: Update composer.json
if: steps.check_release.outputs.update_needed == 'true'
run: |
NEW_VERSION="${{ steps.check_release.outputs.new_version }}"
# Update the version in composer.json
jq --arg version "$NEW_VERSION" \
--arg url "https://github.com/danielmiessler/fabric/archive/refs/tags/$NEW_VERSION.zip" \
'.repositories[0].package.version = $version | .repositories[0].package.dist.url = $url' \
composer.json > composer.json.tmp && mv composer.json.tmp composer.json
# Update composer.lock
composer update danielmiessler/fabric --no-interaction
- name: Determine new package version
if: steps.check_release.outputs.update_needed == 'true'
id: new_version
run: |
# Get current package version
CURRENT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Current tag: $CURRENT_TAG"
# Remove 'v' prefix and split version
VERSION=${CURRENT_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
# Increment minor version
NEW_MINOR=$((MINOR + 1))
NEW_TAG="v${MAJOR}.${NEW_MINOR}.0"
echo "New tag: $NEW_TAG"
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.check_release.outputs.update_needed == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
chore: update fabric to ${{ steps.check_release.outputs.new_version }}
Updates danielmiessler/fabric from ${{ steps.check_release.outputs.current_version }} to ${{ steps.check_release.outputs.new_version }}
branch: update-fabric-${{ steps.check_release.outputs.new_version }}
delete-branch: true
title: 'chore: update fabric to ${{ steps.check_release.outputs.new_version }}'
body: |
## Description
This PR updates the fabric dependency to version ${{ steps.check_release.outputs.new_version }}.
## Changes
- Updated `danielmiessler/fabric` version in `composer.json`
- Updated `composer.lock` with new dependency version
## Release Notes
See the [fabric release notes](https://github.com/danielmiessler/fabric/releases/tag/${{ steps.check_release.outputs.new_version }}) for details about this update.
---
*This PR was automatically created by the update-fabric workflow.*
labels: |
dependencies
automated