From 633eed425bb168b61eaf873f2395fca03c1b2c8e Mon Sep 17 00:00:00 2001 From: Romain Gallet Date: Sun, 21 Jun 2020 21:45:36 +0100 Subject: [PATCH] Arch packaging (#25) Arch packaging --- .github/workflows/release.yml | 68 +++++++++++++++++-- Makefile | 7 +- README.md | 8 ++- data/arch/authenticator-rs/PKGBUILD | 30 ++++++++ .../authenticator-rs/authenticator-rs.install | 16 +++++ data/debian/control | 8 +++ data/debian/postinst | 9 +++ 7 files changed, 136 insertions(+), 10 deletions(-) create mode 100644 data/arch/authenticator-rs/PKGBUILD create mode 100644 data/arch/authenticator-rs/authenticator-rs.install create mode 100644 data/debian/control create mode 100644 data/debian/postinst diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 011a9c3c..f99f0f82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,19 +47,77 @@ jobs: with: command: build - - name: Create binary + - name: Create Debian package env: DESTDIR: '~/authenticator-rs-deb' run: | - sudo mkdir -p $DESTDIR + mkdir -p $DESTDIR RELEASE_VERSION=${{ github.event.release.tag_name }} DESTDIR=$DESTDIR make debian-pkg - - name: Upload Release Asset + - 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: 'authenticator-rs-${{ github.event.release.tag_name }}-x86-64.deb' - asset_name: 'authenticator-rs-${{ github.event.release.tag_name }}-x86-64.deb' + asset_path: 'authenticator-rs-${{ github.event.release.tag_name }}-x86_64.deb' + asset_name: 'authenticator-rs-${{ 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: 'authenticator-rs-${{ github.event.release.tag_name }}-x86_64.deb.md5sum' + asset_name: 'authenticator-rs-${{ 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/authenticator-rs/releases/download/${{ github.event.release.tag_name }}/authenticator-rs-${{ github.event.release.tag_name }}-x86_64.deb -O data/arch/authenticator-rs/authenticator-rs-${{ github.event.release.tag_name }}-x86_64.deb + + MD5_SUM=$(md5sum data/arch/authenticator-rs/authenticator-rs-${{ 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}' data/arch/authenticator-rs/PKGBUILD + awk -i inplace 'BEGINFILE{print "pkgver=${{ github.event.release.tag_name }}"}{print}' data/arch/authenticator-rs/PKGBUILD + + - name: Validate PKGBUILD + id: validate-pkgbuild + uses: grumlimited/arch-pkgbuild-builder@v1.9.1 + with: + target: pkgbuild + pkgbuild: data/arch/authenticator-rs/PKGBUILD + + - name: Create arch package checksum file + run: | + sudo chown -R $USER . + md5sum data/arch/authenticator-rs/*.xz >> data/arch/authenticator-rs/authenticator-rs-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.xz.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: 'data/arch/authenticator-rs/authenticator-rs-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.xz' + asset_name: 'authenticator-rs-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.xz' + 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: 'data/arch/authenticator-rs/authenticator-rs-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.xz.md5sum' + asset_name: 'authenticator-rs-${{ github.event.release.tag_name }}-1-x86_64.pkg.tar.xz.md5sum' + asset_content_type: text/plain diff --git a/Makefile b/Makefile index bd8668dd..9a5045be 100644 --- a/Makefile +++ b/Makefile @@ -65,9 +65,10 @@ clean : debian-pkg : install mkdir -p $(DESTDIR)/DEBIAN - cp data/deb/control $(DESTDIR)/DEBIAN/ + cp data/debian/control $(DESTDIR)/DEBIAN/ echo "Version: $(RELEASE_VERSION)" >> $(DESTDIR)/DEBIAN/control - cp data/deb/postinst $(DESTDIR)/DEBIAN/ + cp data/debian/postinst $(DESTDIR)/DEBIAN/ chmod 775 $(DESTDIR)/DEBIAN/postinst - dpkg-deb --build $(DESTDIR) authenticator-rs-$(RELEASE_VERSION)-x86-64.deb + dpkg-deb --build $(DESTDIR) authenticator-rs-$(RELEASE_VERSION)-x86_64.deb + md5sum authenticator-rs-$(RELEASE_VERSION)-x86_64.deb > authenticator-rs-$(RELEASE_VERSION)-x86_64.deb.md5sum diff --git a/README.md b/README.md index 028c50a6..12848368 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,16 @@ See [releases](https://github.com/grumlimited/authenticator-rs/releases). ## Installing -#### Debian - Download from the [release](https://github.com/grumlimited/authenticator-rs/releases) page. +#### Debian + dpkg -i authenticator-rs-x.x.x-x86-64.deb +#### Arch Linux + + pacman -U authenticator-rs-x.x.x-1-x86_64.pkg.tar.xz + ## Building cargo build diff --git a/data/arch/authenticator-rs/PKGBUILD b/data/arch/authenticator-rs/PKGBUILD new file mode 100644 index 00000000..f5c54be5 --- /dev/null +++ b/data/arch/authenticator-rs/PKGBUILD @@ -0,0 +1,30 @@ +# Maintainer: Romain Gallet +_packager="Romain Gallet " +pkgname=authenticator-rs +# pkgver=0.0.8 # set in CI +pkgrel=1 +pkgdesc='MFA Authenticator. TOTP-MFA application written in Rust and GTK3.' +arch=('x86_64') +url="https://github.com/grumlimited/$pkgname/releases/download/$pkgver/$pkgname-$pkgver-$arch.deb" +license=('GPLv3') +groups=() +depends=('cairo' 'desktop-file-utils' 'gcc-libs' 'gdk-pixbuf2' 'glib2' 'gtk3' 'hicolor-icon-theme' 'pango' 'sqlite') +makedepends=() +checkdepends=() +optdepends=() +provides=() +replaces=() +backup=() +options=() +install=$pkgname.install +source=($url) +noextract=() + +build() { + rm control.tar.xz + tar xvf data.tar.xz +} + +package() { + cp -fr usr/ ${pkgdir} +} diff --git a/data/arch/authenticator-rs/authenticator-rs.install b/data/arch/authenticator-rs/authenticator-rs.install new file mode 100644 index 00000000..32e12056 --- /dev/null +++ b/data/arch/authenticator-rs/authenticator-rs.install @@ -0,0 +1,16 @@ +post_install() { + gtk-update-icon-cache -q -t -f usr/share/icons/hicolor + + chmod +x /usr/bin/authenticator-rs + + update-desktop-database -q +} + +post_upgrade() { + post_install +} + +post_remove() { + gtk-update-icon-cache -q -t -f usr/share/icons/hicolor + update-desktop-database -q +} diff --git a/data/debian/control b/data/debian/control new file mode 100644 index 00000000..9610c4f0 --- /dev/null +++ b/data/debian/control @@ -0,0 +1,8 @@ +Package: authenticator-rs +Section: development +Priority: optional +Architecture: all +Depends: libgtk-3-0, libsqlite3-0, libcairo2, desktop-file-utils, libgdk-pixbuf2.0-0, libglib2.0-0, hicolor-icon-theme +Maintainer: rgallet_at_grumlimited.co.uk +Description: MFA Authenticator + Authenticator-rs is a TOTP-MFA application written in Rust and GTK3. diff --git a/data/debian/postinst b/data/debian/postinst new file mode 100644 index 00000000..e0727bf2 --- /dev/null +++ b/data/debian/postinst @@ -0,0 +1,9 @@ +#!/bin/sh + +gtk-update-icon-cache -q -t -f usr/share/icons/hicolor + +chmod +x /usr/bin/authenticator-rs + +update-desktop-database -q + +exit 0