1- name : Compile SELinux Policy
1+ name : Create tar.gz Folders for Latest Release
22
33on :
4- push :
5- branches :
6- - main
7- paths :
8- - ' logrotate/selinux-policy/ee-logrotate.te'
9- - ' .github/workflows/compile-selinux-policy.yml'
104 workflow_dispatch :
5+ push :
6+ # branches:
7+ # - main # Trigger khi có thay đổi trên branch chính
8+ tags :
9+ - ' v*' # Trigger khi có tag mới
1110
1211jobs :
13- compile-policy :
14- # Sử dụng container Fedora để có sẵn các công cụ SELinux
15- container : fedora:latest
12+ build-and-upload :
1613 runs-on : ubuntu-latest
1714 permissions :
1815 contents : write
1916
2017 steps :
2118 - name : Checkout repository
2219 uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 0 # Needed to get all tags for version comparison
2322
24- - name : Install SELinux build tools and Git
25- # Cài đặt các gói cần thiết và cả git trong container Fedora
26- run : dnf install -y policycoreutils-devel selinux-policy-devel make git
27-
28- - name : Compile and package SELinux policy
29- run : |
30- # Di chuyển vào thư mục chứa file .te
31- cd logrotate/selinux-policy/
32-
33- # Bước 1: Biên dịch file .te thành .mod
34- echo "Compiling ee-logrotate.te to ee-logrotate.mod..."
35- checkmodule -M -m -o ee-logrotate.mod ee-logrotate.te
36-
37- # Bước 2: Tạo policy package (.pp) từ file .mod
38- echo "Creating ee-logrotate.pp from ee-logrotate.mod..."
39- semodule_package -o ee-logrotate.pp -m ee-logrotate.mod
40-
41- # Lấy thông tin tag mới nhất, vì upload release cần tag
4223 - name : Get the latest tag
4324 id : get_tag
4425 run : |
4526 latest_tag=$(git describe --tags --abbrev=0)
4627 echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
4728 echo "📌 Latest tag: ${latest_tag}"
4829
49- # Tải file .pp lên GitHub Release
50- - name : Upload compiled policy file to release
30+ - name : Create tar.gz archives from each directory
31+ run : |
32+ for dir in */; do
33+ dirname="${dir%/}"
34+ if [ "$dirname" == ".github" ]; then
35+ echo "⏩ Skipping .github directory"
36+ continue
37+ fi
38+ echo "📦 Creating '${dirname}.tar.gz'..."
39+ tar --exclude="${dirname}/README.md" -czf "${dirname}.tar.gz" "$dirname"
40+ done
41+
42+ - name : Upload tar.gz files to release
5143 env :
5244 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5345 run : |
54- # Di chuyển file .pp về thư mục gốc để dễ dàng upload
55- mv logrotate/selinux-policy/ee-logrotate.pp .
56- gh release upload ${{ steps.get_tag.outputs.latest_tag }} ee-logrotate.pp --clobber
57- echo "✅ Successfully uploaded ee-logrotate.pp to release '${{ steps.get_tag.outputs.latest_tag }}'"
46+ gh release upload ${{ steps.get_tag.outputs.latest_tag }} *.tar.gz --clobber
47+ echo "✅ Successfully uploaded tar.gz files to release '${{ steps.get_tag.outputs.latest_tag }}'"
48+
49+ - name : Clean up artifacts
50+ run : rm -f *.tar.gz
0 commit comments