Skip to content

Commit

Permalink
Debian & Arch release pipeline (#9)
Browse files Browse the repository at this point in the history
Debian & Arch release pipeline (#9)
  • Loading branch information
gr211 authored May 9, 2023
1 parent 2554bfa commit c014a4d
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 18 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
on:
release:
types:
- created

name: Continuous integration

jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.69.0 # MSRV

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/release
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: System dependencies
run: |
sudo apt-get update
sudo apt-get install -y sudo \
make
mkdir -p ~/.cargo/release
- name: Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy

- name: Build
uses: actions-rs/cargo@v1
with:
command: build

- name: Create Debian package
env:
DESTDIR: '~/kinesis-tailr-deb'
run: |
mkdir -p $DESTDIR
RELEASE_VERSION=${{ github.event.release.tag_name }} DESTDIR=$DESTDIR make debian-pkg
- name: Upload Debian release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: '${{ github.event.release.upload_url }}'
asset_path: 'kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb'
asset_name: 'kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb'
asset_content_type: application/octet-stream

- name: Upload Debian release checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: '${{ github.event.release.upload_url }}'
asset_path: 'kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb.md5sum'
asset_name: 'kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb.md5sum'
asset_content_type: text/plain

arch:
runs-on: ubuntu-latest
needs: [ci]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare arch package metadata
run: |
wget https://github.com/grumlimited/kinesis-tailr/releases/download/${{ github.event.release.tag_name }}/kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb -O build-aux/arch/kinesis-tailr-bin/kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb
MD5_SUM=$(md5sum build-aux/arch/kinesis-tailr-bin/kinesis-tailr-${{ github.event.release.tag_name }}-x86_64.deb | awk '{print $1}')
awk -v q="'" -v MD5_SUM=$MD5_SUM -i inplace 'BEGINFILE{print "md5sums=(" q MD5_SUM q ")"}{print}' build-aux/arch/kinesis-tailr-bin/PKGBUILD
awk -i inplace 'BEGINFILE{print "pkgver=${{ github.event.release.tag_name }}"}{print}' build-aux/arch/kinesis-tailr-bin/PKGBUILD
- name: Validate PKGBUILD
id: validate-pkgbuild
uses: grumlimited/arch-pkgbuild-builder@b0f22da174699e6795f4434f252e15e6c8265b9e
with:
debug: true
target: pkgbuild
pkgname: build-aux/arch/kinesis-tailr-bin/

- name: Create arch package checksum file
run: |
sudo chown -R $USER .
md5sum build-aux/arch/kinesis-tailr-bin/*.zst >> build-aux/arch/kinesis-tailr-bin/kinesis-tailr-bin-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.zst.md5sum
- name: Upload Arch Linux release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: '${{ github.event.release.upload_url }}'
asset_path: 'build-aux/arch/kinesis-tailr-bin/kinesis-tailr-bin-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.zst'
asset_name: 'kinesis-tailr-bin-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.zst'
asset_content_type: application/octet-stream

- name: Upload Arch Linux release checksum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: '${{ github.event.release.upload_url }}'
asset_path: 'build-aux/arch/kinesis-tailr-bin/kinesis-tailr-bin-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.zst.md5sum'
asset_name: 'kinesis-tailr-bin-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.zst.md5sum'
asset_content_type: text/plain
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@

rpmbuild/RPMS
rpmbuild/SRPMS
*.deb
*.md5sum
23 changes: 5 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
FROM amd64/centos:7
FROM library/rust:1.69.0-slim-buster

ARG USER=grumlimited
ARG GROUP=grumlimited
ARG UID=1000
ARG GID=1000
RUN apt-get update && \
apt-get install -y make sudo

ENV HOME=/home/$USER

# https://stackoverflow.com/questions/74345206/centos-7-docker-yum-installation-gets-stuck
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' > /etc/nsswitch.conf
WORKDIR /kinesis-tailr

RUN groupadd -g $GID $USER && \
useradd $USER -d $HOME -g $GID -u $UID && \
chown -R $USER:$GROUP $HOME
ENTRYPOINT ["make", "debian-pkg", "RELEASE_VERSION=0.1", "DESTDIR=build"]


RUN ulimit -n 1024 && yum install -y epel-release
RUN ulimit -n 1024 && yum install -y epel-release && \
yum update -y && \
yum install -y rpm-build rust make cargo

USER $USER
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,13 @@ clean :

uninstall :
rm -f $(bindir)/$(NAME)

debian-pkg : install
mkdir -p $(DESTDIR)/DEBIAN
cp build-aux/debian/control $(DESTDIR)/DEBIAN/
echo "Version: $(RELEASE_VERSION)" >> $(DESTDIR)/DEBIAN/control
cp build-aux/debian/postinst $(DESTDIR)/DEBIAN/
chmod 775 $(DESTDIR)/DEBIAN/postinst
dpkg-deb --build $(DESTDIR) kinesis-tailr-$(RELEASE_VERSION)-x86_64.deb
md5sum kinesis-tailr-$(RELEASE_VERSION)-x86_64.deb > kinesis-tailr-$(RELEASE_VERSION)-x86_64.deb.md5sum

30 changes: 30 additions & 0 deletions build-aux/arch/kinesis-tailr-bin/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Maintainer: Romain Gallet <[email protected]>
# Contributor: Romain Gallet <[email protected]>
_packager="Romain Gallet <[email protected]>"
_deb_pkgname=kinesis-tailr
pkgname=kinesis-tailr-bin
pkgrel=1
pkgdesc='Kinesis tail tool'
arch=('x86_64')
url="https://github.com/grumlimited/$_deb_pkgname"
license=('GPLv3')
groups=()
depends=()
makedepends=()
checkdepends=()
optdepends=()
provides=()
replaces=()
backup=()
options=()
source=("$url/releases/download/$pkgver/$_deb_pkgname-$pkgver-$arch.deb")
noextract=()

build() {
rm control.tar.zst
tar xvf data.tar.zst
}

package() {
cp -fr usr/ ${pkgdir}
}
6 changes: 6 additions & 0 deletions build-aux/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package: kinesis-tailr
Section: development
Priority: optional
Architecture: all
Maintainer: rgallet_at_grumlimited.co.uk
Description: Kinesis tail tool
5 changes: 5 additions & 0 deletions build-aux/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

chmod +x /usr/bin/kinesis-tailr

exit 0
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
rust:
build: .
# entrypoint: ['/bin/sleep', '60000']
volumes:
- '.:/kinesis-tailr'
- '~/.cargo:/root/.cargo'

0 comments on commit c014a4d

Please sign in to comment.