Skip to content

Commit f38efab

Browse files
committed
bugfix
bugfix
0 parents  commit f38efab

74 files changed

Lines changed: 18796 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.19'
21+
22+
- name: Get dependencies
23+
run: go mod download
24+
25+
- name: Run tests
26+
run: go test -v -cover ./...
27+
28+
- name: Run linter
29+
uses: golangci/golangci-lint-action@v3
30+
with:
31+
version: latest
32+
33+
build:
34+
name: Build
35+
runs-on: ubuntu-latest
36+
needs: test
37+
strategy:
38+
matrix:
39+
goos: [linux, darwin, windows]
40+
goarch: [amd64, arm64]
41+
exclude:
42+
- goos: windows
43+
goarch: arm64
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Set up Go
49+
uses: actions/setup-go@v5
50+
with:
51+
go-version: '1.19'
52+
53+
- name: Build
54+
env:
55+
GOOS: ${{ matrix.goos }}
56+
GOARCH: ${{ matrix.goarch }}
57+
CGO_ENABLED: 0
58+
run: |
59+
VERSION=${GITHUB_REF_NAME:-dev}
60+
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
61+
COMMIT_HASH=${GITHUB_SHA::7}
62+
63+
OUTPUT_NAME="cmd4coder-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}"
64+
if [ "${{ matrix.goos }}" = "windows" ]; then
65+
OUTPUT_NAME="${OUTPUT_NAME}.exe"
66+
fi
67+
68+
go build \
69+
-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.CommitHash=${COMMIT_HASH}'" \
70+
-trimpath \
71+
-o "${OUTPUT_NAME}" \
72+
./cmd/cli
73+
74+
echo "Built: ${OUTPUT_NAME}"
75+
ls -lh "${OUTPUT_NAME}"
76+
77+
- name: Upload artifact
78+
uses: actions/upload-artifact@v3
79+
with:
80+
name: cmd4coder-${{ matrix.goos }}-${{ matrix.goarch }}
81+
path: cmd4coder-*

.github/workflows/release.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
outputs:
16+
upload_url: ${{ steps.create_release.outputs.upload_url }}
17+
version: ${{ steps.get_version.outputs.version }}
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Get version
25+
id: get_version
26+
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
27+
28+
- name: Generate changelog
29+
id: changelog
30+
run: |
31+
echo "# Release ${GITHUB_REF#refs/tags/}" > RELEASE_NOTES.md
32+
echo "" >> RELEASE_NOTES.md
33+
echo "## Changes" >> RELEASE_NOTES.md
34+
git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:"- %s" >> RELEASE_NOTES.md || echo "- Initial release" >> RELEASE_NOTES.md
35+
36+
- name: Create Release
37+
id: create_release
38+
uses: actions/create-release@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
tag_name: ${{ github.ref }}
43+
release_name: cmd4coder ${{ steps.get_version.outputs.version }}
44+
body_path: RELEASE_NOTES.md
45+
draft: false
46+
prerelease: false
47+
48+
build-and-upload:
49+
name: Build and Upload Assets
50+
needs: release
51+
runs-on: ubuntu-latest
52+
strategy:
53+
matrix:
54+
include:
55+
- goos: linux
56+
goarch: amd64
57+
- goos: linux
58+
goarch: arm64
59+
- goos: darwin
60+
goarch: amd64
61+
- goos: darwin
62+
goarch: arm64
63+
- goos: windows
64+
goarch: amd64
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Set up Go
70+
uses: actions/setup-go@v5
71+
with:
72+
go-version: '1.19'
73+
74+
- name: Build
75+
env:
76+
GOOS: ${{ matrix.goos }}
77+
GOARCH: ${{ matrix.goarch }}
78+
CGO_ENABLED: 0
79+
run: |
80+
VERSION=${{ needs.release.outputs.version }}
81+
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
82+
COMMIT_HASH=${GITHUB_SHA::7}
83+
84+
OUTPUT_NAME="cmd4coder-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}"
85+
if [ "${{ matrix.goos }}" = "windows" ]; then
86+
OUTPUT_NAME="${OUTPUT_NAME}.exe"
87+
fi
88+
89+
go build \
90+
-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.CommitHash=${COMMIT_HASH}'" \
91+
-trimpath \
92+
-o "${OUTPUT_NAME}" \
93+
./cmd/cli
94+
95+
# Create archive
96+
if [ "${{ matrix.goos }}" = "windows" ]; then
97+
ARCHIVE_NAME="cmd4coder-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip"
98+
zip "${ARCHIVE_NAME}" "${OUTPUT_NAME}"
99+
else
100+
ARCHIVE_NAME="cmd4coder-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz"
101+
tar -czf "${ARCHIVE_NAME}" "${OUTPUT_NAME}"
102+
fi
103+
104+
# Calculate checksums
105+
sha256sum "${ARCHIVE_NAME}" > "${ARCHIVE_NAME}.sha256"
106+
107+
echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV
108+
echo "Built and packaged: ${ARCHIVE_NAME}"
109+
110+
- name: Upload Release Asset
111+
uses: actions/upload-release-asset@v1
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
upload_url: ${{ needs.release.outputs.upload_url }}
116+
asset_path: ./${{ env.ARCHIVE_NAME }}
117+
asset_name: ${{ env.ARCHIVE_NAME }}
118+
asset_content_type: application/octet-stream
119+
120+
- name: Upload Checksum
121+
uses: actions/upload-release-asset@v1
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
upload_url: ${{ needs.release.outputs.upload_url }}
126+
asset_path: ./${{ env.ARCHIVE_NAME }}.sha256
127+
asset_name: ${{ env.ARCHIVE_NAME }}.sha256
128+
asset_content_type: text/plain

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool
12+
*.out
13+
coverage.html
14+
coverage.txt
15+
16+
# Dependency directories
17+
vendor/
18+
19+
# Go workspace file
20+
go.work
21+
22+
# Build output
23+
bin/
24+
dist/
25+
build/
26+
27+
# IDE
28+
.idea/
29+
.vscode/
30+
*.swp
31+
*.swo
32+
*~
33+
34+
# OS
35+
.DS_Store
36+
Thumbs.db
37+
38+
# User data
39+
.cmd4coder/
40+
41+
# Test reports
42+
test-reports/
43+
*.log

0 commit comments

Comments
 (0)