From 1de6e997c2f083051e5739929c4be68641e56cf3 Mon Sep 17 00:00:00 2001 From: scanf3 <981544717@qq.com> Date: Mon, 9 Dec 2024 15:13:36 +0800 Subject: [PATCH] support publishing clang-format package --- .github/workflows/cipd.yml | 8 ++++++++ publish_clang_format.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 publish_clang_format.sh diff --git a/.github/workflows/cipd.yml b/.github/workflows/cipd.yml index d8cca79..6f9b186 100644 --- a/.github/workflows/cipd.yml +++ b/.github/workflows/cipd.yml @@ -11,6 +11,9 @@ on: description: 'the target cipd ensure file(s), split by comma. (e.g. gn.ensure)' required: true type: string + custom_script: + description: 'use the custom script after downloading cipd package by ensure files' + type: string jobs: download: @@ -35,6 +38,11 @@ jobs: - name: generate sha256 list run: python3 publish_helper.py --sha256-list + - name: run custom script + if: ${{ github.event.inputs.custom_script }} + run: | + bash ${{ github.event.inputs.custom_script }} + - name: push to release uses: ncipollo/release-action@v1 with: diff --git a/publish_clang_format.sh b/publish_clang_format.sh new file mode 100644 index 0000000..c849969 --- /dev/null +++ b/publish_clang_format.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# This script is used to extract clang-format executable file from llvm package + +root_dir=$PWD + +# clear the hash.md +cat /dev/null > hash.md + +# Traverse all tar.gz under llvm directory +for file in buildtools-*.tar.gz;do + # llvm files already exists + raw_folder=$(echo $file | sed 's/.tar.gz//g') + + # extract the clang-format file + clang_format_dir=$(echo $raw_folder | sed 's/llvm/clang-format/g') + mkdir $clang_format_dir + cp $root_dir/$raw_folder/bin/clang-format $clang_format_dir/ + + # package the artifacts + tar -czf $clang_format_dir.tar.gz $clang_format_dir + + # get the hash of file and write in hash.md + hash=$(openssl dgst -sha256 "$clang_format_dir.tar.gz" | awk '{print $2}') + echo "$clang_format_dir.tar.gz: $hash" - >> hash.md + + # delete llvm packages + rm -rf $file +done + +echo "Extraction and archiving completed." \ No newline at end of file