Skip to content

Commit

Permalink
[CPCLOUD-4590] Build RPM package
Browse files Browse the repository at this point in the history
  • Loading branch information
skafandri committed Nov 7, 2024
1 parent 9b24873 commit 8f3e985
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 67 deletions.
115 changes: 55 additions & 60 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,72 +18,67 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8]
python-version: [ 3.7, 3.8 ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
#python -m pip install flake8 pytest
python -m pip install wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
#- name: Lint with flake8
# run: |
# stop the build if there are Python syntax errors or undefined names
#flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
#python -m pip install flake8 pytest
python -m pip install wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
#- name: Lint with flake8
# run: |
# stop the build if there are Python syntax errors or undefined names
#flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
#flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
#- name: Test with pytest
# run: |
# pytest
- name: Test build
run: |
pip install .
python setup.py sdist bdist_egg bdist_wheel
#- name: Test with pytest
# run: |
# pytest
- name: Test build
run: |
pip install .
python setup.py sdist bdist_egg bdist_wheel
deploy:
env:
python-version: 3.8
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Build RPM package
run: python setup.py bdist_rpm
- uses: actions/upload-artifact@v4
with:
name: rpm package
path: dist/*.rpm
- name: Publish distribution 📦 to Test PyPI
if: github.ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v2
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Prepare RPM package
run: python setup.py bdist_rpm
- name: Copy spec file
run: cp agent360.spec build/bdist.linux-x86_64/rpm/SPECS/agent360.spec
- name: Build RPM package
run: cp agent360.spec build/bdist.linux-x86_64/rpm/SPECS/agent360.spec
- uses: actions/upload-artifact@v4
with:
name: rpm package
path: dist/*.rpm
- name: Publish distribution 📦 to Test PyPI
if: github.ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
14 changes: 7 additions & 7 deletions agent360.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%define name agen360
%define name agent360
%define version 1.3.1
%define unmangled_version 1.3.1
%define release 1
Expand Down Expand Up @@ -60,7 +60,7 @@ if [ -f /usr/lib/systemd/system/agent360.service ]; then
fi

%postun
rm -Rf $VenvDir/bin/agent360 /usr/share/doc/agent360 /etc/systemd/system/multi-user.target.wants/agent360.service /var/log/agent360.log /etc/agent360-token.ini >/dev/null 2>&1
rm -Rf %{VenvDir}/bin/agent360 /usr/share/doc/agent360 /etc/systemd/system/multi-user.target.wants/agent360.service /var/log/agent360.log /etc/agent360-token.ini >/dev/null 2>&1
if [ "$(grep -c '^agent360:' /etc/passwd)" = "1" ]; then
echo "Removing user and group agent360"
userdel agent360
Expand All @@ -76,13 +76,13 @@ systemctl daemon-reload
python3 -m build --sdist --wheel --outdir dist/

%install
python3 -m venv $VenvDir && echo -e "\\e[32m [SUCCESS] Virtual environment has been created\\e[m"
source $VenvDir/bin/activate && echo -e "\\e[32m [SUCCESS] Virtual environment has been activated\\e[m"
python3 -m venv %{VenvDir} && echo -e "\\e[32m [SUCCESS] Virtual environment has been created\\e[m"
. %{VenvDir}/bin/activate && echo -e "\\e[32m [SUCCESS] Virtual environment has been activated\\e[m"
# Install agent360 in virtual environment
pip3 install agent360 --upgrade && echo -e "\\e[32m [SUCCESS] Finished with agent360\\e[m"
pip3 install agent360 --upgrade --log INSTALLED_FILES && echo -e "\\e[32m [SUCCESS] Finished with agent360\\e[m"
deactivate
# Create a symlink for global access
ln -sf $VenvDir/bin/agent360 /usr/local/bin/agent360
ln -sf %{VenvDir}/bin/agent360 /usr/local/bin/agent360

%files -f INSTALLED_FILES
%files -f %{VenvDir}
%defattr(-,root,root)

0 comments on commit 8f3e985

Please sign in to comment.