Skip to content

Commit d75377b

Browse files
committed
Updated version flag && Pipeline
1 parent e4d964d commit d75377b

File tree

5 files changed

+39
-208
lines changed

5 files changed

+39
-208
lines changed

.github/workflows/release.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ jobs:
6060
run: |
6161
# Create output directory
6262
mkdir -p dist
63-
63+
6464
# Define binary name
6565
if [ "${{ matrix.goos }}" = "windows" ]; then
6666
BINARY_NAME="coderun-${{ matrix.os }}-${{ matrix.arch }}.exe"
6767
else
6868
BINARY_NAME="coderun-${{ matrix.os }}-${{ matrix.arch }}"
6969
fi
70-
70+
7171
# Compile
72-
go build -ldflags="-s -w -X 'main.version=${{ env.VERSION }}'" -o "dist/${BINARY_NAME}" .
73-
72+
go build -ldflags="-s -w -X 'main.version=${{ env.VERSION }}' -X 'github.com/helmcode/coderun-cli/internal/utils.DefaultAPIURL=https://coderun-api.helmcode.com'" -o "dist/${BINARY_NAME}" .
73+
7474
# Verify file was created
7575
ls -la dist/
7676
@@ -99,10 +99,10 @@ jobs:
9999
run: |
100100
# Create final directory
101101
mkdir -p release
102-
102+
103103
# Move all binaries to release directory
104104
find dist/ -name "coderun-*" -type f -exec cp {} release/ \;
105-
105+
106106
# List files for verification
107107
ls -la release/
108108
@@ -119,51 +119,51 @@ jobs:
119119
name: Release ${{ env.VERSION }}
120120
body: |
121121
## 🎉 CodeRun CLI ${{ env.VERSION }}
122-
122+
123123
### 📦 Installation
124-
124+
125125
#### Linux (AMD64)
126126
```bash
127127
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-linux-amd64 -o coderun
128128
chmod +x coderun
129129
sudo mv coderun /usr/local/bin/
130130
```
131-
131+
132132
#### Linux (ARM64)
133133
```bash
134134
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-linux-arm64 -o coderun
135135
chmod +x coderun
136136
sudo mv coderun /usr/local/bin/
137137
```
138-
138+
139139
#### macOS (Intel)
140140
```bash
141141
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-darwin-amd64 -o coderun
142142
chmod +x coderun
143143
sudo mv coderun /usr/local/bin/
144144
```
145-
145+
146146
#### macOS (Apple Silicon)
147147
```bash
148148
curl -L https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/coderun-darwin-arm64 -o coderun
149149
chmod +x coderun
150150
sudo mv coderun /usr/local/bin/
151151
```
152-
152+
153153
#### Windows (AMD64)
154154
Download `coderun-windows-amd64.exe` and rename it to `coderun.exe`
155-
155+
156156
#### Windows (ARM64)
157157
Download `coderun-windows-arm64.exe` and rename it to `coderun.exe`
158-
158+
159159
### ✅ Installation Verification
160160
```bash
161161
coderun --version
162162
```
163-
163+
164164
### 🔒 Integrity Verification
165165
You can verify file integrity using `checksums.txt`
166-
166+
167167
files: |
168168
release/*
169169
draft: false

cmd/root.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
package cmd
22

33
import (
4-
"fmt"
5-
64
"github.com/spf13/cobra"
75
)
86

9-
// Version variables set from main
10-
var (
11-
buildVersion = "dev"
12-
buildCommit = "none"
13-
buildDate = "unknown"
14-
)
7+
// Version variable set from main
8+
var buildVersion = "dev"
159

1610
// SetVersionInfo configures version information from main
17-
func SetVersionInfo(version, commit, date string) {
11+
func SetVersionInfo(version string) {
1812
buildVersion = version
19-
buildCommit = commit
20-
buildDate = date
21-
22-
// Update version in rootCmd
23-
rootCmd.Version = fmt.Sprintf("%s (commit: %s, built: %s)", version, commit, date)
24-
}
25-
26-
// rootCmd represents the base command when called without any subcommands
13+
rootCmd.Version = version
14+
} // rootCmd represents the base command when called without any subcommands
2715
var rootCmd = &cobra.Command{
2816
Use: "coderun",
2917
Short: "CodeRun Container-as-a-Service CLI",

install.sh

Lines changed: 0 additions & 167 deletions
This file was deleted.

internal/utils/config.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@ import (
77
"path/filepath"
88
)
99

10+
// Default API URL (can be overridden at build time)
11+
var DefaultAPIURL = "http://localhost:8000"
12+
1013
// Config represents the CLI configuration
1114
type Config struct {
1215
BaseURL string `json:"base_url"`
1316
AccessToken string `json:"access_token,omitempty"`
1417
}
1518

19+
// GetDefaultAPIURL returns the default API URL, checking environment variables first
20+
func GetDefaultAPIURL() string {
21+
// Check environment variable first
22+
if url := os.Getenv("CODERUN_API_URL"); url != "" {
23+
return url
24+
}
25+
26+
// Return the default URL (may be overridden at build time)
27+
return DefaultAPIURL
28+
}
29+
1630
// GetConfigPath returns the path to the configuration file
1731
func GetConfigPath() (string, error) {
1832
homeDir, err := os.UserHomeDir()
@@ -36,7 +50,7 @@ func LoadConfig() (*Config, error) {
3650
// Return default config if file doesn't exist
3751
if _, err := os.Stat(configPath); os.IsNotExist(err) {
3852
return &Config{
39-
BaseURL: "http://localhost:8000",
53+
BaseURL: GetDefaultAPIURL(),
4054
}, nil
4155
}
4256

main.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ import (
66
"github.com/helmcode/coderun-cli/cmd"
77
)
88

9-
// Build variables injected at compile time
10-
var (
11-
version = "dev"
12-
commit = "none"
13-
date = "unknown"
14-
)
9+
// Build version injected at compile time
10+
var version = "dev"
1511

1612
func main() {
1713
// Pass version information to cmd package
18-
cmd.SetVersionInfo(version, commit, date)
14+
cmd.SetVersionInfo(version)
1915

2016
if err := cmd.Execute(); err != nil {
2117
os.Exit(1)

0 commit comments

Comments
 (0)