Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S7IPA-169 Add docker-based ubuntu packaging for libpostal #1

Merged
merged 29 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
24c6f12
initial approach
rcmorano Jun 30, 2020
762f049
fixed build triggers
rcmorano Jun 30, 2020
a95e55c
fixed indentation
rcmorano Jun 30, 2020
472b3c5
bump
rcmorano Jun 30, 2020
4568e0f
bump
rcmorano Jun 30, 2020
f58e170
bump
rcmorano Jun 30, 2020
a9bdaed
added missing assets
rcmorano Jun 30, 2020
8bbe464
testing releases (1/N try)
rcmorano Jun 30, 2020
da6b9e9
fixed id issues
rcmorano Jun 30, 2020
9ca2ae2
fixed typo
rcmorano Jun 30, 2020
5c8c5c8
added build job depend for release one :)
rcmorano Jun 30, 2020
6f81121
minor fixes
rcmorano Jun 30, 2020
f07d4a3
fixing more typos u_u
rcmorano Jun 30, 2020
3e62ffd
ouf
rcmorano Jun 30, 2020
50dd2b3
test123
rcmorano Jun 30, 2020
45cafef
changed filenames (gh release action does not support wildcard, but w…
rcmorano Jun 30, 2020
8054d8c
fixing artifacts path for upload (I think)
rcmorano Jun 30, 2020
7043420
changed tag names to use commit instead of ref
rcmorano Jun 30, 2020
05289e8
added version parsing for release name/tag
rcmorano Jun 30, 2020
7d69d69
merged 2-jobs in a single one (so we speed up and get rid of artifacts
rcmorano Jun 30, 2020
e30e7b5
trying diff approach while shortening GITHUB_SHA
rcmorano Jun 30, 2020
9be80a7
bunch of updates (multi ubuntu version, etc)
rcmorano Jul 1, 2020
0d98251
fixed postinstall script
rcmorano Jul 1, 2020
a21b4f0
revert matrix tests
rcmorano Jul 1, 2020
f89c5af
fixing invalid ids...
rcmorano Jul 1, 2020
f1c93ce
fixing typo introduced by pressing DEL on my mac kb :@
rcmorano Jul 1, 2020
4de5e19
fixxxx
rcmorano Jul 1, 2020
69f7d99
fix++
rcmorano Jul 1, 2020
2f7b5a7
reverted to use the gh-releases for data package
rcmorano Jul 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/docker-builds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: docker builds
on: [push, pull_request]

jobs:
build:
name: Build OS packages inside a docker container and create release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Make git short-commit available for the different steps
id: metadata
env:
UBUNTU_VERSIONS: 16.04 18.04
run: |
echo "::set-output name=commit::$(echo ${GITHUB_SHA} | head -c7)"
echo "::set-output name=version::$(sed 's|^v||' versions/parser)"
- name: Build
env:
DOCKER_IMAGE_NAME: stuart/libpostal
UBUNTU_VERSIONS: "16.04 18.04"
run: |
pwd
ls -hal
git status -sb
for ubuver in ${UBUNTU_VERSIONS}
do
docker build \
--build-arg UBUNTU_VERSION=${ubuver} \
-t ${DOCKER_IMAGE_NAME}:${ubuver} .
CID=$(docker create ${DOCKER_IMAGE_NAME}:${ubuver})
docker cp ${CID}:/output ./output-ubuntu-${ubuver}
done
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.metadata.outputs.version }}-${{ steps.metadata.outputs.commit }}
release_name: Release ${{ steps.metadata.outputs.version }}-${{ steps.metadata.outputs.commit }}
body: |
Automatically generated by GH action on this project
draft: false
prerelease: false
- name: Upload .deb package release asset (ubuntu-16.04)
id: upload-deb-release-asset-ubuntu-16-04
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./output-ubuntu-16.04/libpostal_${{ steps.metadata.outputs.version }}+git${{ steps.metadata.outputs.commit }}_amd64.deb
asset_name: ubuntu-16.04-libpostal_${{ steps.metadata.outputs.version }}+git${{ steps.metadata.outputs.commit }}_amd64.deb #FIXME: find a way to dynamically set upstream version
asset_content_type: application/vnd.debian.binary-package
- name: Upload data release asset (ubuntu-16.04)
id: upload-data-release-asset-ubuntu-16-04
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./output-ubuntu-16.04/data.tgz
asset_name: ubuntu-16.04-data-${{ steps.metadata.outputs.version }}-${{ steps.metadata.outputs.commit }}.tar.gz #FIXME: find a way to dynamically set upstream version
asset_content_type: application/tar+gzip
- name: Upload .deb package release asset (ubuntu-18.04)
id: upload-deb-release-asset-ubuntu-18-04
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./output-ubuntu-18.04/libpostal_${{ steps.metadata.outputs.version }}+git${{ steps.metadata.outputs.commit }}_amd64.deb
asset_name: ubuntu-18.04-libpostal_${{ steps.metadata.outputs.version }}+git${{ steps.metadata.outputs.commit }}_amd64.deb #FIXME: find a way to dynamically set upstream version
asset_content_type: application/vnd.debian.binary-package
- name: Upload data release asset (ubuntu-18.04)
id: upload-data-release-asset-ubuntu-18-04
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./output-ubuntu-18.04/data.tgz
asset_name: ubuntu-18.04-data-${{ steps.metadata.outputs.version }}-${{ steps.metadata.outputs.commit }}.tar.gz #FIXME: find a way to dynamically set upstream version
asset_content_type: application/tar+gzip
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG UBUNTU_VERSION="18.04"
FROM ubuntu:${UBUNTU_VERSION}
ARG DEB_PACKAGE_NAME="libpostal"
ARG DEB_PACKAGE_DESC="Debian wrapping for https://github.com/openvenues/libpostal"
ARG DEB_PACKAGE_VERSION="0.0.1"
ARG BASE_PACKAGES="ruby ruby-dev rubygems build-essential curl autoconf automake libtool pkg-config git gettext"
ENV APT_ARGS="-y -o APT::Install-Suggests=false -o APT::Install-Recommends=false"

RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install ${APT_ARGS} ${BASE_PACKAGES} && \
gem install --no-document fpm
COPY ./ /src
WORKDIR /src
RUN bash bootstrap.sh && \
mkdir -p /output/usr && \
./configure --prefix=/output/usr && \
make -j && \
make install
# move out big files from the package
WORKDIR /output
RUN tar -zcf data.tgz usr/share/libpostal && \
rm -rf /output/usr/share/libpostal/*
# build deb package
RUN export DEB_PACKAGE_VERSION=$(sed 's|^v||' /src/versions/parser)+git$(bash -c 'cd /src; git rev-parse HEAD | head -c7') && \
envsubst '${DEB_PACKAGE_VERSION}' < /src/assets/fpm-deb-scripts/postinst.sh.tpl > /src/assets/fpm-deb-scripts/postinst.sh && \
fpm -n ${DEB_PACKAGE_NAME} \
-v ${DEB_PACKAGE_VERSION} \
--description "${DEB_PACKAGE_DESC}" \
-s dir \
-t deb \
--after-install /src/assets/fpm-deb-scripts/postinst.sh \
/output/usr=/
46 changes: 46 additions & 0 deletions assets/fpm-deb-scripts/postinst.sh.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

download_data() {
. /etc/lsb-release
if [ "${DISTRIB_ID}" = "Ubuntu" ]
then
curl -sL https://github.com/StuartApp/libpostal/releases/download/${GH_RELEASE}/ubuntu-${DISTRIB_RELEASE}-data-${GH_RELEASE}.tar.gz | tar -C / -zxf -
fi
}

after_upgrade() {
echo "Upgrading data package '${GH_RELEASE}' from GH releases..."
download_data
}

after_install() {
echo "Installing data package '${GH_RELEASE}' from GH releases..."
download_data
}

export PACKAGE_VERSION=${DEB_PACKAGE_VERSION}
export GH_RELEASE=$(echo ${PACKAGE_VERSION} | sed 's|+git|-|')

if [ "${1}" = "configure" -a -z "${2}" ] || \
[ "${1}" = "abort-remove" ]
then
# "after install" here
# "abort-remove" happens when the pre-removal script failed.
# In that case, this script, which should be idemptoent, is run
# to ensure a clean roll-back of the removal.
installingVersion="${2}"
after_install
elif [ "${1}" = "configure" -a -n "${2}" ]
then
upgradeFromVersion="${2}"
# "after upgrade" here
# NOTE: This slot is also used when deb packages are removed,
# but their config files aren't, but a newer version of the
# package is installed later, called "Config-Files" state.
# basically, that still looks a _lot_ like an upgrade to me.
after_upgrade "${2}"
elif echo "${1}" | grep -E -q "(abort|fail)"
then
echo "Failed to install before the post-installation script was run." >&2
exit 1
fi