-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (235 loc) · 7.7 KB
/
Copy pathrelease.yml
File metadata and controls
273 lines (235 loc) · 7.7 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Configure git for consistent line endings
run: |
git config core.autocrlf false
git config core.eol lf
shell: bash
- name: Run quality checks
run: |
echo "🔍 Running quality checks..."
# Check formatting
gofmt -s -w .
if ! git diff --quiet; then
echo "❌ Code formatting issues found and fixed:"
git diff --name-only
echo ""
echo "Files have been automatically formatted by gofmt"
echo "Please commit these formatting changes before release"
exit 1
fi
echo "✅ Go formatting check passed"
# Run go vet
echo "🔍 Running go vet..."
go vet ./...
echo "✅ go vet passed"
# Run tests
echo "🔍 Running tests..."
go test ./...
echo "✅ Tests passed"
# Build
echo "🔍 Building..."
go build -v ./...
echo "✅ Build successful"
shell: bash
- name: Calculate version
id: version
run: |
# Get current version from tags
CURRENT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Current version: $CURRENT_VERSION"
# Parse current version
if [[ $CURRENT_VERSION =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
else
echo "⚠️ Could not parse current version, starting from v0.1.0"
MAJOR=0
MINOR=1
PATCH=0
fi
# Calculate new version based on input
case "${{ github.event.inputs.release_type }}" in
patch)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
;;
minor)
NEW_MINOR=$((MINOR + 1))
NEW_VERSION="v${MAJOR}.${NEW_MINOR}.0"
;;
major)
NEW_MAJOR=$((MAJOR + 1))
NEW_VERSION="v${NEW_MAJOR}.0.0"
;;
esac
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=$NEW_VERSION" >> $GITHUB_OUTPUT
shell: bash
- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
shell: bash
build:
name: Build and Release
runs-on: ${{ matrix.os }}
needs: [prepare-release]
strategy:
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
artifact: occtx-linux-x86_64
cgo: 0
- os: ubuntu-latest
goos: linux
goarch: arm64
artifact: occtx-linux-aarch64
cgo: 0
- os: windows-latest
goos: windows
goarch: amd64
artifact: occtx-windows-x86_64.exe
- os: macos-latest
goos: darwin
goarch: amd64
artifact: occtx-macos-x86_64
- os: macos-latest
goos: darwin
goarch: arm64
artifact: occtx-macos-aarch64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build release binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: ${{ matrix.cgo == 0 && '0' || '1' }}
run: |
go build -ldflags="-s -w" -o ${{ matrix.artifact }} .
- name: Strip binary (Unix)
if: matrix.os != 'windows-latest' && matrix.cgo != '0'
run: strip ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
release:
name: Create Release
needs: [prepare-release, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare-release.outputs.version }}
files: |
occtx-linux-x86_64/occtx-linux-x86_64
occtx-linux-aarch64/occtx-linux-aarch64
occtx-windows-x86_64.exe/occtx-windows-x86_64.exe
occtx-macos-x86_64/occtx-macos-x86_64
occtx-macos-aarch64/occtx-macos-aarch64
body: |
## occtx ${{ needs.prepare-release.outputs.version }}
Fast, secure, and intuitive command-line tool for managing multiple opencode configurations.
### Installation
Download the appropriate binary for your platform:
- **Linux (x86_64)**: `occtx-linux-x86_64`
- **Linux (ARM64)**: `occtx-linux-aarch64`
- **Windows (x86_64)**: `occtx-windows-x86_64.exe`
- **macOS (Intel)**: `occtx-macos-x86_64`
- **macOS (Apple Silicon)**: `occtx-macos-aarch64`
Make the binary executable and place it in your PATH:
#### Linux and macOS
```bash
chmod +x occtx-*
sudo mv occtx-* /usr/local/bin/occtx
```
#### Windows
1. Right-click on 'This PC' or 'My Computer' and select 'Properties'.
2. Click on 'Advanced system settings'.
3. Click on 'Environment Variables'.
4. Under 'System variables', find the 'Path' variable and click 'Edit'.
5. Click 'New' and add the path to the directory where `occtx.exe` is located.
6. Click 'OK' to close all dialog boxes.
### Usage
```bash
# List contexts
occtx
# Switch to a context
occtx work
# Create new context
occtx -n personal
# Switch to previous context
occtx -
```
See the [README](https://github.com/hungthai1401/occtx) for more details.
draft: false
prerelease: false
trigger-homebrew-update:
name: Trigger Homebrew Tap Update
needs: [prepare-release, release]
runs-on: ubuntu-latest
steps:
- name: Trigger Homebrew Tap Update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: hungthai1401/occtx
event-type: update-homebrew
client-payload: |
{
"version": "${{ needs.prepare-release.outputs.version }}",
"tag": "${{ needs.prepare-release.outputs.tag }}"
}