Skip to content

Commit

Permalink
ci: add deb packaging (#823)
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Bjäreholt <erik.bjareholt@gmail.com>
  • Loading branch information
LunarWatcher and ErikBjare authored Nov 5, 2022
1 parent 8d68f8b commit 94e6f89
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ jobs:
cp -v $APPIMAGE_FILE ./dist/activitywatch-linux-x86_64.AppImage
- name: Package deb
if: runner.os == 'Linux'
run: |
# The entire process is deferred to a shell file for consistency.
./scripts/package/package-deb.sh
- name: Upload packages
uses: actions/upload-artifact@v3
with:
Expand Down
8 changes: 8 additions & 0 deletions scripts/package/deb/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Package: activitywatch
Architecture: amd64
Maintainer: Erik Bjäreholt <erik@bjareho.lt>
Depends:
Priority: optional
Version: SCRIPT_VERSION_HERE
Description: Open source time tracker
https://github.com/ActivityWatch/activitywatch
54 changes: 54 additions & 0 deletions scripts/package/package-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/bash
# Setting the shell is required, as `sh` doesn't support slicing.

# Fail fast
set -e
# Verbose commands for CI verification
set -x

VERSION=$(scripts/package/getversion.sh)
# Slice off the "v" from the tag, which is probably guaranteed
VERSION_NUM=${VERSION:1}
echo $VERSION_NUM
PKGDIR="activitywatch_$VERSION_NUM"

# Package tools
sudo apt-get install sed jdupes wget

if [ -d "PKGDIR" ]; then
sudo rm -rf $PKGDIR
fi

# .deb meta files
mkdir -p $PKGDIR/DEBIAN
# activitywatch's install location
mkdir -p $PKGDIR/opt
# Allows aw-qt to autostart.
mkdir -p $PKGDIR/etc/xdg/autostart
# Allows users to manually start aw-qt from their start menu.
mkdir -p $PKGDIR/usr/share/applications

# While storing the control file in a variable here, dumping it in a file is so unnecessarily
# complicated that it's easier to just dump move and sed.
cp ./scripts/package/deb/control $PKGDIR/DEBIAN/control
sed -i "s/SCRIPT_VERSION_HERE/${VERSION_NUM}/" $PKGDIR/DEBIAN/control

# Verify the file content
cat $PKGDIR/DEBIAN/control
# The entire opt directory (should) consist of dist/activitywatch/*

cp -r dist/activitywatch/ $PKGDIR/opt/

# Hard link duplicated libraries
# (I have no idea what this is for)
jdupes -L -r -S -Xsize-:1K $PKGDIR/opt/

sudo chown -R root:root $PKGDIR

# Prepare the .desktop file
sudo sed -i 's!Exec=aw-qt!Exec=/opt/activitywatch/aw-qt!' $PKGDIR/opt/activitywatch/aw-qt.desktop
sudo cp $PKGDIR/opt/activitywatch/aw-qt.desktop $PKGDIR/etc/xdg/autostart/
sudo cp $PKGDIR/opt/activitywatch/aw-qt.desktop $PKGDIR/usr/share/applications/

dpkg-deb --build $PKGDIR
sudo mv activitywatch_${VERSION_NUM}.deb dist/activitywatch-${VERSION}-linux-x86_64.deb

0 comments on commit 94e6f89

Please sign in to comment.