mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Merge pull request #943 from pimutils/deb
Update script to publish deb packages
This commit is contained in:
commit
d72536805c
3 changed files with 92 additions and 57 deletions
49
scripts/_build_deb_in_container.bash
Normal file
49
scripts/_build_deb_in_container.bash
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# This script is mean to be run inside a dedicated container,
|
||||||
|
# and not interatively.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y build-essential fakeroot debhelper git
|
||||||
|
apt-get install -y python3-all python3-pip python3-venv
|
||||||
|
apt-get install -y ruby ruby-dev
|
||||||
|
|
||||||
|
pip3 install virtualenv virtualenv-tools3
|
||||||
|
virtualenv -p python3 /vdirsyncer/env/
|
||||||
|
|
||||||
|
gem install fpm
|
||||||
|
|
||||||
|
# See https://github.com/jordansissel/fpm/issues/1106#issuecomment-461678970
|
||||||
|
pip3 uninstall -y virtualenv
|
||||||
|
echo 'python3 -m venv "$@"' > /usr/local/bin/virtualenv
|
||||||
|
chmod +x /usr/local/bin/virtualenv
|
||||||
|
|
||||||
|
cp -r /source/ /vdirsyncer/vdirsyncer/
|
||||||
|
cd /vdirsyncer/vdirsyncer/ || exit 2
|
||||||
|
mkdir /vdirsyncer/pkgs/
|
||||||
|
|
||||||
|
basename -- *.tar.gz .tar.gz | cut -d'-' -f2 | sed -e 's/\.dev/~/g' | tee version
|
||||||
|
# XXX: Do I really not want google support included?
|
||||||
|
(echo -n *.tar.gz; echo '[google]') | tee requirements.txt
|
||||||
|
fpm --verbose \
|
||||||
|
--input-type virtualenv \
|
||||||
|
--output-type deb \
|
||||||
|
--name "vdirsyncer-latest" \
|
||||||
|
--version "$(cat version)" \
|
||||||
|
--prefix /opt/venvs/vdirsyncer-latest \
|
||||||
|
--depends python3 \
|
||||||
|
requirements.txt
|
||||||
|
|
||||||
|
mv /vdirsyncer/vdirsyncer/*.deb /vdirsyncer/pkgs/
|
||||||
|
|
||||||
|
cd /vdirsyncer/pkgs/
|
||||||
|
dpkg -i -- *.deb
|
||||||
|
|
||||||
|
# Check that it works:
|
||||||
|
LC_ALL=C.UTF-8 LANG=C.UTF-8 /opt/venvs/vdirsyncer-latest/bin/vdirsyncer --version
|
||||||
|
|
||||||
|
cp -- *.deb /source/
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
ARG distro
|
|
||||||
ARG distrover
|
|
||||||
|
|
||||||
FROM $distro:$distrover
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y build-essential fakeroot debhelper git
|
|
||||||
RUN apt-get install -y python3-all python3-pip python3-venv
|
|
||||||
RUN apt-get install -y ruby ruby-dev
|
|
||||||
|
|
||||||
RUN gem install fpm package_cloud
|
|
||||||
|
|
||||||
RUN pip3 install virtualenv virtualenv-tools3
|
|
||||||
RUN virtualenv -p python3 /vdirsyncer/env/
|
|
||||||
|
|
||||||
# See https://github.com/jordansissel/fpm/issues/1106#issuecomment-461678970
|
|
||||||
RUN pip3 uninstall -y virtualenv
|
|
||||||
RUN echo 'python3 -m venv "$@"' > /usr/local/bin/virtualenv
|
|
||||||
RUN chmod +x /usr/local/bin/virtualenv
|
|
||||||
|
|
||||||
COPY . /vdirsyncer/vdirsyncer/
|
|
||||||
WORKDIR /vdirsyncer/vdirsyncer/
|
|
||||||
RUN mkdir /vdirsyncer/pkgs/
|
|
||||||
|
|
||||||
RUN basename *.tar.gz .tar.gz | cut -d'-' -f2 | sed -e 's/\.dev/~/g' | tee version
|
|
||||||
RUN (echo -n *.tar.gz; echo '[google]') | tee requirements.txt
|
|
||||||
RUN fpm --verbose \
|
|
||||||
--input-type virtualenv \
|
|
||||||
--output-type deb \
|
|
||||||
--name "vdirsyncer-latest" \
|
|
||||||
--version "$(cat version)" \
|
|
||||||
--prefix /opt/venvs/vdirsyncer-latest \
|
|
||||||
--depends python3 \
|
|
||||||
requirements.txt
|
|
||||||
|
|
||||||
RUN mv /vdirsyncer/vdirsyncer/*.deb /vdirsyncer/pkgs/
|
|
||||||
|
|
||||||
WORKDIR /vdirsyncer/pkgs/
|
|
||||||
RUN dpkg -i *.deb
|
|
||||||
|
|
||||||
# Check that it works:
|
|
||||||
RUN LC_ALL=C.UTF-8 LANG=C.UTF-8 /opt/venvs/vdirsyncer-latest/bin/vdirsyncer --version
|
|
||||||
|
|
@ -1,26 +1,54 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -xe
|
set -xeu
|
||||||
|
|
||||||
|
SCRIPT_PATH=$(realpath "$0")
|
||||||
|
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
|
||||||
|
|
||||||
DISTRO=$1
|
DISTRO=$1
|
||||||
DISTROVER=$2
|
DISTROVER=$2
|
||||||
|
CONTAINER_NAME="vdirsyncer-${DISTRO}-${DISTROVER}"
|
||||||
NAME="vdirsyncer-${DISTRO}-${DISTROVER}:latest"
|
|
||||||
CONTEXT="$(mktemp -d)"
|
CONTEXT="$(mktemp -d)"
|
||||||
|
|
||||||
|
DEST_DIR="$SCRIPT_DIR/../$DISTRO-$DISTROVER"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -rf "$CONTEXT"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
# Prepare files.
|
||||||
|
cp scripts/_build_deb_in_container.bash "$CONTEXT"
|
||||||
python setup.py sdist -d "$CONTEXT"
|
python setup.py sdist -d "$CONTEXT"
|
||||||
|
|
||||||
# Build the package in a container with the right distro version.
|
podman run -it \
|
||||||
docker build \
|
--name "$CONTAINER_NAME" \
|
||||||
--build-arg distro=$DISTRO \
|
--volume "$CONTEXT:/source" \
|
||||||
--build-arg distrover=$DISTROVER \
|
"$DISTRO:$DISTROVER" \
|
||||||
-t $NAME \
|
bash /source/_build_deb_in_container.bash
|
||||||
-f scripts/dpkg.Dockerfile \
|
|
||||||
"$CONTEXT"
|
|
||||||
|
|
||||||
# Push the package to packagecloud.
|
# Keep around the package filename.
|
||||||
# TODO: Use ~/.packagecloud for CI.
|
PACKAGE=$(ls "$CONTEXT"/*.deb)
|
||||||
docker run -e PACKAGECLOUD_TOKEN=$PACKAGECLOUD_TOKEN $NAME \
|
PACKAGE=$(basename "$PACKAGE")
|
||||||
bash -xec "package_cloud push pimutils/vdirsyncer/$DISTRO/$DISTROVER *.deb"
|
|
||||||
|
|
||||||
rm -rf "$CONTEXT"
|
# Save the build deb files.
|
||||||
|
mkdir -p "$DEST_DIR"
|
||||||
|
cp "$CONTEXT"/*.deb "$DEST_DIR"
|
||||||
|
|
||||||
|
echo Build complete! 🤖
|
||||||
|
|
||||||
|
# Packagecloud uses some internal IDs for each distro.
|
||||||
|
# Extract the one for the distro we're publishing.
|
||||||
|
DISTRO_ID=$(
|
||||||
|
curl -s \
|
||||||
|
https://"$PACKAGECLOUD_TOKEN":@packagecloud.io/api/v1/distributions.json | \
|
||||||
|
jq '.deb | .[] | select(.index_name=="'"$DISTRO"'") | .versions | .[] | select(.index_name=="'"$DISTROVER"'") | .id'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Actually push the package.
|
||||||
|
curl \
|
||||||
|
-F "package[distro_version_id]=$DISTRO_ID" \
|
||||||
|
-F "package[package_file]=@$DEST_DIR/$PACKAGE" \
|
||||||
|
https://"$PACKAGECLOUD_TOKEN":@packagecloud.io/api/v1/repos/pimutils/vdirsyncer/packages.json
|
||||||
|
|
||||||
|
echo Done! ✨
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue