[CI/CD] Moved generation of Arch stable package to tag events.

Separating the generation of the Arch git package (on each commit to
master) from the generation of the Arch stable package (only on a new
tag) ensures that:

1. The checksum of the package isn't calculated on an older version of
   the archive.

2. The stable version of the package is always exactly aligned with the
   commit associated to the tag.
This commit is contained in:
Fabio Manganiello 2024-07-16 22:03:32 +02:00
parent dc96b4995c
commit 8c0943e700
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
3 changed files with 64 additions and 26 deletions

View file

@ -114,10 +114,10 @@ steps:
- . .drone/update-components-cache.sh - . .drone/update-components-cache.sh
### ###
### Update the Arch packages ### Update the Arch git package
### ###
- name: update-arch-packages - name: update-arch-git-package
image: python:3.11-alpine image: python:3.11-alpine
environment: environment:
WORKDIR: /tmp/workdir WORKDIR: /tmp/workdir
@ -136,7 +136,27 @@ steps:
- update-components-cache - update-components-cache
commands: commands:
- . .drone/update-arch-packages.sh - . .drone/update-arch-git-package.sh
###
### Update the Arch stable package
###
- name: update-arch-stable-package
image: python:3.11-alpine
environment:
WORKDIR: /tmp/workdir
SSH_PUBKEY:
from_secret: ssh_pubkey
SSH_PRIVKEY:
from_secret: ssh_privkey
when:
event:
- tag
commands:
- . .drone/update-arch-stable-package.sh
### ###
### Update the Debian (stable) packages ### Update the Debian (stable) packages
@ -325,7 +345,7 @@ steps:
- push - push
depends_on: depends_on:
- update-arch-packages - update-arch-git-package
- update-rpm-repo - update-rpm-repo
- update-apt-repo - update-apt-repo
@ -348,6 +368,7 @@ steps:
depends_on: depends_on:
- update-pip-package - update-pip-package
- update-arch-stable-package
commands: commands:
- apk add --update --no-cache curl - apk add --update --no-cache curl

View file

@ -0,0 +1,38 @@
#!/bin/sh
[ -f .skipci ] && exit 0
apk add --update --no-cache curl pacman sudo
. .drone/macros/configure-ssh.sh
. .drone/macros/configure-git.sh
git pull --rebase origin master --tags
export VERSION=$(python setup.py --version)
export HEAD=$(git log --pretty=format:%h HEAD...HEAD~1 | head -1)
export GIT_VERSION="$VERSION.r$(git log --pretty=oneline HEAD...v$VERSION | wc -l).g${HEAD}"
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

View file

@ -10,34 +10,12 @@ apk add --update --no-cache curl pacman sudo
git pull --rebase origin master --tags git pull --rebase origin master --tags
export VERSION=$(python setup.py --version) export VERSION=$(python setup.py --version)
export HEAD=$(git log --pretty=format:%h HEAD...HEAD~1 | head -1)
export GIT_VERSION="$VERSION.r$(git log --pretty=oneline HEAD...v$VERSION | wc -l).g${HEAD}"
export TAG_URL="https://git.platypush.tech/platypush/platypush/archive/v$VERSION.tar.gz" export TAG_URL="https://git.platypush.tech/platypush/platypush/archive/v$VERSION.tar.gz"
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null
adduser -u 1000 -D build adduser -u 1000 -D build
mkdir -p "$WORKDIR" 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" echo "--- Updating Arch stable version"
export PKGDIR="$WORKDIR/stable" export PKGDIR="$WORKDIR/stable"
git clone ssh://aur@aur.archlinux.org/platypush.git "$PKGDIR" git clone ssh://aur@aur.archlinux.org/platypush.git "$PKGDIR"
@ -47,6 +25,7 @@ cd "$PKGDIR"
export RELEASED_VERSION=$(grep -e '^pkgver=' PKGBUILD | sed -r -e 's/^pkgver=(.*)\s*/\1/') export RELEASED_VERSION=$(grep -e '^pkgver=' PKGBUILD | sed -r -e 's/^pkgver=(.*)\s*/\1/')
if [ "$RELEASED_VERSION" == "$VERSION" ]; then if [ "$RELEASED_VERSION" == "$VERSION" ]; then
echo "--- No changes in the stable package version"
exit 0 exit 0
fi fi