1
- name : Compile SELinux Policy
1
+ name : Create tar.gz Folders for Latest Release
2
2
3
3
on :
4
- push :
5
- branches :
6
- - main
7
- paths :
8
- - ' logrotate/selinux-policy/ee-logrotate.te'
9
- - ' .github/workflows/compile-selinux-policy.yml'
10
4
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
11
10
12
11
jobs :
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 :
16
13
runs-on : ubuntu-latest
17
14
permissions :
18
15
contents : write
19
16
20
17
steps :
21
18
- name : Checkout repository
22
19
uses : actions/checkout@v4
20
+ with :
21
+ fetch-depth : 0 # Needed to get all tags for version comparison
23
22
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
42
23
- name : Get the latest tag
43
24
id : get_tag
44
25
run : |
45
26
latest_tag=$(git describe --tags --abbrev=0)
46
27
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
47
28
echo "📌 Latest tag: ${latest_tag}"
48
29
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
51
43
env :
52
44
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53
45
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