1
- name : Create tar.gz Folders for Latest Release
1
+ name : Compile SELinux Policy
2
2
3
3
on :
4
- workflow_dispatch :
5
4
push :
6
5
branches :
7
- - main # Trigger khi có thay đổi trên branch chính
8
- tags :
9
- - ' v*' # Trigger khi có tag mới
6
+ - main
7
+ paths :
8
+ - ' logrotate/selinux-policy/ee-logrotate.te'
9
+ - ' .github/workflows/compile-selinux-policy.yml'
10
+ workflow_dispatch :
10
11
11
12
jobs :
12
- build-and-upload :
13
+ compile-policy :
14
+ # Sử dụng container Fedora để có sẵn các công cụ SELinux
15
+ container : fedora:latest
13
16
runs-on : ubuntu-latest
14
17
permissions :
15
18
contents : write
16
19
17
20
steps :
18
21
- name : Checkout repository
19
22
uses : actions/checkout@v4
20
- with :
21
- fetch-depth : 0 # Needed to get all tags for version comparison
22
23
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
+ # Đổi tên file đầu ra để khớp với tên module bên trong file .te
36
+ checkmodule -M -m -o ee-logrotate.mod ee-logrotate.te
37
+
38
+ # Bước 2: Tạo policy package (.pp) từ file .mod
39
+ echo "Creating ee-logrotate.pp from ee-logrotate.mod..."
40
+ semodule_package -o ee-logrotate.pp -m ee-logrotate.mod
41
+
42
+ # Thêm một bước để lấy thông tin tag mới nhất, vì upload release cần tag
23
43
- name : Get the latest tag
24
44
id : get_tag
25
45
run : |
26
46
latest_tag=$(git describe --tags --abbrev=0)
27
47
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
28
48
echo "📌 Latest tag: ${latest_tag}"
29
49
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
50
+ # Thêm bước này để tải file .pp lên GitHub Release
51
+ - name : Upload compiled policy file to release
43
52
env :
44
53
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
45
54
run : |
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 }}'"
55
+ # Di chuyển file .pp về thư mục gốc để dễ dàng upload
56
+ mv logrotate/selinux-policy/ee-logrotate.pp .
57
+ # Đổi tên file để tải lên khớp với tên mới
58
+ gh release upload ${{ steps.get_tag.outputs.latest_tag }} ee-logrotate.pp --clobber
59
+ echo "✅ Successfully uploaded ee-logrotate.pp to release '${{ steps.get_tag.outputs.latest_tag }}'"
48
60
49
- - name : Clean up artifacts
50
- run : rm -f *.tar.gz
61
+ # Xóa bước upload artifact cũ
62
+ # - name: Upload compiled policy file
63
+ # uses: actions/upload-artifact@v4
64
+ # with:
65
+ # name: compiled-selinux-policy
66
+ # path: ee-logrotate.pp
67
+ # retention-days: 5
0 commit comments