-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (229 loc) · 8.01 KB
/
Copy pathbuild-and-release-cli.yaml
File metadata and controls
272 lines (229 loc) · 8.01 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
name: Build and Release CLI
on:
push:
branches: [main]
paths:
- 'apps/cli/**'
tags:
- 'cli/v*'
pull_request:
branches: [main]
paths:
- 'apps/cli/**'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: false
default: ''
env:
GO_VERSION: '1.24'
jobs:
build:
name: Build CLI
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
suffix: linux-amd64
- goos: linux
goarch: arm64
suffix: linux-arm64
- goos: darwin
goarch: amd64
suffix: darwin-amd64
- goos: darwin
goarch: arm64
suffix: darwin-arm64
- goos: windows
goarch: amd64
suffix: windows-amd64
extension: .exe
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: apps/cli/go.sum
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('apps/cli/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get version info
id: version
run: |
cd apps/cli
# Get git commit info
GIT_COMMIT=$(git rev-parse --short HEAD)
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
# Determine version
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.version }}" != "" ]]; then
VERSION="${{ github.event.inputs.version }}"
elif [[ "${{ github.ref }}" == refs/tags/cli/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/cli/}
else
VERSION="${GIT_COMMIT}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "git_commit=${GIT_COMMIT}" >> $GITHUB_OUTPUT
echo "build_time=${BUILD_TIME}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}"
echo "Git commit: ${GIT_COMMIT}"
echo "Build time: ${BUILD_TIME}"
- name: Build binary
run: |
cd apps/cli
BINARY_NAME="asyncstatus${{ matrix.extension }}"
OUTPUT_NAME="asyncstatus-${{ matrix.suffix }}${{ matrix.extension }}"
echo "Building ${OUTPUT_NAME} for ${{ matrix.goos }}/${{ matrix.goarch }}"
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
-ldflags "-s -w -X asyncstatus.com/cli/cmd.Version=${{ steps.version.outputs.version }} -X asyncstatus.com/cli/cmd.BuildTime=${{ steps.version.outputs.build_time }} -X asyncstatus.com/cli/cmd.GitCommit=${{ steps.version.outputs.git_commit }}" \
-o "bin/${OUTPUT_NAME}" \
.
# Verify the binary was created
ls -la bin/
file "bin/${OUTPUT_NAME}" || true
- name: Test binary (Linux only)
if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
run: |
cd apps/cli
chmod +x "bin/asyncstatus-${{ matrix.suffix }}"
./bin/asyncstatus-${{ matrix.suffix }} --version
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: asyncstatus-${{ matrix.suffix }}
path: apps/cli/bin/asyncstatus-${{ matrix.suffix }}${{ matrix.extension }}
retention-days: 7
test:
name: Test CLI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: apps/cli/go.sum
- name: Run tests
run: |
cd apps/cli
go test -v ./...
- name: Run go vet
run: |
cd apps/cli
go vet ./...
- name: Run staticcheck
uses: dominikh/staticcheck-action@v1
with:
working-directory: apps/cli
version: "latest"
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, test]
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/cli/v'))
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version info
id: version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.version }}" != "" ]]; then
VERSION="${{ github.event.inputs.version }}"
TAG_NAME="cli/${VERSION}"
elif [[ "${{ github.ref }}" == refs/tags/cli/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/cli/}
TAG_NAME="cli/${VERSION}"
else
echo "No version found for release"
exit 1
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
echo "Release version: ${VERSION}"
echo "Tag name: ${TAG_NAME}"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: Prepare release assets
run: |
mkdir -p ./release
# Copy and rename artifacts
for artifact_dir in ./artifacts/asyncstatus-*; do
if [ -d "$artifact_dir" ]; then
cp "$artifact_dir"/* ./release/
fi
done
# List what we have
echo "Release assets:"
ls -la ./release/
- name: Generate checksums
run: |
cd ./release
sha256sum * > checksums.txt
echo "Checksums:"
cat checksums.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag_name }}
name: "CLI ${{ steps.version.outputs.version }}"
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
files: |
./release/*
body: |
# AsyncStatus CLI ${{ steps.version.outputs.version }}
## Installation
### Quick Install (Linux/macOS)
```bash
curl -fsSL https://raw.githubusercontent.com/AsyncStatus/asyncstatus/main/apps/cli/install.sh | bash
```
### Manual Installation
1. Download the appropriate binary for your platform
2. Make it executable: `chmod +x asyncstatus-*`
3. Move to your PATH: `mv asyncstatus-* /usr/local/bin/asyncstatus`
### Supported Platforms
- Linux (amd64, arm64)
- macOS (amd64, arm64)
- Windows (amd64)
## Usage
```bash
# Show current status
asyncstatus
# Add status updates
asyncstatus "completed something"
asyncstatus progress "working on something"
asyncstatus blocker "blocked by something"
# View and manage
asyncstatus show
asyncstatus list
asyncstatus undo
```
## Verification
Verify the download using the checksums:
```bash
sha256sum -c checksums.txt
```
## Full Changelog
**Full Changelog**: https://github.com/AsyncStatus/asyncstatus/compare/cli/${{ steps.version.outputs.version }}...cli/${{ steps.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}