1
0
mirror of https://github.com/QSCTech/zjunet.git synced 2026-01-22 19:54:48 +08:00

Add CI support (#76)

This commit is contained in:
Wu Yufei 2020-11-12 23:40:37 +08:00 committed by GitHub
parent 2fa9b0a1e8
commit 701a17a1e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 16 deletions

View File

@ -18,8 +18,16 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '^3.7' # request python 3.7+ for datetime.datetime.fromisoformat
- name: Build Packages - name: Build Packages
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: | run: |
python -m pip install --upgrade pip
python -m pip install urllib3
cd build cd build
./build.sh ./build.sh
@ -28,6 +36,6 @@ jobs:
with: with:
name: Release Packages name: Release Packages
path: | path: |
build/debain/*.deb build/debian/zjunet_*.deb
build/rpm/*.rpm build/rpm/zjunet_*.rpm
build/openwrt/*.opk build/openwrt/zjunet_*.opk

View File

@ -6,17 +6,46 @@ fail() {
echo -e "\033[31mERROR: Failed to build $1\033[0m" 1>&2 echo -e "\033[31mERROR: Failed to build $1\033[0m" 1>&2
} }
if [[ $# -gt 0 ]]; then
for arg in $*; do
case $arg in
rpm)
USE_RPM=1
;;
debian)
USE_DEB=1
;;
openwrt)
USE_OPK=1
;;
*)
echo "Invalid package $arg"
exit 1
esac
done
else
USE_RPM=1
USE_DEB=1
USE_OPK=1
fi
if [[ ! -z $USE_RPM ]]; then
pushd rpm > /dev/null pushd rpm > /dev/null
./build.sh $VERSION || fail 'RPM package' ./build.sh $VERSION || fail 'RPM package'
popd > /dev/null popd > /dev/null
fi
if [[ ! -z $USE_DEB ]]; then
pushd debian > /dev/null pushd debian > /dev/null
./build.sh $VERSION || fail 'Debian package' ./build.sh $VERSION || fail 'Debian package'
popd > /dev/null popd > /dev/null
fi
if [[ ! -z $USE_OPK ]]; then
pushd openwrt > /dev/null pushd openwrt > /dev/null
./build.sh $VERSION || fail 'OpenWrt package' ./build.sh $VERSION || fail 'OpenWrt package'
popd > /dev/null popd > /dev/null
fi
echo -ne "\033[0;32m" echo -ne "\033[0;32m"
find . -regextype posix-egrep -regex ".*\.(opk|deb|rpm)$" find . -regextype posix-egrep -regex ".*\.(opk|deb|rpm)$"

View File

@ -8,7 +8,7 @@ import datetime
def get_time(s): def get_time(s):
if 'fromisoformat' in dir(datetime.datetime): if 'fromisoformat' in dir(datetime.datetime):
return datetime.datetime.fromisoformat(s) return datetime.datetime.fromisoformat(s.replace('Z', '+00:00'))
else: else:
return __import__('dateutil.parser').parser.parse(s) return __import__('dateutil.parser').parser.parse(s)
@ -54,7 +54,7 @@ def get_author(name):
return data return data
def get_changelog(owner, name): def get_changelog(owner, name):
print('Reading releases of {} in {}'.format(owner, name), flush=True, file=sys.stderr) print('Reading releases of {1} in {0}'.format(owner, name), flush=True, file=sys.stderr)
releases = api_get('repos/{}/{}/releases'.format(owner, name)) releases = api_get('repos/{}/{}/releases'.format(owner, name))
releases = filter(lambda v: not v['draft'] and not v['prerelease'], releases) releases = filter(lambda v: not v['draft'] and not v['prerelease'], releases)

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
VERSION=$1 VERSION=$1
REALVERSION=`echo "$VERSION" | cut -d'-' -f1` REALVERSION=`echo "$VERSION" | cut -d'-' -f1`
@ -63,5 +63,5 @@ echo "" >> zjunet.spec
echo "%post" >> zjunet.spec echo "%post" >> zjunet.spec
echo "/usr/share/zjunet/zjunet-postinst || true" >> zjunet.spec echo "/usr/share/zjunet/zjunet-postinst || true" >> zjunet.spec
echo "" >> zjunet.spec echo "" >> zjunet.spec
../changelog.py rpm >> zjunet.spec
../../changelog.py rpm >> zjunet.spec