generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update clang-format binary with a workflow
- Loading branch information
1 parent
b5a2501
commit ab75a46
Showing
9 changed files
with
157 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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,144 @@ | ||
name: Update Clang | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '6 6 * * *' | ||
|
||
# Cancel outdated jobs | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
jobs: | ||
|
||
# Prepare environment and build the plugin | ||
update-clang: | ||
name: Update Clang | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.properties.outputs.version }} | ||
changelog: ${{ steps.properties.outputs.changelog }} | ||
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }} | ||
steps: | ||
|
||
- name: Fetch Sources | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check for updates | ||
id: check-for-updates | ||
run: | | ||
latest_tag=$(gh release view --repo llvm/llvm-project --json tagName --jq .tagName) | ||
echo "Latest tag: $latest_tag" | ||
branch_name="autoupdate-clang-$latest_tag" | ||
current_version=$(cat src/main/resources/clang-format-tag.txt) | ||
found_branch=$(gh api repos/llvm/llvm-project/branches/$branch_name --jq .name 2> /dev/null || true) | ||
echo "Branch found: $found_branch" | ||
# We need to update if: 1. The current branch is outdated and 2. There is no other branch with the same name | ||
if [ "$latest_tag" != "$current_version" ] && [ "$found_branch" != "$branch_name" ]; then | ||
echo -e "\033[31mUpdate to $latest_tag is needed\033[0m" | ||
echo "update_needed=true" >> $GITHUB_OUTPUT | ||
echo "version=$latest_tag" >> $GITHUB_OUTPUT | ||
else | ||
echo -e "\033[32mUpdate to $latest_tag is not needed\033[0m" | ||
echo "update_needed=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
if: steps.check-for-updates.outputs.update_needed == 'true' | ||
with: | ||
python-version: '3.13' | ||
|
||
- name: Generate schema | ||
if: steps.check-for-updates.outputs.update_needed == 'true' | ||
run: | | ||
latest_tag=${{ steps.check-for-updates.outputs.version }} | ||
cd schemaGenerator | ||
python generate_schema.py --download --clang-tag $latest_tag | ||
- name: Update clang-format Binary | ||
if: steps.check-for-updates.outputs.update_needed == 'true' | ||
run: | | ||
latest_tag=${{ steps.check-for-updates.outputs.version }} | ||
echo "Downloading windows binary" | ||
echo "::group::Download Details" | ||
gh release download $latest_tag --repo llvm/llvm-project --pattern "clang+llvm-*windows-msvc.tar.xz" --dir clang | ||
tar -xvf clang/clang+llvm-*windows-msvc.tar.xz --strip-components=2 -C clang --wildcards --no-anchored 'clang-format.exe' | ||
mkdir -p src/main/resources/clang-format-win | ||
mv clang/clang-format.exe src/main/resources/clang-format-win/clang-format.exe | ||
rm clang/clang+llvm-* | ||
echo "::endgroup::" | ||
echo "Downloading linux aarch64 binary" | ||
echo "::group::Download Details" | ||
gh release download $latest_tag --repo llvm/llvm-project --pattern "clang+llvm-*-aarch64-linux-gnu.tar.xz" --dir clang | ||
tar -xvf clang/clang+llvm-*-aarch64-linux-gnu.tar.xz --strip-components=2 -C clang --wildcards --no-anchored 'clang-format' | ||
mkdir -p src/main/resources/clang-format-linux-aarch64 | ||
mv clang/clang-format src/main/resources/clang-format-linux-aarch64/clang-format | ||
chmod +x src/main/resources/clang-format-linux-aarch64/clang-format | ||
rm clang/clang+llvm-* | ||
echo "::endgroup::" | ||
echo "Downloading linux armv7a binary" | ||
echo "::group::Download Details" | ||
gh release download $latest_tag --repo llvm/llvm-project --pattern "clang+llvm-*-armv7a-linux-*.tar.gz" --dir clang | ||
tar -xvf clang/clang+llvm-*-armv7a-linux-*.tar.gz --strip-components=2 -C clang --wildcards --no-anchored 'clang-format' | ||
mkdir -p src/main/resources/clang-format-linux-armv7a | ||
mv clang/clang-format src/main/resources/clang-format-linux-armv7a/clang-format | ||
chmod +x src/main/resources/clang-format-linux-armv7a/clang-format | ||
rm clang/clang+llvm-* | ||
echo "::endgroup::" | ||
echo "Downloading macos x64 binary" | ||
echo "::group::Download Details" | ||
gh release download $latest_tag --repo llvm/llvm-project --pattern "LLVM-*-macOS-X64.tar.xz" --dir clang | ||
tar -xvf clang/LLVM-*-macOS-X64.tar.xz --strip-components=2 -C clang --wildcards --no-anchored 'clang-format' | ||
mkdir -p src/main/resources/clang-format-macos-x64 | ||
mv clang/clang-format src/main/resources/clang-format-macos-x64/clang-format | ||
chmod +x src/main/resources/clang-format-macos-x64/clang-format | ||
rm clang/LLVM-* | ||
echo "::endgroup::" | ||
echo "Downloading macos arm64 binary" | ||
echo "::group::Download Details" | ||
gh release download $latest_tag --repo llvm/llvm-project --pattern "LLVM-*-macOS-ARM64.tar.xz" --dir clang | ||
tar -xvf clang/LLVM-*-macOS-ARM64.tar.xz --strip-components=2 -C clang --wildcards --no-anchored 'clang-format' | ||
mkdir -p src/main/resources/clang-format-macos-arm64 | ||
mv clang/clang-format src/main/resources/clang-format-macos-arm64/clang-format | ||
chmod +x src/main/resources/clang-format-macos-arm64/clang-format | ||
rm clang/LLVM-* | ||
echo "::endgroup::" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create branch and commit | ||
if: steps.check-for-updates.outputs.update_needed == 'true' | ||
run: | | ||
latest_tag=${{ steps.check-for-updates.outputs.version }} | ||
echo $latest_tag > src/main/resources/clang-format-tag.txt | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Alessandro Arcangeli (bot)" | ||
branch_name="autoupdate-clang-$latest_tag" | ||
git checkout -b $branch_name | ||
git add src/* | ||
git add schemaGenerator/* | ||
git status | ||
git commit -m "Update clang-format to $latest_tag" | ||
- name: Create Pull Request | ||
if: steps.check-for-updates.outputs.update_needed == 'true' | ||
run: | | ||
latest_tag=${{ steps.check-for-updates.outputs.version }} | ||
branch_name="autoupdate-clang-$latest_tag" | ||
echo "Pushing branch $branch_name" | ||
git push origin $branch_name | ||
echo "Creating pull request" | ||
gh pr create --title "Update clang-format to $latest_tag" --body "Update clang-format to $latest_tag" --base main --head $branch_name | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.intellijPlatform | ||
.qodana | ||
build | ||
__pycache__ |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
llvmorg-19.1.7 | ||
FORCE_REBUILD |
This file was deleted.
Oops, something went wrong.