2023-07-24 12:12:13 +02:00
|
|
|
---
|
2023-07-24 11:05:38 +02:00
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: default
|
|
|
|
|
2023-08-06 10:49:44 +02:00
|
|
|
volumes:
|
|
|
|
- name: docs
|
|
|
|
host:
|
|
|
|
path: /opt/docs/platypush
|
|
|
|
|
2023-10-19 21:48:59 +02:00
|
|
|
- name: repos
|
|
|
|
host:
|
|
|
|
path: /opt/repos/platypush
|
|
|
|
|
2023-07-24 11:05:38 +02:00
|
|
|
steps:
|
2023-09-19 00:36:16 +02:00
|
|
|
|
|
|
|
###
|
|
|
|
### Mirror the current repository state to Github
|
|
|
|
###
|
|
|
|
|
2023-07-25 00:00:47 +02:00
|
|
|
- name: github-mirror
|
|
|
|
image: alpine
|
|
|
|
environment:
|
|
|
|
SSH_PUBKEY:
|
|
|
|
from_secret: ssh_pubkey
|
|
|
|
SSH_PRIVKEY:
|
|
|
|
from_secret: ssh_privkey
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- apk add --update --no-cache git openssh
|
|
|
|
- mkdir -p ~/.ssh
|
2023-08-06 00:44:03 +02:00
|
|
|
- echo $SSH_PUBKEY > ~/.ssh/id_rsa.pub
|
2023-07-25 00:00:47 +02:00
|
|
|
- |
|
|
|
|
cat <<EOF > ~/.ssh/id_rsa
|
|
|
|
$SSH_PRIVKEY
|
|
|
|
EOF
|
|
|
|
- chmod 0600 ~/.ssh/id_rsa
|
|
|
|
- ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
|
2023-07-25 00:21:56 +02:00
|
|
|
- git config --global --add safe.directory $PWD
|
2023-07-25 00:00:47 +02:00
|
|
|
- git remote add github git@github.com:/BlackLight/platypush.git
|
2023-08-31 02:32:42 +02:00
|
|
|
- git pull --rebase github "$(git branch | head -1 | awk '{print $2}')" || echo "No such branch on Github"
|
2023-08-31 02:23:13 +02:00
|
|
|
- git push --all -v github
|
2023-07-25 00:00:47 +02:00
|
|
|
|
2023-10-01 23:17:53 +02:00
|
|
|
###
|
|
|
|
### Synchronize the `stable` branch to the new release
|
|
|
|
###
|
|
|
|
|
|
|
|
- name: sync-stable-branch
|
|
|
|
image: alpine
|
|
|
|
environment:
|
|
|
|
SSH_PUBKEY:
|
|
|
|
from_secret: ssh_pubkey
|
|
|
|
SSH_PRIVKEY:
|
|
|
|
from_secret: ssh_privkey
|
|
|
|
PGP_KEY:
|
|
|
|
from_secret: pgp_key
|
|
|
|
PGP_KEY_ID:
|
|
|
|
from_secret: pgp_key_id
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- apk add --update --no-cache git bash gnupg openssh
|
|
|
|
|
|
|
|
# Backup the original git configuration before changing attributes
|
|
|
|
- export GIT_CONF=$PWD/.git/config
|
|
|
|
- cp $GIT_CONF /tmp/git.config.orig
|
|
|
|
- git config --global --add safe.directory $PWD
|
|
|
|
|
|
|
|
# Install the SSH and PGP keys
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- |
|
|
|
|
cat <<EOF | gpg --import --armor
|
|
|
|
$PGP_KEY
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- echo $SSH_PUBKEY > ~/.ssh/id_rsa.pub
|
|
|
|
- |
|
|
|
|
cat <<EOF > ~/.ssh/id_rsa
|
|
|
|
$SSH_PRIVKEY
|
|
|
|
EOF
|
|
|
|
- chmod 0600 ~/.ssh/id_rsa
|
|
|
|
- ssh-keyscan git.platypush.tech >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
|
|
|
|
# Git configuration
|
|
|
|
- git config user.name "Platypush CI/CD Automation"
|
|
|
|
- git config user.email "admin@platypush.tech"
|
|
|
|
- git config commit.gpgsign true
|
|
|
|
- git config user.signingkey $PGP_KEY_ID
|
|
|
|
- git remote rm origin
|
|
|
|
- git remote add origin git@git.platypush.tech:platypush/platypush.git
|
|
|
|
|
2023-10-01 23:31:22 +02:00
|
|
|
# Merge and push to the `stable` branch
|
|
|
|
- git checkout stable
|
|
|
|
- git rebase master
|
2023-10-01 23:17:53 +02:00
|
|
|
- git push -u origin stable
|
2023-10-01 23:31:22 +02:00
|
|
|
- git checkout master
|
2023-10-01 23:17:53 +02:00
|
|
|
|
|
|
|
# Restore the original git configuration
|
|
|
|
- mv /tmp/git.config.orig $GIT_CONF
|
|
|
|
|
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- tag
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Rebuild the docs
|
|
|
|
###
|
|
|
|
|
2023-08-06 10:49:44 +02:00
|
|
|
- name: docs
|
2023-08-04 11:18:42 +02:00
|
|
|
image: alpine
|
|
|
|
volumes:
|
|
|
|
- name: docs
|
|
|
|
path: /docs
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- echo "Installing required build dependencies"
|
2023-10-21 22:54:49 +02:00
|
|
|
- apk add --update --no-cache git make py3-sphinx py3-myst-parser py3-pip $(cat platypush/install/requirements/alpine.txt)
|
2023-12-18 13:50:02 +01:00
|
|
|
- pip install -U sphinx-rtd-theme sphinx-book-theme --break-system-packages
|
|
|
|
- pip install . --break-system-packages
|
2023-08-04 11:18:42 +02:00
|
|
|
- mkdir -p /docs/current
|
|
|
|
- export APPDIR=$PWD
|
|
|
|
- rm -rf "$APPDIR/docs/build"
|
|
|
|
- echo "Building the updated documentation"
|
2023-10-21 22:54:49 +02:00
|
|
|
- cd "$APPDIR/docs/source"
|
|
|
|
- git clone 'https://git.platypush.tech/platypush/platypush.wiki.git' wiki
|
|
|
|
- cd wiki
|
|
|
|
- ln -s Home.md index.md
|
2023-08-04 11:18:42 +02:00
|
|
|
- cd "$APPDIR/docs"
|
|
|
|
- make html
|
|
|
|
- rm -f config*.yaml
|
|
|
|
- cd "$APPDIR"
|
|
|
|
- echo "Copying the new documentation files to the target folder"
|
|
|
|
- mv -v "$APPDIR/docs/build" /docs/new
|
|
|
|
- cd /docs
|
|
|
|
- mv current old
|
|
|
|
- mv new current
|
|
|
|
- rm -rf old
|
|
|
|
|
2023-08-05 14:43:10 +02:00
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- tag
|
|
|
|
|
2023-10-01 23:17:53 +02:00
|
|
|
depends_on:
|
|
|
|
- sync-stable-branch
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Run the tests
|
|
|
|
###
|
|
|
|
|
2023-08-06 00:44:03 +02:00
|
|
|
- name: tests
|
2023-09-30 13:36:28 +02:00
|
|
|
image: alpine
|
2023-07-24 11:05:38 +02:00
|
|
|
commands:
|
2023-09-30 13:36:28 +02:00
|
|
|
- apk add --update --no-cache $(cat platypush/install/requirements/alpine.txt)
|
2023-12-18 13:50:02 +01:00
|
|
|
- pip install . --break-system-packages
|
|
|
|
- pip install -r requirements-tests.txt --break-system-packages
|
2023-07-24 11:05:38 +02:00
|
|
|
- pytest tests
|
2023-08-04 11:18:42 +02:00
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Rebuild the UI files
|
|
|
|
###
|
|
|
|
|
2023-08-06 22:21:22 +02:00
|
|
|
- name: build-ui
|
|
|
|
image: node:current-alpine3.18
|
|
|
|
|
|
|
|
environment:
|
|
|
|
SSH_PUBKEY:
|
|
|
|
from_secret: ssh_pubkey
|
|
|
|
SSH_PRIVKEY:
|
|
|
|
from_secret: ssh_privkey
|
|
|
|
PGP_KEY:
|
|
|
|
from_secret: pgp_key
|
|
|
|
PGP_KEY_ID:
|
|
|
|
from_secret: pgp_key_id
|
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- tests
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- apk add --update --no-cache git
|
2023-08-07 00:45:51 +02:00
|
|
|
|
|
|
|
# Backup the original git configuration before changing attributes
|
|
|
|
- export GIT_CONF=$PWD/.git/config
|
|
|
|
- cp $GIT_CONF /tmp/git.config.orig
|
|
|
|
|
2023-08-06 22:21:22 +02:00
|
|
|
- git config --global --add safe.directory $PWD
|
|
|
|
- cd platypush/backend/http/webapp
|
|
|
|
- |
|
|
|
|
if [ $(git log --pretty=oneline $DRONE_COMMIT_AFTER...$DRONE_COMMIT_BEFORE . | wc -l) -eq 0 ]; then
|
|
|
|
echo "No UI changes detected, skipping build"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-08-07 00:10:46 +02:00
|
|
|
- |
|
2023-09-20 23:42:34 +02:00
|
|
|
if [ "$(git log --pretty=format:%s HEAD...HEAD~1 | head -1)" == "[Automatic] Updated UI files" ]; then
|
2023-08-07 00:10:46 +02:00
|
|
|
echo "UI changes have already been committed, skipping build"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-09-17 12:56:54 +02:00
|
|
|
- rm -rf node_modules
|
2023-08-06 22:21:22 +02:00
|
|
|
- npm install
|
|
|
|
- npm run build
|
|
|
|
- |
|
|
|
|
if [ $(git status --porcelain dist | wc -l) -eq 0 ]; then
|
|
|
|
echo "No build files have been changed"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
- apk add --update --no-cache bash gnupg openssh
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- |
|
|
|
|
cat <<EOF | gpg --import --armor
|
|
|
|
$PGP_KEY
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- echo $SSH_PUBKEY > ~/.ssh/id_rsa.pub
|
|
|
|
- |
|
|
|
|
cat <<EOF > ~/.ssh/id_rsa
|
|
|
|
$SSH_PRIVKEY
|
|
|
|
EOF
|
|
|
|
- chmod 0600 ~/.ssh/id_rsa
|
|
|
|
- ssh-keyscan git.platypush.tech >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
|
|
|
|
- git config user.name "Platypush CI/CD Automation"
|
|
|
|
- git config user.email "admin@platypush.tech"
|
2023-08-07 00:10:46 +02:00
|
|
|
- git config commit.gpgsign true
|
2023-08-06 22:21:22 +02:00
|
|
|
- git config user.signingkey $PGP_KEY_ID
|
|
|
|
- git add dist
|
|
|
|
- git commit dist -S -m "[Automatic] Updated UI files" --no-verify
|
2023-08-06 23:40:35 +02:00
|
|
|
- git remote rm origin
|
|
|
|
- git remote add origin git@git.platypush.tech:platypush/platypush.git
|
2023-10-12 02:56:38 +02:00
|
|
|
- git push -f origin master
|
2023-08-06 22:21:22 +02:00
|
|
|
|
2023-08-07 00:19:02 +02:00
|
|
|
# Restore the original git configuration
|
2023-08-07 00:45:51 +02:00
|
|
|
- mv /tmp/git.config.orig $GIT_CONF
|
2023-08-07 00:19:02 +02:00
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Update the Arch packages
|
|
|
|
###
|
|
|
|
|
2023-08-06 00:44:03 +02:00
|
|
|
- name: update-arch-packages
|
|
|
|
image: python:3.11-alpine
|
|
|
|
environment:
|
|
|
|
WORKDIR: /tmp/workdir
|
|
|
|
SSH_PUBKEY:
|
|
|
|
from_secret: ssh_pubkey
|
|
|
|
SSH_PRIVKEY:
|
|
|
|
from_secret: ssh_privkey
|
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
2023-08-06 22:21:22 +02:00
|
|
|
event:
|
|
|
|
- push
|
2023-08-06 00:44:03 +02:00
|
|
|
|
|
|
|
depends_on:
|
2023-08-06 22:21:22 +02:00
|
|
|
- build-ui
|
2023-08-06 00:44:03 +02:00
|
|
|
|
|
|
|
commands:
|
|
|
|
- echo "-- Installing dependencies"
|
|
|
|
- apk add --update --no-cache curl git openssh pacman sudo
|
|
|
|
|
|
|
|
- echo "--- Parsing metadata"
|
|
|
|
- git config --global --add safe.directory $PWD
|
2023-09-04 02:53:20 +02:00
|
|
|
- git pull --rebase origin master --tags
|
2023-08-06 00:44:03 +02:00
|
|
|
- export VERSION=$(python setup.py --version)
|
2023-09-20 23:42:34 +02:00
|
|
|
- export HEAD=$(git log --pretty=format:%h HEAD...HEAD~1 | head -1)
|
2023-08-06 00:48:20 +02:00
|
|
|
- export GIT_VERSION="$VERSION.r$(git log --pretty=oneline HEAD...v$VERSION | wc -l).$HEAD"
|
2023-08-06 00:44:03 +02:00
|
|
|
- export TAG_URL="https://git.platypush.tech/platypush/platypush/archive/v$VERSION.tar.gz"
|
|
|
|
|
|
|
|
- echo "--- Preparing environment"
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- echo $SSH_PUBKEY > ~/.ssh/id_rsa.pub
|
|
|
|
- |
|
|
|
|
cat <<EOF > ~/.ssh/id_rsa
|
|
|
|
$SSH_PRIVKEY
|
|
|
|
EOF
|
|
|
|
- chmod 0600 ~/.ssh/id_rsa
|
|
|
|
- ssh-keyscan git.platypush.tech >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- adduser -u 1000 -D build
|
|
|
|
- mkdir -p $WORKDIR
|
|
|
|
|
|
|
|
- echo "--- Updating Arch git version"
|
|
|
|
- export PKGDIR=$WORKDIR/git
|
|
|
|
- git clone ssh://aur@aur.archlinux.org/platypush-git.git $PKGDIR
|
|
|
|
- git config --global --add safe.directory $PKGDIR
|
|
|
|
- chown -R build $PKGDIR
|
|
|
|
- cd $PKGDIR
|
|
|
|
- |
|
|
|
|
sed -i 'PKGBUILD' -r \
|
|
|
|
-e "s/^pkgver=.*/pkgver=$GIT_VERSION/" \
|
|
|
|
-e "s/^pkgrel=.*/pkgrel=1/" \
|
|
|
|
- sudo -u build makepkg --printsrcinfo > .SRCINFO
|
|
|
|
- export FILES_CHANGED=$(git status --porcelain --untracked-files=no | wc -l)
|
|
|
|
- |
|
|
|
|
if [ $FILES_CHANGED -gt 0 ]; then
|
|
|
|
echo "--- Pushing git package version $GIT_VERSION"
|
|
|
|
git commit -a -m '[Automatic] Package update'
|
|
|
|
git push origin master
|
|
|
|
fi
|
|
|
|
|
|
|
|
- echo "--- Updating Arch stable version"
|
|
|
|
- export PKGDIR=$WORKDIR/stable
|
|
|
|
- git clone ssh://aur@aur.archlinux.org/platypush.git $PKGDIR
|
|
|
|
- git config --global --add safe.directory $PKGDIR
|
|
|
|
- chown -R build $PKGDIR
|
|
|
|
- cd $PKGDIR
|
|
|
|
- export RELEASED_VERSION=$(grep -e '^pkgver=' PKGBUILD | sed -r -e 's/^pkgver=(.*)\s*/\1/')
|
|
|
|
- |
|
|
|
|
if [ "$RELEASED_VERSION" == "$VERSION" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
- export TAG_CHECKSUM=$(curl --silent "$TAG_URL" | sha512sum | awk '{print $1}')
|
|
|
|
- |
|
|
|
|
sed -i 'PKGBUILD' -r \
|
|
|
|
-e "s/^pkgver=.*/pkgver=$VERSION/" \
|
|
|
|
-e "s/^pkgrel=.*/pkgrel=1/" \
|
|
|
|
-e "s/^sha512sums=.*/sha512sums=('$TAG_CHECKSUM')/"
|
|
|
|
|
|
|
|
- sudo -u build makepkg --printsrcinfo > .SRCINFO
|
|
|
|
- export FILES_CHANGED=$(git status --porcelain --untracked-files=no | wc -l)
|
|
|
|
- |
|
|
|
|
if [ $FILES_CHANGED -gt 0 ]; then
|
|
|
|
echo "--- Pushing stable package version $VERSION"
|
|
|
|
git commit -a -m '[Automatic] Package update'
|
|
|
|
git push origin master
|
|
|
|
fi
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Update the Debian (stable) packages
|
|
|
|
###
|
|
|
|
|
2023-09-18 13:36:59 +02:00
|
|
|
- name: update-debian-stable-packages
|
2023-09-18 21:31:42 +02:00
|
|
|
image: debian:stable
|
2023-10-19 21:48:59 +02:00
|
|
|
volumes:
|
|
|
|
- name: repos
|
|
|
|
path: /repos
|
|
|
|
|
2023-09-18 11:00:46 +02:00
|
|
|
environment:
|
2023-09-18 21:31:42 +02:00
|
|
|
DEB_VERSION: stable
|
2023-09-18 11:00:46 +02:00
|
|
|
WORKDIR: /tmp/workdir
|
2023-10-19 21:48:59 +02:00
|
|
|
APT_ROOT: /repos/apt
|
2023-09-19 00:36:16 +02:00
|
|
|
PKG_NAME: platypush
|
2023-09-18 11:00:46 +02:00
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- build-ui
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- echo "-- Installing dependencies"
|
|
|
|
- apt update
|
2023-10-19 21:48:59 +02:00
|
|
|
- apt install -y curl dpkg-dev gpg git python3 python3-pip
|
2023-09-18 11:00:46 +02:00
|
|
|
|
2023-09-18 21:15:48 +02:00
|
|
|
- echo "-- Copying source directory"
|
|
|
|
- mkdir -p "$WORKDIR"
|
|
|
|
- export SRCDIR="$WORKDIR/src"
|
|
|
|
- cp -r "$PWD" "$SRCDIR"
|
|
|
|
- cd "$SRCDIR"
|
|
|
|
|
2023-09-18 11:00:46 +02:00
|
|
|
- echo "--- Parsing metadata"
|
2023-12-26 05:36:29 +01:00
|
|
|
- git config --global --add safe.directory "$PWD"
|
2023-09-18 14:46:30 +02:00
|
|
|
- git pull --rebase origin master --tags
|
2023-09-18 14:53:21 +02:00
|
|
|
- export VERSION=$(python3 setup.py --version)
|
2023-12-26 04:37:05 +01:00
|
|
|
- export GIT_VERSION="$VERSION-$(git log --pretty=oneline HEAD...v$VERSION | wc -l)"
|
2023-09-19 00:36:16 +02:00
|
|
|
- export GIT_BUILD_DIR="$WORKDIR/$${PKG_NAME}_$${GIT_VERSION}_all"
|
|
|
|
- export GIT_DEB="$WORKDIR/$${PKG_NAME}_$${GIT_VERSION}_all.deb"
|
2023-12-25 15:13:34 +01:00
|
|
|
- export POOL_PATH="$APT_ROOT/pool/$DEB_VERSION/dev"
|
2023-09-18 11:00:46 +02:00
|
|
|
|
|
|
|
- echo "--- Building git package"
|
2023-09-18 15:23:53 +02:00
|
|
|
- pip install --prefix="$GIT_BUILD_DIR/usr" --no-cache --no-deps .
|
2023-09-18 15:49:11 +02:00
|
|
|
- |
|
|
|
|
find "$GIT_BUILD_DIR" -name "site-packages" | while read dir; do
|
|
|
|
base="$(dirname "$dir")"
|
|
|
|
mv "$dir" "$base/dist-packages"
|
|
|
|
done
|
2023-09-18 15:08:03 +02:00
|
|
|
|
2023-09-18 11:59:03 +02:00
|
|
|
- mkdir -p "$GIT_BUILD_DIR/DEBIAN"
|
2023-09-18 11:00:46 +02:00
|
|
|
- |
|
2023-09-18 11:59:03 +02:00
|
|
|
cat <<EOF > "$GIT_BUILD_DIR/DEBIAN/control"
|
2023-09-19 00:36:16 +02:00
|
|
|
Package: $PKG_NAME
|
2023-09-18 11:00:46 +02:00
|
|
|
Version: $GIT_VERSION
|
|
|
|
Maintainer: Fabio Manganiello <fabio@platypush.tech>
|
2023-09-18 11:44:59 +02:00
|
|
|
Depends: $(cat platypush/install/requirements/debian.txt | tr '\n' ',' | sed -re 's/,$//' -e 's/,/, /g')
|
2023-09-18 11:00:46 +02:00
|
|
|
Architecture: all
|
|
|
|
Homepage: https://platypush.tech
|
|
|
|
Description: Universal command executor and automation hub.
|
2023-09-18 11:34:57 +02:00
|
|
|
EOF
|
2023-12-26 05:39:25 +01:00
|
|
|
- mkdir -p "$POOL_PATH"
|
2023-12-26 05:40:56 +01:00
|
|
|
- rm -f "$POOL_PATH/"*.deb
|
2023-09-18 11:00:46 +02:00
|
|
|
- dpkg --build "$GIT_BUILD_DIR"
|
2023-09-19 00:36:16 +02:00
|
|
|
|
2023-12-25 15:13:34 +01:00
|
|
|
- echo "--- Copying $GIT_DEB to $POOL_PATH"
|
|
|
|
- cp "$GIT_DEB" "$POOL_PATH"
|
2023-09-19 00:36:16 +02:00
|
|
|
|
2023-09-20 01:42:25 +02:00
|
|
|
# If main/all/Packages doesn't exist, then we should create the first main release
|
2023-12-26 05:08:21 +01:00
|
|
|
- |
|
|
|
|
[ $(ls "$APT_ROOT/pool/$DEB_VERSION/main/$${PKG_NAME}_$${VERSION}-"*"_all.deb" 2>/dev/null | wc -l) -eq 0 ] && export UPDATE_STABLE_PKG=1
|
|
|
|
|
2023-09-20 01:42:25 +02:00
|
|
|
- export PKGURL="https://apt.platypush.tech/dists/$DEB_VERSION/main/all/Packages"
|
|
|
|
- |
|
|
|
|
[ -z "$UPDATE_STABLE_PKG" ] &&
|
|
|
|
curl -ILs -o /dev/null -w "%{http_code}" "$PKGURL" |
|
|
|
|
grep -e '^4' >/dev/null && export UPDATE_STABLE_PKG=1
|
|
|
|
|
|
|
|
# If the published release version differs from the current one, then we should publish a new main release
|
|
|
|
- |
|
|
|
|
if [ -z "$UPDATE_STABLE_PKG" ]; then
|
|
|
|
RELEASED_VERSION=$(curl -s "$PKGURL" | grep -e '^Version: ' | head -1 | awk '{print $2}' | cut -d- -f 1)
|
|
|
|
[ "$RELEASED_VERSION" != "$VERSION" ] && export UPDATE_STABLE_PKG=1
|
|
|
|
fi
|
|
|
|
|
2023-10-23 21:24:11 +02:00
|
|
|
# Proceed and update the main release if the version number has changed
|
2023-09-20 01:42:25 +02:00
|
|
|
- |
|
2023-10-23 21:24:11 +02:00
|
|
|
if [ -n "$UPDATE_STABLE_PKG" ]; then
|
|
|
|
echo "--- Updating main package"
|
|
|
|
mkdir -p "$APT_ROOT/pool/$DEB_VERSION/main"
|
|
|
|
cp "$GIT_DEB" "$APT_ROOT/pool/$DEB_VERSION/main/$${PKG_NAME}_$${VERSION}-1_all.deb"
|
2023-09-20 01:42:25 +02:00
|
|
|
fi
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Update the Debian (oldstable) packages
|
|
|
|
###
|
2023-09-18 13:36:59 +02:00
|
|
|
|
|
|
|
- name: update-debian-oldstable-packages
|
2023-09-18 21:31:42 +02:00
|
|
|
image: debian:oldstable
|
2023-10-19 21:48:59 +02:00
|
|
|
volumes:
|
|
|
|
- name: repos
|
|
|
|
path: /repos
|
|
|
|
|
2023-09-18 13:36:59 +02:00
|
|
|
environment:
|
2023-09-18 21:31:42 +02:00
|
|
|
DEB_VERSION: oldstable
|
2023-09-18 13:36:59 +02:00
|
|
|
WORKDIR: /tmp/workdir
|
2023-10-19 21:48:59 +02:00
|
|
|
APT_ROOT: /repos/apt
|
2023-10-19 21:54:03 +02:00
|
|
|
PKG_NAME: platypush
|
2023-09-18 13:36:59 +02:00
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- build-ui
|
|
|
|
|
|
|
|
commands:
|
2023-09-18 21:15:48 +02:00
|
|
|
- echo "-- Copying source directory"
|
|
|
|
- mkdir -p "$WORKDIR"
|
|
|
|
- export SRCDIR="$WORKDIR/src"
|
|
|
|
- cp -r "$PWD" "$SRCDIR"
|
|
|
|
- cd "$SRCDIR"
|
|
|
|
|
2023-09-18 13:36:59 +02:00
|
|
|
- echo "-- Installing dependencies"
|
|
|
|
- apt update
|
2023-10-14 15:35:11 +02:00
|
|
|
- apt install -y curl dpkg-dev gpg git python3 python3-pip
|
2023-10-14 15:26:07 +02:00
|
|
|
|
2023-09-18 13:36:59 +02:00
|
|
|
- echo "--- Parsing metadata"
|
2023-12-26 05:36:29 +01:00
|
|
|
- git config --global --add safe.directory "$PWD"
|
2023-09-18 14:46:30 +02:00
|
|
|
- git pull --rebase origin master --tags
|
2023-09-18 14:53:21 +02:00
|
|
|
- export VERSION=$(python3 setup.py --version)
|
2023-12-26 04:37:05 +01:00
|
|
|
- export GIT_VERSION="$VERSION-$(git log --pretty=oneline HEAD...v$VERSION | wc -l)"
|
2023-09-19 00:36:16 +02:00
|
|
|
- export GIT_BUILD_DIR="$WORKDIR/$${PKG_NAME}_$${GIT_VERSION}_all"
|
|
|
|
- export GIT_DEB="$WORKDIR/$${PKG_NAME}_$${GIT_VERSION}_all.deb"
|
2023-12-25 15:13:34 +01:00
|
|
|
- export POOL_PATH="$APT_ROOT/pool/$DEB_VERSION/dev"
|
2023-09-18 13:36:59 +02:00
|
|
|
|
|
|
|
- echo "--- Building git package"
|
2023-09-18 15:23:53 +02:00
|
|
|
- pip install --prefix="$GIT_BUILD_DIR/usr" --no-cache --no-deps .
|
2023-09-18 15:49:11 +02:00
|
|
|
- |
|
|
|
|
find "$GIT_BUILD_DIR" -name "site-packages" | while read dir; do
|
|
|
|
base="$(dirname "$dir")"
|
|
|
|
mv "$dir" "$base/dist-packages"
|
|
|
|
done
|
|
|
|
|
2023-09-18 13:36:59 +02:00
|
|
|
- mkdir -p "$GIT_BUILD_DIR/DEBIAN"
|
|
|
|
- |
|
|
|
|
cat <<EOF > "$GIT_BUILD_DIR/DEBIAN/control"
|
2023-09-19 00:36:16 +02:00
|
|
|
Package: $PKG_NAME
|
2023-09-18 13:36:59 +02:00
|
|
|
Version: $GIT_VERSION
|
|
|
|
Maintainer: Fabio Manganiello <fabio@platypush.tech>
|
|
|
|
Depends: $(cat platypush/install/requirements/debian.txt | tr '\n' ',' | sed -re 's/,$//' -e 's/,/, /g')
|
|
|
|
Architecture: all
|
|
|
|
Homepage: https://platypush.tech
|
|
|
|
Description: Universal command executor and automation hub.
|
|
|
|
EOF
|
2023-12-26 05:40:56 +01:00
|
|
|
- mkdir -p "$POOL_PATH"
|
|
|
|
- rm -f "$POOL_PATH/"*.deb
|
2023-09-18 13:36:59 +02:00
|
|
|
- dpkg --build "$GIT_BUILD_DIR"
|
2023-09-19 00:36:16 +02:00
|
|
|
|
2023-12-25 15:13:34 +01:00
|
|
|
- echo "--- Copying $GIT_DEB to $POOL_PATH"
|
|
|
|
- cp "$GIT_DEB" "$POOL_PATH"
|
2023-09-19 00:36:16 +02:00
|
|
|
|
2023-09-20 01:42:25 +02:00
|
|
|
# If main/all/Packages doesn't exist, then we should create the first main release
|
2023-12-26 05:08:21 +01:00
|
|
|
- |
|
|
|
|
[ $(ls "$APT_ROOT/pool/$DEB_VERSION/main/$${PKG_NAME}_$${VERSION}-"*"_all.deb" 2>/dev/null | wc -l) -eq 0 ] && export UPDATE_STABLE_PKG=1
|
|
|
|
|
2023-09-20 01:42:25 +02:00
|
|
|
- export PKGURL="https://apt.platypush.tech/dists/$DEB_VERSION/main/all/Packages"
|
|
|
|
- |
|
|
|
|
[ -z "$UPDATE_STABLE_PKG" ] &&
|
|
|
|
curl -ILs -o /dev/null -w "%{http_code}" "$PKGURL" |
|
|
|
|
grep -e '^4' >/dev/null && export UPDATE_STABLE_PKG=1
|
|
|
|
|
|
|
|
# If the published release version differs from the current one, then we should publish a new main release
|
|
|
|
- |
|
|
|
|
if [ -z "$UPDATE_STABLE_PKG" ]; then
|
|
|
|
RELEASED_VERSION=$(curl -s "$PKGURL" | grep -e '^Version: ' | head -1 | awk '{print $2}' | cut -d- -f 1)
|
|
|
|
[ "$RELEASED_VERSION" != "$VERSION" ] && export UPDATE_STABLE_PKG=1
|
|
|
|
fi
|
|
|
|
|
2023-10-23 21:24:11 +02:00
|
|
|
# Proceed and update the main release if the version number has changed
|
2023-09-20 01:42:25 +02:00
|
|
|
- |
|
2023-10-23 21:24:11 +02:00
|
|
|
if [ -n "$UPDATE_STABLE_PKG" ]; then
|
|
|
|
echo "--- Updating main package"
|
|
|
|
mkdir -p "$APT_ROOT/pool/$DEB_VERSION/main"
|
|
|
|
cp "$GIT_DEB" "$APT_ROOT/pool/$DEB_VERSION/main/$${PKG_NAME}_$${VERSION}-1_all.deb"
|
2023-09-20 01:42:25 +02:00
|
|
|
fi
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Updates the APT repository after new packages have been pushed
|
|
|
|
###
|
|
|
|
|
|
|
|
- name: update-apt-repo
|
|
|
|
image: debian:stable
|
2023-10-19 21:48:59 +02:00
|
|
|
volumes:
|
|
|
|
- name: repos
|
|
|
|
path: /repos
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
environment:
|
2023-10-19 21:48:59 +02:00
|
|
|
REPOS_ROOT: /repos
|
|
|
|
APT_ROOT: /repos/apt
|
2023-09-20 00:03:49 +02:00
|
|
|
PGP_PUBKEY:
|
|
|
|
from_secret: apt_pgp_pub_key
|
|
|
|
PGP_PRIVKEY:
|
|
|
|
from_secret: apt_pgp_priv_key
|
2023-09-19 00:36:16 +02:00
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- update-debian-stable-packages
|
|
|
|
- update-debian-oldstable-packages
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- echo "-- Installing dependencies"
|
2023-09-19 01:05:38 +02:00
|
|
|
- apt update
|
2023-10-19 21:48:59 +02:00
|
|
|
- apt install -y dpkg-dev gpg
|
2023-10-14 15:14:08 +02:00
|
|
|
|
|
|
|
- echo "-- Creating a new apt root folder"
|
|
|
|
- export TMP_APT_ROOT="/tmp/apt"
|
|
|
|
- cp -r "$APT_ROOT" "$TMP_APT_ROOT"
|
2023-09-19 00:36:16 +02:00
|
|
|
|
|
|
|
- echo "-- Cleaning up older apt releases"
|
|
|
|
- |
|
2023-10-14 15:14:08 +02:00
|
|
|
find "$TMP_APT_ROOT/pool" -mindepth 2 -maxdepth 2 -type d | while read reldir; do
|
2023-09-19 11:46:04 +02:00
|
|
|
pkg_to_remove=$(( $(ls "$reldir"/*.deb | wc -l) - 1 ))
|
|
|
|
[ $pkg_to_remove -le 0 ] && continue
|
|
|
|
ls "$reldir"/*.deb | sort -V | head -n$pkg_to_remove | xargs rm -f
|
|
|
|
done
|
|
|
|
|
|
|
|
- echo "-- Updating Packages files"
|
|
|
|
- |
|
|
|
|
echo "stable\noldstable" | while read distro; do
|
|
|
|
echo "main\ndev" | while read branch; do
|
2023-10-14 15:14:08 +02:00
|
|
|
branch_dir="$TMP_APT_ROOT/pool/$distro/$branch"
|
2023-12-26 05:21:46 +01:00
|
|
|
echo "Checking pool folder: $branch_dir"
|
|
|
|
[ -d "$branch_dir" ] || mkdir -p "$branch_dir"
|
2023-10-14 15:14:08 +02:00
|
|
|
dist_dir="$TMP_APT_ROOT/dists/$distro/$branch/all"
|
2023-09-19 11:46:04 +02:00
|
|
|
mkdir -p "$dist_dir"
|
|
|
|
pkg_file="$dist_dir/Packages"
|
|
|
|
dpkg-scanpackages --arch all "$branch_dir" > "$pkg_file"
|
2023-10-14 15:14:08 +02:00
|
|
|
sed -i "$pkg_file" -re "s|^Filename: $TMP_APT_ROOT/|Filename: |"
|
2023-09-19 11:46:04 +02:00
|
|
|
cat "$pkg_file" | gzip -9 > "$pkg_file.gz"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
- echo "-- Updating Release files"
|
|
|
|
- |
|
2023-09-19 13:01:06 +02:00
|
|
|
add_hashes() {
|
|
|
|
dist_dir=$1
|
|
|
|
hash_cmd=$2
|
|
|
|
hash_label=$3
|
|
|
|
|
|
|
|
echo "$hash_label:"
|
|
|
|
find "$dist_dir" -name 'Packages*' | while read file; do
|
|
|
|
basename="$(echo "$file" | sed -r -e "s|^$dist_dir/||")"
|
|
|
|
hash="$($hash_cmd "$file" | cut -d" " -f1)"
|
|
|
|
size="$(wc -c < $file)"
|
|
|
|
echo " $hash $size $basename"
|
2023-09-19 14:34:02 +02:00
|
|
|
echo " $hash $size $(echo $basename | sed -re 's|/all/|/binary-i386/|')"
|
|
|
|
echo " $hash $size $(echo $basename | sed -re 's|/all/|/binary-amd64/|')"
|
|
|
|
echo " $hash $size $(echo $basename | sed -re 's|/all/|/binary-armel/|')"
|
|
|
|
echo " $hash $size $(echo $basename | sed -re 's|/all/|/binary-armhf/|')"
|
|
|
|
echo " $hash $size $(echo $basename | sed -re 's|/all/|/binary-arm64/|')"
|
2023-09-19 13:01:06 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-09-19 11:46:04 +02:00
|
|
|
echo "stable\noldstable" | while read distro; do
|
2023-10-14 15:14:08 +02:00
|
|
|
dist_dir="$TMP_APT_ROOT/dists/$distro"
|
2023-09-19 11:46:04 +02:00
|
|
|
components=$(find "$dist_dir" -name Packages | awk -F '/' '{print $(NF-2)}' | uniq | tr '\n' ' ')
|
|
|
|
release_file="$dist_dir/Release"
|
|
|
|
|
|
|
|
cat <<EOF > "$release_file"
|
|
|
|
Origin: Platypush repository
|
|
|
|
Label: Platypush
|
|
|
|
Suite: $distro
|
|
|
|
Codename: $distro
|
2023-09-19 14:13:31 +02:00
|
|
|
Architectures: i386 amd64 armel armhf arm64
|
2023-09-19 11:46:04 +02:00
|
|
|
Components: $components
|
|
|
|
Description: The official APT repository for Platypush
|
|
|
|
Date: $(date -Ru)
|
|
|
|
EOF
|
|
|
|
|
2023-09-19 13:01:06 +02:00
|
|
|
add_hashes "$dist_dir" "md5sum" "MD5Sum" >> "$release_file"
|
|
|
|
add_hashes "$dist_dir" "sha1sum" "SHA1" >> "$release_file"
|
|
|
|
add_hashes "$dist_dir" "sha256sum" "SHA256" >> "$release_file"
|
2023-09-19 00:36:16 +02:00
|
|
|
done
|
|
|
|
|
2023-11-18 15:33:22 +01:00
|
|
|
- echo "-- Generating list files"
|
|
|
|
- mkdir -p "$TMP_APT_ROOT/lists"
|
2023-11-18 15:27:34 +01:00
|
|
|
- |
|
2023-11-18 15:33:22 +01:00
|
|
|
cat <<EOF > "$TMP_APT_ROOT/lists/platypush-stable-main.list"
|
2023-11-18 14:16:49 +01:00
|
|
|
deb https://apt.platypush.tech/ stable main
|
|
|
|
EOF
|
|
|
|
|
2023-11-18 15:27:34 +01:00
|
|
|
- |
|
2023-11-18 15:33:22 +01:00
|
|
|
cat <<EOF > "$TMP_APT_ROOT/lists/platypush-stable-dev.list"
|
2023-11-18 14:16:49 +01:00
|
|
|
deb https://apt.platypush.tech/ stable dev
|
|
|
|
EOF
|
|
|
|
|
2023-11-18 15:33:22 +01:00
|
|
|
- |
|
|
|
|
cat <<EOF > "$TMP_APT_ROOT/lists/platypush-oldstable-main.list"
|
|
|
|
deb https://apt.platypush.tech/ oldstable main
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- |
|
|
|
|
cat <<EOF > "$TMP_APT_ROOT/lists/platypush-oldstable-dev.list"
|
|
|
|
deb https://apt.platypush.tech/ oldstable dev
|
|
|
|
EOF
|
|
|
|
|
2023-10-19 23:46:36 +02:00
|
|
|
- echo "-- Updating index file"
|
|
|
|
- |
|
|
|
|
cat <<EOF > "$TMP_APT_ROOT/index.txt"
|
|
|
|
Welcome to the Platypush APT repository!
|
|
|
|
|
|
|
|
Project homepage: https://platypush.tech
|
|
|
|
Source code: https://git.platypush.tech/platypush/platypush
|
|
|
|
Documentation / API reference: https://docs.platypush.tech
|
|
|
|
|
|
|
|
You can use this APT repository to install Platypush on Debian, Ubuntu or any
|
|
|
|
Debian-based distro.
|
|
|
|
|
|
|
|
Steps:
|
|
|
|
|
|
|
|
1. Add this repository's PGP key to your apt keyring
|
|
|
|
====================================================
|
|
|
|
|
2023-11-18 15:37:17 +01:00
|
|
|
$ sudo wget -q -O \\\
|
|
|
|
/etc/apt/trusted.gpg.d/platypush.asc \\\
|
2023-10-19 23:46:36 +02:00
|
|
|
https://apt.platypush.tech/pubkey.txt
|
|
|
|
|
|
|
|
2. Add the repository to your sources
|
|
|
|
=====================================
|
|
|
|
|
2023-11-18 15:37:17 +01:00
|
|
|
$ sudo wget -q -O \\\
|
|
|
|
/etc/apt/sources.list.d/platypush.list \\\
|
2023-10-19 23:46:36 +02:00
|
|
|
https://apt.platypush.tech/lists/platypush-<deb_version>-<branch>.list
|
|
|
|
|
|
|
|
Where:
|
|
|
|
|
|
|
|
- deb_version can be either *stable* (for the current Debian stable version) or
|
|
|
|
*oldstable* (for the previous Debian stable version)
|
|
|
|
- branch can be either *main* (for the latest releases) or *dev* (for a package
|
|
|
|
that is always in sync with the git version)
|
|
|
|
|
|
|
|
For example, to install the latest stable tags on Debian stable:
|
|
|
|
|
2023-11-18 15:37:17 +01:00
|
|
|
$ sudo wget -q -O \\\
|
|
|
|
/etc/apt/sources.list.d/platypush.list \\\
|
2023-10-19 23:46:36 +02:00
|
|
|
https://apt.platypush.tech/lists/platypush-stable-main.list
|
|
|
|
|
|
|
|
3. Update your repos
|
|
|
|
====================
|
|
|
|
|
|
|
|
$ sudo apt update
|
|
|
|
|
|
|
|
4. Install Platypush
|
|
|
|
====================
|
|
|
|
|
|
|
|
$ sudo apt install platypush
|
|
|
|
EOF
|
|
|
|
|
2023-09-20 00:03:49 +02:00
|
|
|
- echo "-- Importing and refreshing PGP key"
|
2023-10-14 15:14:08 +02:00
|
|
|
- echo "$PGP_PUBKEY" > "$TMP_APT_ROOT/pubkey.txt"
|
2023-09-20 00:03:49 +02:00
|
|
|
- export PGP_KEYID=$(echo "$PGP_PUBKEY" | gpg --with-colons --import-options show-only --import --fingerprint | grep -e '^fpr:' | head -1 | awk -F ':' '{print $(NF - 1)}')
|
|
|
|
- |
|
|
|
|
cat <<EOF | gpg --import --armor
|
|
|
|
$PGP_PRIVKEY
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- echo "-- Signing Release files"
|
|
|
|
- |
|
2023-10-14 15:14:08 +02:00
|
|
|
find "$TMP_APT_ROOT/dists" -type f -name Release | while read file; do
|
2023-09-20 00:03:49 +02:00
|
|
|
dirname="$(dirname "$file")"
|
|
|
|
cat "$file" | gpg -q --default-key "$PGP_KEYID" -abs > "$file.gpg"
|
|
|
|
cat "$file" | gpg -q --default-key "$PGP_KEYID" -abs --clearsign > "$dirname/InRelease"
|
|
|
|
done
|
|
|
|
|
2023-10-19 21:48:59 +02:00
|
|
|
- echo "-- Updating the apt repo root"
|
|
|
|
- export OLD_APT_ROOT="$REPOS_ROOT/oldapt"
|
2023-10-14 15:14:08 +02:00
|
|
|
- |
|
|
|
|
if [ ! -d "$OLD_APT_ROOT" ]; then
|
|
|
|
mv "$APT_ROOT" "$OLD_APT_ROOT"
|
|
|
|
mv "$TMP_APT_ROOT" "$APT_ROOT"
|
|
|
|
rm -rf "$OLD_APT_ROOT"
|
|
|
|
fi
|
|
|
|
|
2023-10-23 21:47:22 +02:00
|
|
|
- chmod -R a+r "$APT_ROOT"
|
|
|
|
- chmod a+x "$APT_ROOT"
|
2023-10-23 21:40:09 +02:00
|
|
|
|
2023-09-23 16:21:00 +02:00
|
|
|
###
|
|
|
|
### Update the RPM (stable) packages
|
|
|
|
###
|
|
|
|
|
|
|
|
- name: update-rpm-repo
|
|
|
|
image: fedora
|
2023-10-19 21:48:59 +02:00
|
|
|
volumes:
|
|
|
|
- name: repos
|
|
|
|
path: /repos
|
|
|
|
|
2023-09-23 16:21:00 +02:00
|
|
|
environment:
|
|
|
|
RPM_VERSION: stable
|
2023-10-19 21:48:59 +02:00
|
|
|
REPOS_ROOT: /repos
|
|
|
|
RPM_ROOT: /repos/rpm
|
2023-09-23 16:21:00 +02:00
|
|
|
WORKDIR: /tmp/workdir
|
|
|
|
PKG_NAME: platypush
|
|
|
|
PGP_PUBKEY:
|
|
|
|
from_secret: rpm_pgp_pub_key
|
|
|
|
PGP_PRIVKEY:
|
|
|
|
from_secret: rpm_pgp_priv_key
|
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- build-ui
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- echo "-- Installing dependencies"
|
2023-10-19 21:48:59 +02:00
|
|
|
- yum install -y createrepo rpm-build rpm-sign gpg wget yum-utils git python python-pip
|
2023-09-23 16:21:00 +02:00
|
|
|
|
|
|
|
- echo "-- Copying source directory"
|
|
|
|
- mkdir -p "$WORKDIR"
|
|
|
|
- export SRCDIR="$WORKDIR/src"
|
|
|
|
- cp -r "$PWD" "$SRCDIR"
|
|
|
|
- cd "$SRCDIR"
|
|
|
|
- mkdir -p "$RPM_ROOT"
|
|
|
|
|
|
|
|
- echo "--- Parsing metadata"
|
|
|
|
- git config --global --add safe.directory $PWD
|
|
|
|
- git pull --rebase origin master --tags
|
|
|
|
- export VERSION=$(python3 setup.py --version)
|
2023-12-26 04:37:05 +01:00
|
|
|
- export RELNUM="$(git log --pretty=oneline HEAD...v$VERSION | wc -l)"
|
2023-09-23 16:21:00 +02:00
|
|
|
- export SPECFILE="$WORKDIR/$PKG_NAME.spec"
|
|
|
|
- export BUILD_DIR="$WORKDIR/build"
|
|
|
|
- export TMP_RPM_ROOT="$WORKDIR/repo"
|
|
|
|
- export SRC_URL="https://git.platypush.tech/platypush/platypush/archive/master.tar.gz"
|
|
|
|
|
|
|
|
- echo "--- Creating git package spec"
|
|
|
|
- |
|
|
|
|
cat <<EOF > $SPECFILE
|
|
|
|
Summary: Universal command executor and automation hub.
|
|
|
|
Name: $PKG_NAME-git
|
|
|
|
Version: $VERSION
|
|
|
|
Release: $RELNUM
|
|
|
|
URL: https://platypush.tech
|
|
|
|
Group: System
|
|
|
|
License: MIT
|
|
|
|
Packager: Fabio Manganiello <fabio@platypush.tech>
|
|
|
|
Source: $SRC_URL
|
|
|
|
Requires: $(cat platypush/install/requirements/fedora.txt | tr '\n' ' ')
|
|
|
|
Conflicts: $PKG_NAME
|
|
|
|
Prefix: %{_prefix}
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-root
|
|
|
|
|
|
|
|
%description
|
|
|
|
Universal command executor and automation hub.
|
|
|
|
|
|
|
|
%install
|
|
|
|
mkdir -p %{buildroot}/
|
|
|
|
cp -r "$BUILD_DIR"/* %{buildroot}/
|
|
|
|
|
|
|
|
%clean
|
|
|
|
|
|
|
|
%files
|
|
|
|
/usr/bin/*
|
|
|
|
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush
|
|
|
|
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush-$VERSION.dist-info
|
|
|
|
|
|
|
|
%changelog
|
|
|
|
* $(date +'%a %b %d %Y') admin <admin@platypush.tech>
|
|
|
|
- [Automatic] Release $VERSION-$RELNUM
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- echo "--- Building git package"
|
|
|
|
- mkdir -p "$BUILD_DIR"
|
|
|
|
- pip install --prefix="$BUILD_DIR/usr" --no-cache --no-deps .
|
|
|
|
- rpmbuild --target "noarch" -bb "$SPECFILE"
|
|
|
|
|
|
|
|
- echo "--- Copying the new RPM package"
|
|
|
|
- mkdir -p "$TMP_RPM_ROOT"
|
|
|
|
- cp "$HOME/rpmbuild/RPMS/noarch/$PKG_NAME-git-$VERSION-$RELNUM.noarch.rpm" "$TMP_RPM_ROOT"
|
|
|
|
|
|
|
|
- echo "--- Checking the latest released stable version"
|
|
|
|
- export LATEST_STABLE_PKG=$(ls -rt "$RPM_ROOT/$PKG_NAME"*.rpm 2>/dev/null | grep -v "$PKG_NAME-git" | tail -1)
|
|
|
|
- |
|
|
|
|
if [ -z "$LATEST_STABLE_PKG" ]; then
|
|
|
|
# If not stable release is available, then create one
|
|
|
|
export UPDATE_STABLE_PKG=1
|
|
|
|
else
|
|
|
|
# Otherwise, create a new release if the reported version on the repo is different
|
|
|
|
# from the latest released version.
|
|
|
|
export LATEST_STABLE_VERSION=$(basename $LATEST_STABLE_PKG | cut -d- -f 2)
|
|
|
|
if [ "$VERSION" != "$LATEST_STABLE_VERSION" ]; then
|
|
|
|
export UPDATE_STABLE_PKG=1
|
|
|
|
else
|
|
|
|
# If the version has remained the same, then simply copy the existing RPM to the
|
|
|
|
# new repository directory.
|
|
|
|
echo "Copying the existing release $LATEST_STABLE_VERSION to the new repository"
|
|
|
|
cp "$LATEST_STABLE_PKG" "$TMP_RPM_ROOT"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If a new stable release is required, build another RPM
|
|
|
|
- |
|
|
|
|
if [ -n "$UPDATE_STABLE_PKG" ]; then
|
|
|
|
export RELNUM=1
|
|
|
|
export SRC_URL="https://git.platypush.tech/platypush/platypush/archive/v$VERSION.tar.gz"
|
|
|
|
|
|
|
|
cat <<EOF > $SPECFILE
|
|
|
|
Summary: Universal command executor and automation hub.
|
|
|
|
Name: $PKG_NAME
|
|
|
|
Version: $VERSION
|
|
|
|
Release: $RELNUM
|
|
|
|
URL: https://platypush.tech
|
|
|
|
Group: System
|
|
|
|
License: MIT
|
|
|
|
Packager: Fabio Manganiello <fabio@platypush.tech>
|
|
|
|
Source: $SRC_URL
|
|
|
|
Requires: $(cat platypush/install/requirements/fedora.txt | tr '\n' ' ')
|
|
|
|
Conflicts: $PKG_NAME-git
|
|
|
|
Prefix: %{_prefix}
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-root
|
|
|
|
|
|
|
|
%description
|
|
|
|
Universal command executor and automation hub.
|
|
|
|
|
|
|
|
%install
|
|
|
|
mkdir -p %{buildroot}/
|
|
|
|
cp -r "$BUILD_DIR"/* %{buildroot}/
|
|
|
|
|
|
|
|
%clean
|
|
|
|
|
|
|
|
%files
|
|
|
|
/usr/bin/*
|
|
|
|
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush
|
|
|
|
/usr/lib/python$(python3 --version | awk '{print $2}' | cut -d. -f 1,2)/site-packages/platypush-$VERSION.dist-info
|
|
|
|
|
|
|
|
%changelog
|
|
|
|
* $(date +'%a %b %d %Y') admin <admin@platypush.tech>
|
|
|
|
- [Automatic] Release $VERSION-$RELNUM
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo "--- Building package for stable release $VERSION"
|
|
|
|
rpmbuild --target "noarch" -bb "$SPECFILE"
|
|
|
|
cp "$HOME/rpmbuild/RPMS/noarch/$PKG_NAME-$VERSION-$RELNUM.noarch.rpm" "$TMP_RPM_ROOT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
- echo "--- Importing the repository keys"
|
|
|
|
- |
|
|
|
|
cat <<EOF | gpg --import --armor
|
|
|
|
$PGP_PRIVKEY
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- export PGP_KEYID=$(echo "$PGP_PUBKEY" | gpg --with-colons --import-options show-only --import --fingerprint | grep -e '^fpr:' | head -1 | awk -F ':' '{print $(NF - 1)}')
|
2023-09-23 16:37:52 +02:00
|
|
|
- |
|
|
|
|
cat <<EOF > $HOME/.rpmmacros
|
2023-09-23 16:21:00 +02:00
|
|
|
%signature gpg
|
|
|
|
%_gpg_name $PGP_KEYID
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- echo "--- Signing the new RPM packages"
|
|
|
|
- rpm --addsign "$TMP_RPM_ROOT"/*.rpm
|
|
|
|
|
|
|
|
- echo "--- Creating a new copy of the RPM repository"
|
|
|
|
- createrepo "$TMP_RPM_ROOT"
|
|
|
|
- gpg --detach-sign --armor "$TMP_RPM_ROOT/repodata/repomd.xml"
|
|
|
|
|
2023-10-19 23:46:36 +02:00
|
|
|
- |
|
|
|
|
cat <<EOF > "$TMP_RPM_ROOT/platypush.repo"
|
|
|
|
[platypush]
|
|
|
|
name=Platypush repository
|
|
|
|
baseurl=https://rpm.platypush.tech
|
|
|
|
enabled=1
|
|
|
|
type=rpm
|
|
|
|
gpgcheck=1
|
|
|
|
gpgkey=https://rpm.platypush.tech/pubkey.txt
|
|
|
|
EOF
|
|
|
|
|
|
|
|
- |
|
|
|
|
cat <<EOF > "$TMP_RPM_ROOT/index.txt"
|
|
|
|
Welcome to the Platypush RPM repository!
|
|
|
|
|
|
|
|
Project homepage: https://platypush.tech
|
|
|
|
Source code: https://git.platypush.tech/platypush/platypush
|
|
|
|
Documentation / API reference: https://docs.platypush.tech
|
|
|
|
|
|
|
|
You can use this RPM repository to install Platypush on Fedora or other
|
|
|
|
RPM-based distros - as long as they are compatible with the latest Fedora
|
|
|
|
release.
|
|
|
|
|
|
|
|
Steps:
|
|
|
|
|
|
|
|
1. Add the repository to your sources
|
|
|
|
=====================================
|
|
|
|
|
|
|
|
$ sudo yum config-manager --add-repo https://rpm.platypush.tech/platypush.repo
|
|
|
|
|
|
|
|
2. Install Platypush
|
|
|
|
====================
|
|
|
|
|
|
|
|
$ sudo yum install platypush
|
2023-10-19 23:56:48 +02:00
|
|
|
|
|
|
|
Or, if you want to install a version always up-to-date with the git repo:
|
|
|
|
|
|
|
|
$ sudo yum install platypush-git
|
2023-10-19 23:46:36 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
- |
|
|
|
|
cat <<EOF > "$TMP_RPM_ROOT/pubkey.txt"
|
|
|
|
$PGP_PUBKEY
|
|
|
|
EOF
|
|
|
|
|
2023-10-19 21:48:59 +02:00
|
|
|
- echo "--- Updating the repository"
|
|
|
|
- export NEW_RPM_ROOT="$REPOS_ROOT/rpm_new"
|
|
|
|
- export OLD_RPM_ROOT="$REPOS_ROOT/rpm_old"
|
2023-09-23 16:42:15 +02:00
|
|
|
- cp -r "$TMP_RPM_ROOT" "$NEW_RPM_ROOT"
|
|
|
|
- rm -rf "$TMP_RPM_ROOT"
|
2023-09-23 16:48:49 +02:00
|
|
|
- mv "$RPM_ROOT" "$OLD_RPM_ROOT"
|
2023-09-23 16:21:00 +02:00
|
|
|
- mv "$NEW_RPM_ROOT" "$RPM_ROOT"
|
2023-09-23 16:48:49 +02:00
|
|
|
- rm -rf "$OLD_RPM_ROOT"
|
2023-09-23 16:21:00 +02:00
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Updates the pip package upon new releases
|
|
|
|
###
|
2023-09-18 11:00:46 +02:00
|
|
|
|
2023-08-06 10:49:44 +02:00
|
|
|
- name: update-pip-package
|
|
|
|
image: python:3.11-alpine
|
|
|
|
environment:
|
|
|
|
TWINE_USERNAME:
|
|
|
|
from_secret: pypi_user
|
|
|
|
TWINE_PASSWORD:
|
|
|
|
from_secret: pypi_pass
|
|
|
|
|
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- tag
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- tests
|
|
|
|
- docs
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- apk add --update --no-cache py3-twine
|
|
|
|
- python setup.py sdist bdist_wheel
|
|
|
|
- twine upload dist/platypush-$(python setup.py --version).tar.gz
|
2023-08-06 11:08:01 +02:00
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Checkpoint step that waits for all the package update
|
|
|
|
### steps to complete before proceeding to the next steps.
|
|
|
|
###
|
|
|
|
|
2023-09-18 14:15:29 +02:00
|
|
|
- name: wait-pkg-update
|
|
|
|
image: alpine
|
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- update-arch-packages
|
2023-09-23 16:20:28 +02:00
|
|
|
- update-rpm-repo
|
2023-09-19 00:36:16 +02:00
|
|
|
- update-apt-repo
|
2023-09-18 14:15:29 +02:00
|
|
|
|
|
|
|
commands:
|
|
|
|
- echo "All packages have been successfully updated"
|
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Notifies about a new release
|
|
|
|
###
|
|
|
|
|
2023-08-06 11:08:01 +02:00
|
|
|
- name: notify-release
|
|
|
|
image: python:3.11-alpine
|
|
|
|
environment:
|
|
|
|
WORKER_RPC_SECRET:
|
|
|
|
from_secret: worker_rpc_secret
|
|
|
|
|
|
|
|
when:
|
|
|
|
event:
|
|
|
|
- tag
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- update-pip-package
|
|
|
|
|
|
|
|
commands:
|
|
|
|
- apk add --update --no-cache curl
|
|
|
|
- |
|
|
|
|
curl --silent -XPOST \
|
|
|
|
-H "X-Token: $WORKER_RPC_SECRET" \
|
|
|
|
"https://worker.ci-cd.platypush.tech/hook/notify-platypush-release?version=$(python setup.py --version)"
|
2023-08-06 11:14:12 +02:00
|
|
|
|
2023-09-19 00:36:16 +02:00
|
|
|
###
|
|
|
|
### Notifies about a change in the CI/CD build status
|
|
|
|
###
|
|
|
|
|
2023-08-06 11:14:12 +02:00
|
|
|
- name: notify-build-status
|
|
|
|
image: alpine
|
|
|
|
environment:
|
|
|
|
WORKER_RPC_SECRET:
|
|
|
|
from_secret: worker_rpc_secret
|
|
|
|
|
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
- master
|
|
|
|
event:
|
|
|
|
- push
|
2023-08-07 00:05:13 +02:00
|
|
|
status:
|
|
|
|
- success
|
|
|
|
- failure
|
2023-08-06 11:14:12 +02:00
|
|
|
|
|
|
|
depends_on:
|
2023-09-18 14:15:29 +02:00
|
|
|
- wait-pkg-update
|
2023-08-06 11:14:12 +02:00
|
|
|
|
|
|
|
commands:
|
|
|
|
- apk add --update --no-cache curl
|
|
|
|
- |
|
|
|
|
curl --silent -XPOST \
|
|
|
|
-H "X-Token: $WORKER_RPC_SECRET" \
|
|
|
|
"https://worker.ci-cd.platypush.tech/hook/notify-platypush-build?status=$DRONE_BUILD_STATUS"
|