-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (173 loc) · 7.94 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Generate Samba Debian Package
on:
push:
branches: ["main"]
tags:
- deb*
- all*
env:
IMAGE_NAME: generate_samba_deb
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run tests
run: |
if ! [ -f Dockerfile ]; then
docker
fi
build:
needs: prepare
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d-%H%M%S')"
- name: Build Deb Package For Ubuntu
id: build_ubuntu_package
run: |
build_number="${{ github.run_number }}"
mkdir opt ubuntu_src
cp -r src/* ubuntu_src/
tar -zxvf samba_source/samba-ubuntu*.tar.gz
cp -r opt/samba4/* ubuntu_src/
cp -r build/debian ubuntu_src/DEBIAN
touch ubuntu_src/DEBIAN/md5sums
touch ubuntu_src/DEBIAN/control
find ./ -type f -exec md5sum {} \; > ubuntu_src/DEBIAN/md5sums
size=$(du -s ubuntu_src | cut -f 1)
echo "Package: sambahvl
Version: $build_number
Installed-Size: $size
Priority: optional
Maintainer: Duygu Ölmez <[email protected]>, Zeki Ahmet Bayar <[email protected]>
Section: admin
Depends: libcups2, libjansson4, libpython3.8, libgpgme11, ntpdate, krb5-user, python3-dnspython, openssh-server, ntp, python3-markdown, liblmdb0, openssl, libunwind-dev, libglib2.0-dev
Date : $GITHUB_RUN_ID
Architecture: amd64
Description: Deb package for Samba Configuration
" > ubuntu_src/DEBIAN/control
chmod 755 ubuntu_src/DEBIAN/postinst
. build/version
ubuntu_package_name="sambahvl-ubuntu-$ver-$build_number"
mv ubuntu_src "$ubuntu_package_name"
dpkg-deb -Zgzip --build "$ubuntu_package_name"
echo ::set-output name=path_ubuntu::$(pwd)/"$ubuntu_package_name".deb
echo ::set-output name=filename_ubuntu::"$ubuntu_package_name".deb
- name: Build Packages for RPM and Deb
id: build_package
run: |
rm -rf opt
rm -rf ubuntu_src
build_number="${{ github.run_number }}"
mkdir opt deb_src
cp -r src/* deb_src/
tar -zxvf samba_source/samba-debian*.tar.gz
cp -r opt/samba4/* deb_src/
mv build/debian deb_src/DEBIAN
touch deb_src/DEBIAN/md5sums
touch deb_src/DEBIAN/control
find ./ -type f -exec md5sum {} \; > deb_src/DEBIAN/md5sums
size=$(du -s deb_src | cut -f 1)
echo "Package: sambahvl
Version: $build_number
Installed-Size: $size
Priority: optional
Maintainer: Duygu Ölmez <[email protected]>, Zeki Ahmet Bayar <[email protected]>
Section: admin
Depends: libcups2, libjansson4, libpython3.7, libgpgme11, ntpdate, krb5-user, python3-dnspython, openssh-server, ntp, python3-markdown, liblmdb0, openssl, libunwind-dev, libglib2.0-dev
Date : $GITHUB_RUN_ID
Architecture: amd64
Description: Deb package for Samba Configuration
" > deb_src/DEBIAN/control
chmod 755 deb_src/DEBIAN/postinst
. build/version
deb_package_name="sambahvl-debian-$ver-$build_number"
mv deb_src "$deb_package_name"
dpkg-deb -Zgzip --build "$deb_package_name"
sudo apt-get install rpm
mkdir -p opt/samba4/usr/lib/systemd/system/
cp src/etc/systemd/system/samba4.service opt/samba4/usr/lib/systemd/system/
ls -al /
rpmbuildroot=$(pwd)/build
echo "%_topdir $rpmbuildroot/rpmbuild" > ~/.rpmmacros
mkdir -p $rpmbuildroot/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp -r src/usr/* opt/samba4/usr/
cp -r opt/samba4/* $rpmbuildroot/rpmbuild/BUILD
build_number="${{ github.run_number }}"
echo """Name: sambahvl
Version: $ver
Release: $build_number
Summary: Rpm package for Samba Configuration
License: GPLv2
Packager: Fatih Arslan Tugay
Requires: iniparser libldb libtalloc libtdb libtevent gnutls-devel libacl-devel openldap-devel pam-devel readline-devel krb5-devel cups-devel epel-release python3-devel lmdb-devel lmdb gpgme-devel jansson-devel libarchive-devel python3 krb5-workstation python3-dns krb5-workstation avahi-libs avahi-libs oddjob oddjob-mkhomedir
%description
Rpm package for Samba Configuration
%install
mkdir -p %{buildroot}
cp -ra * %{buildroot}/
%post
kill -TERM 1
chmod +x /usr/local/bin/smb*
ln -s /usr/local/bin/* /usr/bin/
systemctl stop sssd
systemctl disable sssd
%files""" > $rpmbuildroot/rpmbuild/SPECS/sambahvl.spec
find ./opt/samba4/ -type f,l | sort | sed "s+.*opt/samba4++g" | grep -v "\/man\/" >> $rpmbuildroot/rpmbuild/SPECS/sambahvl.spec
find ./opt/samba4/ -depth -empty -type d | sed "s+.*opt/samba4++g" >> $rpmbuildroot/rpmbuild/SPECS/sambahvl.spec
echo "%define _unpackaged_files_terminate_build 0" >> $rpmbuildroot/rpmbuild/SPECS/sambahvl.spec
rpmbuild -ba $rpmbuildroot/rpmbuild/SPECS/sambahvl.spec
rpmpath=$(find $rpmbuildroot/rpmbuild/RPMS/ -type f)
echo ::set-output name=path_deb::$(pwd)/"$deb_package_name".deb
echo ::set-output name=filename_deb::"$deb_package_name".deb
echo ::set-output name=path::$rpmpath
echo ::set-output name=filename::$(echo $rpmpath | sed "s/.*\///")
echo ::set-output name=version::"$ver"
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release.${{ github.run_number }}
release_name: "Release ${{ github.run_number }}"
body: |
Changes in this Release
- ${{ github.event.commits[0].message }}
draft: false
prerelease: false
- name: Upload the Debian package to Release Assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build_package.outputs.path_deb }}
asset_name: ${{ steps.build_package.outputs.filename_deb }}
asset_content_type: application/vnd.debian.binary-package
- name: Upload the Ubuntu package to Release Assets
id: upload-release-asset-2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build_ubuntu_package.outputs.path_ubuntu }}
asset_name: ${{ steps.build_ubuntu_package.outputs.filename_ubuntu }}
asset_content_type: application/vnd.debian.binary-package
- name: Upload the CentOS package to Release Assets
id: upload-release-asset-3
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build_package.outputs.path }}
asset_name: ${{ steps.build_package.outputs.filename }}
asset_content_type: application/vnd.debian.binary-package