diff --git a/automation/makefile b/automation/makefile new file mode 100644 index 0000000000000000000000000000000000000000..46b99a6aeed8f7108bb2529481216f7716cf19af --- /dev/null +++ b/automation/makefile @@ -0,0 +1,39 @@ +BINARY_NAME := PilotGo-plugin-automation +go_build_cflags = -ldflags "-s -w" + +.PHONY: build-web build-server rpm clean + +build-web: + @echo "Building web dist..." + cd web + yarn install + yarn run build + +build-server: + @echo "Building server binary..." + GOSUMDB=off GO111MODULE=on go build $(go_build_cflags) -o $(BINARY_NAME) server/cmd/main.go + +PWD_DIR := $(CURDIR) +PARENT_DIR := $(abspath $(PWD_DIR)/..) +ARCH := $(shell uname -m) + +rpm: + @echo "Building tar..." + rm -f $(PWD_DIR)/$(BINARY_NAME).tar.gz + cd $(PARENT_DIR) && tar -czvf $(BINARY_NAME).tar.gz automation + + @echo "Moving tar..." + mv $(PARENT_DIR)/$(BINARY_NAME).tar.gz /root/rpmbuild/SOURCES/ + cp $(PWD_DIR)/server/scripts/PilotGo-plugin-automation.spec /root/rpmbuild/SPECS/ + + @echo "Building rpm..." + cd /root/rpmbuild/SPECS && rpmbuild -ba PilotGo-plugin-automation.spec + + @echo "Coping rpm..." + cp /root/rpmbuild/RPMS/$(ARCH)/*.rpm $(PWD_DIR)/ + + +clean: + @echo "Cleaning up..." + rm -rf web/dist + rm -rf $(BINARY_NAME) \ No newline at end of file diff --git a/automation/server/scripts/PilotGo-plugin-automation.spec b/automation/server/scripts/PilotGo-plugin-automation.spec new file mode 100644 index 0000000000000000000000000000000000000000..ebda918422c01498177d785832103f16b5a98262 --- /dev/null +++ b/automation/server/scripts/PilotGo-plugin-automation.spec @@ -0,0 +1,61 @@ +%define debug_package %{nil} + +Name: PilotGo-plugin-automation +Version: 3.0.0 +Release: 1 +Summary: PilotGo automation plugin provides script execution and orchestration. +License: MulanPSL-2.0 +URL: https://gitee.com/openeuler/PilotGo-plugins/automation +Source0: PilotGo-plugin-automation.tar.gz + +BuildRequires: systemd +Provides: pilotgo-plugin-automation = %{version}-%{release} + +%description +PilotGo automation plugin provides script execution and orchestration. + +%prep +%autosetup -p1 -n automation + +%build +pushd server +GO111MODULE=on go build -o PilotGo-plugin-automation ./cmd/main.go +popd + +pushd web +yarn install +yarn run build +popd + +%install +mkdir -p %{buildroot}/opt/PilotGo/plugin/automation/{server/log,web/dist} +install -D -m 0755 server/PilotGo-plugin-automation %{buildroot}/opt/PilotGo/plugin/automation/server +install -D -m 0644 server/automation.yml %{buildroot}/opt/PilotGo/plugin/automation/server/automation.yml +install -D -m 0644 server/scripts/PilotGo-plugin-automation.service %{buildroot}%{_unitdir}/PilotGo-plugin-automation.service +cp -rf web/dist %{buildroot}/opt/PilotGo/plugin/automation/web + +%post +%systemd_post PilotGo-plugin-automation.service + +%preun +%systemd_preun PilotGo-plugin-automation.service + +%postun +%systemd_postun PilotGo-plugin-automation.service + +%files +%dir /opt/PilotGo +%dir /opt/PilotGo/plugin +%dir /opt/PilotGo/plugin/automation +%dir /opt/PilotGo/plugin/automation/server +%dir /opt/PilotGo/plugin/automation/server/log +/opt/PilotGo/plugin/automation/server/PilotGo-plugin-automation +/opt/PilotGo/plugin/automation/server/automation.yml +%{_unitdir}/PilotGo-plugin-automation.service +/opt/PilotGo/plugin/automation/web/dist + + +%changelog +* Wed Sep 03 2025 zhanghan - 3.0.0-1 +- Package init +