From 680f7dcd9510a9575d227b703a1a5b6b74ea6df1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 30 Jun 2025 08:24:01 +0200 Subject: [PATCH 1/2] feat: add GitHub Actions to auto-update fabric dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add workflow to check for new fabric releases daily - Automatically create PR when new version is available - Add workflow to tag new minor release when PR is merged - Updates composer.json and composer.lock automatically 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/tag-release.yml | 70 +++++++++++++++++ .github/workflows/update-fabric.yml | 114 ++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 .github/workflows/tag-release.yml create mode 100644 .github/workflows/update-fabric.yml diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 0000000..7b49e6a --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,70 @@ +name: Tag Release on Fabric Update + +on: + pull_request: + types: [closed] + branches: [main] + +permissions: + contents: write + +jobs: + tag-release: + if: github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'update fabric to') + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Determine new version + id: version + run: | + # Get current tag + 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 and push tag + run: | + NEW_TAG="${{ steps.version.outputs.new_tag }}" + + # Extract fabric version from PR title + FABRIC_VERSION=$(echo "${{ github.event.pull_request.title }}" | grep -oP '(?<=update fabric to )[0-9.]+') + + # Create annotated tag + git tag -a "$NEW_TAG" -m "Release $NEW_TAG - Update fabric to $FABRIC_VERSION" + + # Push tag + git push origin "$NEW_TAG" + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.new_tag }} + name: ${{ steps.version.outputs.new_tag }} + body: | + ## What's Changed + + - Updated danielmiessler/fabric to version ${{ github.event.pull_request.title }} + + **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.version.outputs.current_tag }}...${{ steps.version.outputs.new_tag }} + draft: false + prerelease: false \ No newline at end of file diff --git a/.github/workflows/update-fabric.yml b/.github/workflows/update-fabric.yml new file mode 100644 index 0000000..2d6468a --- /dev/null +++ b/.github/workflows/update-fabric.yml @@ -0,0 +1,114 @@ +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 \ No newline at end of file From 5e1892155b0bb70a77ed8aeafb3fc6e56458e5d7 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 30 Jun 2025 08:29:17 +0200 Subject: [PATCH 2/2] fix: add newlines at end of workflow files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/tag-release.yml | 2 +- .github/workflows/update-fabric.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index 7b49e6a..0632ae2 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -67,4 +67,4 @@ jobs: **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.version.outputs.current_tag }}...${{ steps.version.outputs.new_tag }} draft: false - prerelease: false \ No newline at end of file + prerelease: false diff --git a/.github/workflows/update-fabric.yml b/.github/workflows/update-fabric.yml index 2d6468a..35acdb0 100644 --- a/.github/workflows/update-fabric.yml +++ b/.github/workflows/update-fabric.yml @@ -111,4 +111,4 @@ jobs: *This PR was automatically created by the update-fabric workflow.* labels: | dependencies - automated \ No newline at end of file + automated