Skip to content

Commit bf32bdd

Browse files
committed
feat: implement release workflow, add contribution guidelines, and enhance update mechanism
1 parent 89f9e84 commit bf32bdd

File tree

12 files changed

+716
-422
lines changed

12 files changed

+716
-422
lines changed

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
include:
17+
- goos: linux
18+
goarch: amd64
19+
- goos: linux
20+
goarch: arm64
21+
- goos: darwin
22+
goarch: amd64
23+
- goos: darwin
24+
goarch: arm64
25+
- goos: windows
26+
goarch: amd64
27+
- goos: windows
28+
goarch: arm64
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version: '1.25'
35+
36+
- name: Build
37+
env:
38+
GOOS: ${{ matrix.goos }}
39+
GOARCH: ${{ matrix.goarch }}
40+
run: |
41+
VERSION=${GITHUB_REF#refs/tags/}
42+
OUTPUT=sgs-${{ matrix.goos }}-${{ matrix.goarch }}
43+
if [ "${{ matrix.goos }}" = "windows" ]; then
44+
OUTPUT="${OUTPUT}.exe"
45+
fi
46+
go build -ldflags "-X github.com/bacchus-snu/sgs-cli/internal/sgs.Version=${VERSION}" \
47+
-o ${OUTPUT} ./cmd/sgs
48+
49+
- name: Upload artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: sgs-${{ matrix.goos }}-${{ matrix.goarch }}
53+
path: sgs-*
54+
55+
release:
56+
needs: build
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Download all artifacts
60+
uses: actions/download-artifact@v4
61+
with:
62+
path: artifacts
63+
64+
- name: Collect binaries
65+
run: |
66+
mkdir -p release
67+
find artifacts -type f -name 'sgs-*' -exec cp {} release/ \;
68+
ls -la release/
69+
70+
- name: Create Release
71+
uses: softprops/action-gh-release@v2
72+
with:
73+
files: release/*
74+
generate_release_notes: true

CONTRIBUTING.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Contributing to SGS CLI
2+
3+
Thank you for your interest in contributing to SGS CLI! This document provides guidelines and instructions for contributing.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- Go 1.25 or higher
10+
- Access to a Kubernetes cluster (for testing)
11+
- Git
12+
13+
### Clone and Build
14+
15+
```bash
16+
git clone https://github.com/bacchus-snu/sgs-cli.git
17+
cd sgs-cli
18+
go build -o bin/sgs ./cmd/sgs
19+
```
20+
21+
### Running Tests
22+
23+
```bash
24+
go test ./...
25+
```
26+
27+
### Linting
28+
29+
```bash
30+
# Install golangci-lint if not already installed
31+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
32+
33+
# Run linter
34+
golangci-lint run
35+
```
36+
37+
## Project Structure
38+
39+
```text
40+
sgs-cli/
41+
├── cmd/sgs/ # Application entry point
42+
├── internal/
43+
│ ├── cleanup/ # Interrupt handling and cleanup
44+
│ ├── client/ # Kubernetes client, config, and updates
45+
│ ├── cmd/ # CLI commands (Cobra)
46+
│ ├── node/ # Node operations
47+
│ ├── session/ # Session operations
48+
│ ├── sgs/ # Shared constants and version
49+
│ ├── user/ # User identity from OIDC
50+
│ ├── volume/ # Volume and session management
51+
│ └── workspace/ # Workspace operations
52+
└── .github/workflows/ # CI/CD workflows
53+
```
54+
55+
## Code Style
56+
57+
- Follow standard Go conventions and idioms
58+
- Use `gofmt` for formatting
59+
- Keep functions focused and small
60+
- Add comments for exported functions and types
61+
- Error messages should be lowercase and not end with punctuation
62+
63+
### Naming Conventions
64+
65+
- Use camelCase for unexported identifiers
66+
- Use PascalCase for exported identifiers
67+
- Keep names concise but descriptive
68+
69+
## Making Changes
70+
71+
### Branch Naming
72+
73+
- `feature/description` - New features
74+
- `fix/description` - Bug fixes
75+
- `docs/description` - Documentation updates
76+
- `refactor/description` - Code refactoring
77+
78+
### Commit Messages
79+
80+
Write clear, concise commit messages:
81+
82+
```text
83+
feat: add volume copy progress indicator
84+
85+
- Show bytes transferred during copy
86+
- Display estimated time remaining
87+
- Support quiet mode with --quiet flag
88+
```
89+
90+
Prefixes:
91+
92+
- `feat:` - New feature
93+
- `fix:` - Bug fix
94+
- `docs:` - Documentation
95+
- `refactor:` - Code refactoring
96+
- `test:` - Adding tests
97+
- `chore:` - Maintenance tasks
98+
99+
### Pull Requests
100+
101+
1. Create a feature branch from `main`
102+
2. Make your changes with clear commits
103+
3. Ensure tests pass and code is formatted
104+
4. Submit a PR with a clear description
105+
5. Address review feedback
106+
107+
## Adding New Commands
108+
109+
1. Create a new file in `internal/cmd/` (e.g., `mycommand.go`)
110+
2. Define the cobra command
111+
3. Register it in `init()` or add to parent command
112+
4. Add tests if applicable
113+
114+
Example:
115+
116+
```go
117+
package cmd
118+
119+
import (
120+
"fmt"
121+
"github.com/spf13/cobra"
122+
)
123+
124+
var myCmd = &cobra.Command{
125+
Use: "mycommand",
126+
Short: "Short description",
127+
Long: `Longer description with examples.`,
128+
Run: runMyCommand,
129+
}
130+
131+
func init() {
132+
rootCmd.AddCommand(myCmd)
133+
}
134+
135+
func runMyCommand(cmd *cobra.Command, args []string) {
136+
// Implementation
137+
}
138+
```
139+
140+
## Modifying Constants
141+
142+
Constants are defined in `internal/sgs/constants.go`. These are hardcoded values used throughout the CLI:
143+
144+
- Label keys for Kubernetes resources
145+
- Annotation keys
146+
- Default values (image, storage size)
147+
- Resource limits
148+
149+
If you need to change these, ensure they match the server-side configuration.
150+
151+
## Version and Releases
152+
153+
### Version Format
154+
155+
We use semantic versioning: `vMAJOR.MINOR.PATCH`
156+
157+
- MAJOR: Breaking changes
158+
- MINOR: New features (backward compatible)
159+
- PATCH: Bug fixes
160+
161+
### Creating a Release
162+
163+
1. Update version-related documentation if needed
164+
1. Create and push a tag:
165+
166+
```bash
167+
git tag v1.2.3
168+
git push origin v1.2.3
169+
```
170+
171+
1. GitHub Actions will automatically:
172+
- Build binaries for all platforms
173+
- Create a GitHub release
174+
- Attach binaries to the release
175+
176+
### Building with Version
177+
178+
For local builds with a specific version:
179+
180+
```bash
181+
go build -ldflags "-X github.com/bacchus-snu/sgs-cli/internal/sgs.Version=v1.2.3" -o bin/sgs ./cmd/sgs
182+
```
183+
184+
## Testing
185+
186+
### Manual Testing
187+
188+
Before submitting a PR, test your changes:
189+
190+
```bash
191+
# Build
192+
go build -o bin/sgs ./cmd/sgs
193+
194+
# Test basic commands
195+
bin/sgs version
196+
bin/sgs --help
197+
bin/sgs get --help
198+
```
199+
200+
### Integration Testing
201+
202+
If you have access to a test cluster:
203+
204+
```bash
205+
bin/sgs fetch
206+
bin/sgs set workspace test-workspace
207+
bin/sgs get nodes
208+
bin/sgs get volumes
209+
```
210+
211+
## Getting Help
212+
213+
- Open an issue for bugs or feature requests
214+
- Check existing issues before creating new ones
215+
- Join discussions in pull requests
216+
217+
## License
218+
219+
By contributing, you agree that your contributions will be licensed under the MIT License.

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A command line interface for SNUCSE GPU Service. It provides a VM-like experienc
1313

1414
## Project Structure
1515

16-
```
16+
```text
1717
sgs-cli/
1818
├── cmd/
1919
│ └── sgs/ # Application entry point
@@ -28,7 +28,6 @@ sgs-cli/
2828
│ ├── user/ # User identity from OIDC tokens
2929
│ ├── volume/ # Volume and session management
3030
│ └── workspace/ # Workspace operations
31-
├── constants.yaml # Configuration constants (downloaded by fetch)
3231
├── go.mod
3332
├── go.sum
3433
├── Makefile
@@ -40,14 +39,10 @@ sgs-cli/
4039
SGS CLI downloads configuration files to `~/.sgs/` on first run or when `sgs fetch` is executed:
4140

4241
- `~/.sgs/config.yaml` - Kubernetes kubeconfig for cluster access
43-
- `~/.sgs/constants.yaml` - Configuration constants (labels, annotations, defaults)
42+
- `~/.sgs/metadata.yaml` - CLI metadata (last fetch timestamp)
4443
- `~/.sgs/cache/` - Token cache for OIDC authentication
4544

46-
The `constants.yaml` file is downloaded from this repository and contains configurable values like:
47-
48-
- Kubernetes label and annotation keys
49-
- Default container images and resource limits
50-
- Runtime class configuration
45+
The configuration is automatically refreshed if more than 24 hours have passed since the last fetch.
5146

5247
## Prerequisites
5348

@@ -56,6 +51,27 @@ The `constants.yaml` file is downloaded from this repository and contains config
5651

5752
## Installation
5853

54+
### Download Binary
55+
56+
Download the latest binary for your platform from [GitHub Releases](https://github.com/bacchus-snu/sgs-cli/releases):
57+
58+
```bash
59+
# Linux (amd64)
60+
curl -LO https://github.com/bacchus-snu/sgs-cli/releases/latest/download/sgs-linux-amd64
61+
chmod +x sgs-linux-amd64
62+
sudo mv sgs-linux-amd64 /usr/local/bin/sgs
63+
64+
# macOS (Apple Silicon)
65+
curl -LO https://github.com/bacchus-snu/sgs-cli/releases/latest/download/sgs-darwin-arm64
66+
chmod +x sgs-darwin-arm64
67+
sudo mv sgs-darwin-arm64 /usr/local/bin/sgs
68+
69+
# macOS (Intel)
70+
curl -LO https://github.com/bacchus-snu/sgs-cli/releases/latest/download/sgs-darwin-amd64
71+
chmod +x sgs-darwin-amd64
72+
sudo mv sgs-darwin-amd64 /usr/local/bin/sgs
73+
```
74+
5975
### From Source
6076

6177
```bash
@@ -70,6 +86,10 @@ make build
7086
make install
7187
```
7288

89+
### Auto-Update
90+
91+
When running `sgs fetch`, the CLI automatically checks for new versions and offers to update.
92+
7393
## Build
7494

7595
```bash
@@ -91,11 +111,14 @@ make clean
91111
### Initial Setup
92112

93113
```bash
94-
# Download cluster configuration
114+
# Download cluster configuration (also checks for CLI updates)
95115
sgs fetch
96116

97117
# Set your workspace
98118
sgs set workspace <workspace-name>
119+
120+
# Check CLI version
121+
sgs version
99122
```
100123

101124
### List Resources

0 commit comments

Comments
 (0)