Skip to content

Commit 9788290

Browse files
committed
Add github action release workflow and support for bash
1 parent 0af3cc9 commit 9788290

File tree

2 files changed

+128
-4
lines changed

2 files changed

+128
-4
lines changed

.github/workflows/release.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build-linux:
10+
name: Build Linux
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install SQLCipher
16+
run: sudo apt-get install -y libsqlcipher-dev
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.22'
22+
23+
- name: Build Linux amd64
24+
run: |
25+
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
26+
go build -o dist/enveil-linux-amd64 ./cmd/enveil/
27+
28+
- name: Build Linux arm64
29+
run: |
30+
sudo apt-get install -y gcc-aarch64-linux-gnu
31+
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \
32+
CC=aarch64-linux-gnu-gcc \
33+
go build -o dist/enveil-linux-arm64 ./cmd/enveil/
34+
35+
- name: Upload Linux artifacts
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: linux-binaries
39+
path: dist/
40+
41+
build-macos:
42+
name: Build macOS
43+
runs-on: macos-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Install SQLCipher
48+
run: brew install sqlcipher
49+
50+
- name: Set up Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: '1.22'
54+
55+
- name: Build macOS amd64
56+
run: |
57+
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 \
58+
go build -o dist/enveil-darwin-amd64 ./cmd/enveil/
59+
60+
- name: Build macOS arm64
61+
run: |
62+
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 \
63+
go build -o dist/enveil-darwin-arm64 ./cmd/enveil/
64+
65+
- name: Upload macOS artifacts
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: macos-binaries
69+
path: dist/
70+
71+
release:
72+
name: Create Release
73+
needs: [build-linux, build-macos]
74+
runs-on: ubuntu-latest
75+
permissions:
76+
contents: write
77+
steps:
78+
- name: Download Linux binaries
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: linux-binaries
82+
path: dist/
83+
84+
- name: Download macOS binaries
85+
uses: actions/download-artifact@v4
86+
with:
87+
name: macos-binaries
88+
path: dist/
89+
90+
- name: Create checksums
91+
run: |
92+
cd dist
93+
sha256sum * > checksums.txt
94+
cat checksums.txt
95+
96+
- name: Create GitHub Release
97+
uses: softprops/action-gh-release@v2
98+
with:
99+
files: |
100+
dist/enveil-linux-amd64
101+
dist/enveil-linux-arm64
102+
dist/enveil-darwin-amd64
103+
dist/enveil-darwin-arm64
104+
dist/checksums.txt
105+
generate_release_notes: true

cmd/enveil/shellhook.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func runShellHook(cmd *cobra.Command, args []string) error {
7777
func runShellInit(cmd *cobra.Command, args []string) error {
7878
script := `
7979
# Enveil shell integration
80-
# Add this to your ~/.zshrc:
80+
# Add this to your ~/.zshrc or ~/.bashrc:
8181
# eval "$(enveil shell-init)"
8282
8383
_enveil_hook() {
@@ -88,19 +88,38 @@ func runShellInit(cmd *cobra.Command, args []string) error {
8888
fi
8989
}
9090
91-
# Run hook on directory change
91+
# Detect shell and register hook accordingly
92+
if [ -n "$ZSH_VERSION" ]; then
93+
# zsh
9294
autoload -U add-zsh-hook
9395
add-zsh-hook chpwd _enveil_hook
96+
elif [ -n "$BASH_VERSION" ]; then
97+
# bash
98+
if [[ "$PROMPT_COMMAND" != *"_enveil_hook"* ]]; then
99+
PROMPT_COMMAND="_enveil_hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
100+
fi
101+
fi
94102
95-
# Show enveil status on the right side of the prompt
103+
# Show enveil status in prompt
96104
_enveil_prompt() {
97105
if [ -n "$ENVEIL_PROJECT" ]; then
106+
if [ -n "$ZSH_VERSION" ]; then
98107
echo "%F{cyan}[${ENVEIL_PROJECT}/${ENVEIL_ENV}]%f"
108+
else
109+
echo "\[\033[0;36m\][${ENVEIL_PROJECT}/${ENVEIL_ENV}]\[\033[0m\]"
110+
fi
99111
fi
100112
}
101113
102-
# Use RPROMPT so it doesn't interfere with existing themes
114+
if [ -n "$ZSH_VERSION" ]; then
115+
# zsh - use RPROMPT
103116
RPROMPT='$(_enveil_prompt)'
117+
elif [ -n "$BASH_VERSION" ]; then
118+
# bash - prepend to PS1
119+
if [[ "$PS1" != *'$(_enveil_prompt)'* ]]; then
120+
PS1='$(_enveil_prompt)'"$PS1"
121+
fi
122+
fi
104123
105124
# Run once on shell startup for current directory
106125
_enveil_hook

0 commit comments

Comments
 (0)