llvm-capstone/.github/workflows/LLVM-Auto-Updater.yml

117 lines
3.8 KiB
YAML
Raw Normal View History

2023-05-07 14:56:36 +00:00
name: Weekly-LLVM-Release-Update
2023-05-06 09:06:37 +00:00
on:
workflow_dispatch:
inputs:
tag_name:
description: "LLVM Version"
required: false
schedule:
- cron: "0 0 * * 1"
permissions:
contents: write
jobs:
2023-05-07 14:54:33 +00:00
merge-llvm:
2023-05-06 09:06:37 +00:00
runs-on: ubuntu-latest
2023-05-07 15:11:42 +00:00
outputs:
branch_version: ${{ steps.step1.outputs.branch_version }}
2023-05-06 09:06:37 +00:00
steps:
- name: Get LLVM version
2023-05-07 15:11:42 +00:00
id: step1
2023-05-06 09:06:37 +00:00
run: |
if [[ -z $github_event_inputs_tag_name ]]; then
tag_name=$(curl -sL https://api.github.com/repos/llvm/llvm-project/releases/latest | jq -r '.tag_name')
else
tag_name=$github.event.inputs.tag_name
fi
echo "Using version: $tag_name"
echo "tag_name=${tag_name}" >> $GITHUB_ENV
version=$(echo $tag_name | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
echo "version=${version}" >> $GITHUB_ENV
major_version=$(echo $version | awk -F '.' '{print $1}')
echo "major_version=${major_version}" >> $GITHUB_ENV
branch_version='release/'$major_version'.x'
echo "branch_version=${branch_version}" >> $GITHUB_ENV
is_official_release=$(curl -sL https://api.github.com/repos/llvm/llvm-project/releases/latest | jq -r '.prerelease')
echo "is_official_release=${is_official_release}" >> $GITHUB_ENV
2023-05-08 03:46:02 +00:00
echo "branch_version=${branch_version}" >> $GITHUB_OUTPUT
2023-05-06 09:06:37 +00:00
- name: Ensure official release
run: |
if [[ "${{ env.is_official_release }}" != "false" ]]; then
exit 0
fi
2023-05-07 14:27:54 +00:00
- name: Checkout LLVM-project
2023-05-06 09:06:37 +00:00
uses: actions/checkout@v3
2023-05-07 06:12:34 +00:00
with:
2023-05-07 09:37:51 +00:00
fetch-depth: 1
2023-05-07 06:12:34 +00:00
2023-05-07 06:57:35 +00:00
- name: Sparse checkout LLVM-project
2023-05-06 09:06:37 +00:00
run: |
2023-05-07 14:27:54 +00:00
git clone --depth 1 --filter=blob:none --sparse --branch ${{ env.branch_version }} https://github.com/llvm/llvm-project.git ../llvm-project
2023-05-06 09:06:37 +00:00
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
2023-05-07 14:35:38 +00:00
cd ../llvm-project
2023-05-07 06:48:30 +00:00
echo "sparse checkout"
2023-05-07 06:12:34 +00:00
git sparse-checkout set llvm/ cmake/ third-party/
2023-05-07 09:19:13 +00:00
rm -rf .git/ .github/
2023-05-07 07:21:12 +00:00
ls -la
2023-05-07 14:35:38 +00:00
cd -
- name: Add files to branch ${{ env.branch_version }}
run: |
branch_exists=$(git ls-remote --exit-code --heads origin ${{env.branch_version}})
echo "branch_exists=${branch_exists}" >> $GITHUB_ENV
git checkout ${{ env.branch_version }} 2>/dev/null || git checkout -b ${{ env.branch_version }}
if [[ "${{ env.branch_exists }}" = true ]]; then
git pull origin ${{ env.branch_version }}
git push -u origin ${{ env.branch_version }}
rm -rf !\(.git\|.github\)
fi
cp -r ../llvm-project/* .
2023-05-07 15:17:49 +00:00
ls -la
2023-05-07 14:35:38 +00:00
git add .
2023-05-07 06:48:30 +00:00
2023-05-07 14:40:03 +00:00
- name: Update branch ${{ env.branch_version }}
if: ${{ env.branch_exists }}
run: |
echo "Branch already exists, update."
if [[ `git status --porcelain` ]]; then
git commit -m "Update LLVM ${{ env.branch_version }}"
else
echo "No changes to commit."
exit 0
fi
2023-05-07 14:18:40 +00:00
2023-05-07 14:40:03 +00:00
- name: Commit new branch ${{ env.branch_version }}
if: ${{ ! env.branch_exists }}
run: |
git commit -m "Add LLVM ${{ env.branch_version }}"
2023-05-07 14:18:40 +00:00
2023-05-07 15:52:17 +00:00
- name: Push new branch
run: |
git push origin ${{ env.branch_version }} -f
2023-05-07 15:24:02 +00:00
2023-05-07 15:52:17 +00:00
build-llvm-tblgen:
runs-on: ubuntu-latest
needs: merge-llvm
env:
branch_version: ${{ needs.merge-llvm.outputs.branch_version }}
steps:
2023-05-07 16:01:06 +00:00
- uses: lukka/get-cmake@latest
2023-05-07 15:52:17 +00:00
- name: Checkout llvm-capstone
uses: actions/checkout@v3
with:
ref: ${{ env.branch_version }}
2023-05-07 15:11:42 +00:00
2023-05-07 15:52:17 +00:00
- name: Build llvm tblgen
run: |
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ../llvm
cmake --build . --target llvm-tblgen --config Debug