Skip to content

Commit 75d2a80

Browse files
committed
add snap packaging
Signed-off-by: artivis <[email protected]>
1 parent 2ee8801 commit 75d2a80

File tree

4 files changed

+238
-0
lines changed

4 files changed

+238
-0
lines changed

.github/workflows/snap.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: snap
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
snap-file: ${{ steps.build-snap.outputs.snap }}
16+
steps:
17+
- name: Checkout snapcraft.yaml branch
18+
uses: actions/checkout@v4
19+
20+
- name: Build snap
21+
uses: snapcore/action-build@v1
22+
id: build-snap
23+
24+
- name: Upload snap artifact
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: atuin-snap
28+
path: ${{ steps.build-snap.outputs.snap }}
29+
retention-days: 7
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
needs: build
34+
steps:
35+
- name: Download snap artifact
36+
uses: actions/download-artifact@v4
37+
with:
38+
name: atuin-snap
39+
40+
- name: Install snap
41+
run: |
42+
sudo snap install ${{needs.build.outputs.snap-file}} --dangerous
43+
44+
- name: Snap info
45+
run: |
46+
snap info atuin
47+
48+
- name: Run custom test script
49+
shell: bash
50+
run: |
51+
atuin --help
52+
53+
publish:
54+
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
55+
runs-on: ubuntu-latest
56+
needs: [build, test]
57+
steps:
58+
- name: Download snap artifact
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: atuin-snap
62+
63+
- name: Publish snap
64+
uses: snapcore/action-publish@v1
65+
env:
66+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.store-login }}
67+
if: env.SNAPCRAFT_STORE_CREDENTIALS
68+
with:
69+
snap: ${{ needs.build.outputs.snap-file }}
70+
release: ${{ startsWith(github.ref, 'refs/tags/') && 'candidate' || 'edge'}}

snap/hooks/install

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh -e
2+
3+
# Print to the journal
4+
# sudo journalctl -r -t ${SNAP_NAME}
5+
6+
logger -t ${SNAP_NAME} << EOF
7+
8+
9+
10+
_______ __ __ _______ __ _ ___ _ __ __ _______ __ __
11+
| || | | || _ || | | || | | | | | | || || | | |
12+
|_ _|| |_| || |_| || |_| || |_| | | |_| || _ || | | |
13+
| | | || || || _| | || | | || |_| |
14+
| | | || || _ || |_ |_ _|| |_| || |
15+
| | | _ || _ || | | || _ | | | | || |
16+
|___| |__| |__||__| |__||_| |__||___| |_| |___| |_______||_______|
17+
18+
19+
20+
Thanks for installing Atuin! I really hope you like it.
21+
22+
If you have any issues, please open an issue on GitHub or visit our Discord (https://discord.gg/jR3tfchVvW)!
23+
24+
If you love Atuin, please give us a star on GitHub! It really helps ⭐️ https://github.com/atuinsh/atuin
25+
26+
Please run "atuin register" to get setup with sync, or "atuin login" if you already have an account
27+
28+
EOF

snap/local/launcher

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -eq 3 ] && [ "$2" == "import" ]; then
4+
if ! snapctl is-connected dot-bash-history && \
5+
! snapctl is-connected dot-fish-history && \
6+
! snapctl is-connected dot-resh-history && \
7+
! snapctl is-connected dot-zsh-history; then
8+
echo "Error: Requested to import existing history but no interface connected which would allow this."
9+
echo "Please connect the appropriate interface such as: "
10+
echo ""
11+
echo "sudo snap connect $SNAP_NAME:dot-bash-history"
12+
echo ""
13+
echo "and try again."
14+
echo "To see which interfaces are available and whether they are connected:"
15+
echo ""
16+
echo "snap connections $SNAP_NAME"
17+
exit 1
18+
fi
19+
20+
# Atuin looks for the bash history using directories::UserDirs::UserDir
21+
# which relies on $HOME. This env var is remapped in Snaps.
22+
# We thus workaround that by setting HISTFILE which takes precedence
23+
# in atuin loading logic.
24+
if snapctl is-connected dot-bash-history && [[ -z "${HISTFILE}" ]]; then
25+
export HISTFILE="${SNAP_REAL_HOME}/.bash_history"
26+
fi
27+
fi
28+
29+
if snapctl is-connected atuin-existing-config-and-data; then
30+
export XDG_CONFIG_HOME="${SNAP_REAL_HOME}/.config"
31+
export XDG_DATA_HOME="${SNAP_REAL_HOME}/.local/share"
32+
fi
33+
34+
exec "$@"

