prepare for release 3.3.0 #17
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
| name: Run swift-format | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| swiftformat: | |
| name: "swift-format" | |
| runs-on: ubuntu-latest | |
| container: | |
| image: swift:latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v3 | |
| - name: Check out UBKit | |
| run: | | |
| git clone https://github.com/UbiqueInnovation/ubkit-ios __ubkit | |
| mv __ubkit/.swift-format . | |
| - name: Run swift-format | |
| run: swift format --in-place --parallel --recursive . | |
| - name: Delete UBKit | |
| run: | | |
| rm -rf __ubkit | |
| # Keep .swift-format in project | |
| - name: Configure git | |
| run: | | |
| git config --global --add safe.directory "$(pwd)" | |
| git config user.name "GitHub Actions Bot" | |
| git config user.email "<>" | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if git status --porcelain .swift-format | grep -q .; then | |
| echo "swift_format_changes=true" >> $GITHUB_ENV | |
| else | |
| echo "swift_format_changes=false" >> $GITHUB_ENV | |
| fi | |
| if git status --porcelain '*.swift' | grep -q .; then | |
| echo "swift_files_changes=true" >> $GITHUB_ENV | |
| else | |
| echo "swift_files_changes=false" >> $GITHUB_ENV | |
| fi | |
| - name: Add commit for swift-format file | |
| if: env.swift_format_changes == 'true' | |
| run: | | |
| git add .swift-format | |
| git commit -m "Update .swift-format" | |
| - name: Add commit for swift-format | |
| if: env.swift_files_changes == 'true' | |
| run: | | |
| git add '**/*.swift' | |
| git commit -m "[Generated] swift-format" | |
| # Store the commit hash for later use | |
| echo "FORMAT_COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
| - name: Update git-blame-ignore-revs | |
| if: env.swift_files_changes == 'true' | |
| run: | | |
| # Add the formatting commit hash to .git-blame-ignore-revs | |
| echo "$FORMAT_COMMIT_HASH" >> .git-blame-ignore-revs | |
| git add .git-blame-ignore-revs | |
| git commit -m "Add swift-format commit to .git-blame-ignore-revs" | |
| - name: Create pull request | |
| if: env.swift_files_changes == 'true' || env.swift_format_changes == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| branch: "generated/swift-format" | |
| delete-branch: true | |
| title: "[Generated] swift-format" | |
| body: "This action automatically runs swift-format on the project. Check the changes and merge them!" |