-
Notifications
You must be signed in to change notification settings - Fork 0
241 lines (196 loc) · 6.91 KB
/
ci.yml
File metadata and controls
241 lines (196 loc) · 6.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Build and Publish TShare
on:
push:
branches:
- '**'
pull_request:
workflow_dispatch:
permissions: write-all
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.88"
components: rustfmt, clippy
- name: Install just
uses: extractions/setup-just@v1
- name: Install HTML formatter
run: pip install djlint
- name: Install taplo-cli
run: cargo install taplo-cli
- name: Check formatting
run: just format-check
- name: Run clippy
run: just lint
- name: Run tests
run: just test
- name: Check documentation
run: just docs-check
docs:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.88"
- name: Install just
uses: extractions/setup-just@v1
- name: Generate documentation
run: just docs
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: tshare-docs
path: target/doc/
retention-days: 30
if-no-files-found: error
build:
name: Build Multi-Platform
needs: [lint, docs]
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.88"
targets: ${{ matrix.target }}
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare Artifacts
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/tshare release/tshare-linux-x64
chmod +x release/*
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: tshare-${{ matrix.target }}
path: release/*
retention-days: 7
if-no-files-found: error
build-deb:
name: Build Debian Package
needs: [lint, docs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.88"
- name: Install just
uses: extractions/setup-just@v1
- name: Install dpkg-dev
run: sudo apt-get update && sudo apt-get install -y dpkg-dev
- name: Build .deb package
run: just build-deb
- name: Upload .deb Artifact
uses: actions/upload-artifact@v4
with:
name: tshare-deb
path: releases/*.deb
retention-days: 7
if-no-files-found: error
publish:
name: Publish Release
needs: [build, build-deb]
runs-on: ubuntu-latest
permissions:
contents: write
discussions: write
pull-requests: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '.') && (startsWith(github.event.head_commit.message, '0.') || startsWith(github.event.head_commit.message, '1.') || startsWith(github.event.head_commit.message, '2.') || startsWith(github.event.head_commit.message, '3.') || startsWith(github.event.head_commit.message, '4.') || startsWith(github.event.head_commit.message, '5.') || startsWith(github.event.head_commit.message, '6.') || startsWith(github.event.head_commit.message, '7.') || startsWith(github.event.head_commit.message, '8.') || startsWith(github.event.head_commit.message, '9.'))
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Git Tag
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
TAG_NAME=$(git log -1 --pretty=%s | grep -oE '\b[0-9]+\.[0-9]+\.[0-9]+\b')
TAG_NAME="v${TAG_NAME}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists. Skipping tag creation."
else
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
fi
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
- name: Download Linux Artifacts
uses: actions/download-artifact@v4
with:
name: tshare-x86_64-unknown-linux-gnu
path: artifacts/linux
- name: Download Debian Package
uses: actions/download-artifact@v4
with:
name: tshare-deb
path: artifacts/deb
- name: Prepare Release Files
run: |
mkdir -p release
cp artifacts/linux/* release/
cp artifacts/deb/*.deb release/
chmod +x release/tshare-linux-x64
- name: Get Previous Tag
id: prev_tag
run: |
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -2 | tail -1)
if [ -z "$PREV_TAG" ]; then
# If no previous tag, use first commit
PREV_TAG=$(git rev-list --max-parents=0 HEAD)
fi
echo "PREV_TAG=${PREV_TAG}" >> $GITHUB_ENV
echo "Previous tag: $PREV_TAG"
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ env.TAG_NAME }}
with:
tag_name: ${{ env.TAG_NAME }}
name: TShare ${{ env.TAG_NAME }}
body: |
TShare - Terminal Sharing Made Simple
## What's New
- See the full changelog: https://github.com/${{ github.repository }}/compare/${{ env.PREV_TAG }}...${{ env.TAG_NAME }}
## Installation
### Debian/Ubuntu
```bash
# Download and install the .deb package
wget https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/tshare_${{ env.TAG_NAME }}.deb
sudo dpkg -i tshare_${{ env.TAG_NAME }}.deb
```
### Linux Binary
```bash
# Download binary
wget https://github.com/${{ github.repository }}/releases/download/${{ env.TAG_NAME }}/tshare-linux-x64
chmod +x tshare-linux-x64
```
## Usage
```bash
# Start tunnel server
./tshare-linux-x64 tunnel &
# Start web server
./tshare-linux-x64 web &
# Share your terminal
./tshare-linux-x64 connect
```
files: |
release/tshare-linux-x64
release/*.deb