Skip to content

Commit

Permalink
Merge pull request #154 from Teingi/master
Browse files Browse the repository at this point in the history
github Action build obdiag rpm
  • Loading branch information
Teingi authored Apr 17, 2024
2 parents 7fc450c + 57103e4 commit 37753f4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 12 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build_rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: build rpm

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build-and-package-x86_64:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.8'

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
pip3 install -r requirements3.txt
- name: Set up RPM build env
run: |
sudo apt-get update && sudo apt-get install -y rpm
- name: Build package
run: |
pwd
ls -lh
export RELEASE=`date +%Y%m%d%H%M`
cat ./rpm/oceanbase-diagnostic-tool.spec
rpmbuild -bb ./rpm/oceanbase-diagnostic-tool.spec
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
with:
name: obdiag
path: /home/runner/rpmbuild/RPMS/x86_64/oceanbase-diagnostic-tool-*.rpm
retention-days: 3
16 changes: 4 additions & 12 deletions rpm/oceanbase-diagnostic-tool.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: oceanbase-diagnostic-tool
Version:2.0.0
Release: %(echo $RELEASE)%{?dist}
Release: 1%{?dist}
Summary: oceanbase diagnostic tool program
Group: Development/Tools
Url: [email protected]:oceanbase/oceanbase-diagnostic-tool.git
Expand All @@ -16,23 +16,15 @@ oceanbase diagnostic tool program

%install
RPM_DIR=$OLDPWD
SRC_DIR=$OLDPWD/..
SRC_DIR=$OLDPWD
BUILD_DIR=$OLDPWD/rpmbuild
cd $SRC_DIR/
rm -rf build.log build dist oceanbase-diagnostic-tool.spec
if [ `git log |head -n1 | awk -F' ' '{print $2}'` ]; then
CID=`git log |head -n1 | awk -F' ' '{print $2}'`
BRANCH=`git rev-parse --abbrev-ref HEAD`
else
CID='UNKNOWN'
BRANCH='UNKNOWN'
fi
DATE=`date '+%b %d %Y %H:%M:%S'`
DATE=`date`
VERSION="$RPM_PACKAGE_VERSION"

source py-env-activate py38
cd $SRC_DIR
pip install -r requirements3.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pwd
cp -f main.py obdiag.py
sed -i "s/<B_TIME>/$DATE/" ./common/version.py && sed -i "s/<VERSION>/$VERSION/" ./common/version.py
mkdir -p $BUILD_DIR/SOURCES ${RPM_BUILD_ROOT}
Expand Down

0 comments on commit 37753f4

Please sign in to comment.