Skip to content

Commit 3da6fe8

Browse files
authored
update
1 parent e05f2ed commit 3da6fe8

File tree

2 files changed

+34
-39
lines changed

2 files changed

+34
-39
lines changed

.github/workflows/compile-ee-logrotate-sepolicy.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Compile EE-LogRotate SELinux Policy
1+
name: Compile SELinux Policy
22

33
on:
44
push:
55
branches:
66
- main
77
paths:
88
- 'logrotate/selinux-policy/ee-logrotate.te'
9-
- '.github/workflows/compile-selinux-policy.yml'
9+
- '.github/workflows/compile-ee-logrotate-sepolicy.yml'
1010
workflow_dispatch:
1111

1212
jobs:
@@ -21,9 +21,9 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24-
- name: Install SELinux build tools
25-
# Cài đặt các gói cần thiết trong container Fedora
26-
run: dnf install -y policycoreutils-devel selinux-policy-devel make
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
2727

2828
- name: Compile and package SELinux policy
2929
run: |
@@ -32,6 +32,7 @@ jobs:
3232
3333
# Bước 1: Biên dịch file .te thành .mod
3434
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
3536
checkmodule -M -m -o ee-logrotate.mod ee-logrotate.te
3637
3738
# Bước 2: Tạo policy package (.pp) từ file .mod
@@ -53,6 +54,7 @@ jobs:
5354
run: |
5455
# Di chuyển file .pp về thư mục gốc để dễ dàng upload
5556
mv logrotate/selinux-policy/ee-logrotate.pp .
57+
# Đổi tên file để tải lên khớp với tên mới
5658
gh release upload ${{ steps.get_tag.outputs.latest_tag }} ee-logrotate.pp --clobber
5759
echo "✅ Successfully uploaded ee-logrotate.pp to release '${{ steps.get_tag.outputs.latest_tag }}'"
5860
Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,50 @@
1-
name: Compile SELinux Policy
1+
name: Create tar.gz Folders for Latest Release
22

33
on:
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

1211
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:
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

Comments
 (0)