snap/snapcraft.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: atuin
2+
adopt-info: atuin
3+
summary: Magical shell history
4+
description: |
5+
Atuin replaces your existing shell history with a SQLite database,
6+
and records additional context for your commands.
7+
Additionally, it provides optional and fully encrypted synchronisation of your history between machines,
8+
via an Atuin server.
9+
10+
To import existing history,
11+
make sure to connect the appropriate interface such as:
12+
13+
`sudo snap connect atuin:dot-bash-history`
14+
15+
To see which interfaces are available and whether they are connected:
16+
17+
`snap connections atuin`
18+
19+
Furthermore, when using `atuin import auto`,
20+
you must export your current shell such as,
21+
22+
`SHELL=${SHELL} atuin import auto`
23+
24+
When using this snap, atuin's configuration and data file live respectively at
25+
- $HOME/snap/atuin/.config/atuin
26+
- $HOME/snap/atuin/local/share/atuin
27+
28+
issues: https://github.com/atuinsh/atuin/issues
29+
contact: https://github.com/atuinsh/atuin/issues
30+
source-code: https://github.com/atuinsh/atuin
31+
donation: https://github.com/sponsors/atuinsh
32+
website: https://atuin.sh/
33+
license: MIT
34+
35+
confinement: strict
36+
base: core24
37+
38+
apps:
39+
atuin:
40+
command: atuin
41+
command-chain: [usr/local/atuin/launcher]
42+
completer: usr/share/bash-completion/completions/atuin-completion.bash
43+
plugs:
44+
- dot-bash-history
45+
- dot-fish-history
46+
- dot-resh-history
47+
- dot-zsh-history
48+
- network
49+
- network-bind
50+
51+
plugs:
52+
dot-bash-history:
53+
interface: personal-files
54+
read: [$HOME/.bash_history]
55+
dot-fish-history:
56+
interface: personal-files
57+
read: [$HOME/.local/share/fish/fish_history]
58+
dot-resh-history:
59+
interface: personal-files
60+
read: [$HOME/.local/share/resh/history.reshjson]
61+
dot-zsh-history:
62+
interface: personal-files
63+
read: [$HOME/.zsh_history]
64+
65+
parts:
66+
atuin:
67+
plugin: rust
68+
source: .
69+
override-pull: |
70+
craftctl default
71+
72+
git config --global --add safe.directory '*'
73+
version="$(git describe --always --tags --exclude='weekly' | sed -e 's/^v//;s/-/+git/;y/-/./')"
74+
[ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable
75+
craftctl set version="$version"
76+
craftctl set grade="$grade"
77+
78+
atuin-launcher:
79+
after: [atuin]
80+
plugin: dump
81+
source: snap/local/
82+
organize:
83+
'launcher': usr/local/atuin/
84+
85+
atuin-completer:
86+
after: [atuin]
87+
plugin: nil
88+
organize:
89+
'atuin-completion.bash': usr/share/bash-completion/completions/
90+
override-build: |
91+
$CRAFT_STAGE/atuin gen-completions --shell bash > $CRAFT_PART_INSTALL/atuin-completion.bash
92+
93+
ble:
94+
plugin: make
95+
build-packages: [gawk]
96+
source: https://github.com/akinomyoga/ble.sh.git
97+
make-parameters:
98+
- PREFIX=/usr
99+
100+
bash-preexec:
101+
plugin: nil
102+
build-packages: [curl]
103+
organize:
104+
'bash-preexec.sh': usr/share/
105+
override-build: |
106+
curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o $CRAFT_PART_INSTALL/bash-preexec.sh

0 commit comments

Comments
 (0)