-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add GitHub Actions to auto-update fabric dependency #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.