Skip to content

Commit ad24dab

Browse files
committed
add new ci
1 parent b26d3c4 commit ad24dab

2 files changed

Lines changed: 178 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 178 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,224 @@
11

2-
# .github/workflows/ci.yml
32
name: NextDeploy CI/CD
43

54
on:
65
push:
7-
branches: [ "main" ]
6+
branches: [ "main", "develop" ]
87
tags: [ "v*" ]
98
pull_request:
10-
branches: [ "main" ]
9+
branches: [ "main", "develop" ]
10+
11+
# Environment variables shared across jobs
12+
env:
13+
GO_VERSION: "1.22.x"
14+
CGO_ENABLED: 0
15+
GOFLAGS: "-mod=readonly"
1116

1217
jobs:
13-
build-test:
14-
name: Build & Test
18+
# Quality Assurance First
19+
quality-checks:
20+
name: Code Quality
1521
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
go-version: [ "1.22.x" ]
19-
os: [ ubuntu-latest, macos-latest, windows-latest ]
2022
steps:
2123
- name: Checkout code
2224
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
2327

2428
- name: Setup Go
2529
uses: actions/setup-go@v5
2630
with:
27-
go-version: ${{ matrix.go-version }}
31+
go-version: ${{ env.GO_VERSION }}
2832

2933
- name: Install dependencies
30-
run: go mod tidy
34+
run: go mod download
3135

32-
- name: Lint
33-
run: go vet ./...
36+
- name: Run security audit
37+
run: go mod verify
3438

35-
- name: Run tests
36-
run: go test ./... -v
39+
- name: Run linters
40+
uses: golangci/golangci-lint-action@v3
41+
with:
42+
version: latest
3743

38-
- name: Build CLI (nextdeploy)
44+
- name: Run unit tests with coverage
3945
run: |
40-
go build -o bin/nextdeploy ./cli
46+
go test ./... -v -coverprofile=coverage.out -covermode=atomic
47+
go tool cover -func=coverage.out
48+
49+
- name: Upload coverage report
50+
uses: codecov/codecov-action@v3
51+
with:
52+
file: ./coverage.out
4153

42-
- name: Build Daemon (nextdeployd)
54+
# Build and test across platforms
55+
build-test:
56+
name: Build & Test (${{ matrix.os }})
57+
needs: quality-checks
58+
runs-on: ${{ matrix.os }}
59+
strategy:
60+
matrix:
61+
go-version: [ "${{ env.GO_VERSION }}" ]
62+
os: [ ubuntu-latest, macos-latest, windows-latest ]
63+
include:
64+
- os: ubuntu-latest
65+
platform: linux
66+
suffix: ""
67+
- os: macos-latest
68+
platform: darwin
69+
suffix: ""
70+
- os: windows-latest
71+
platform: windows
72+
suffix: ".exe"
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
77+
- name: Setup Go
78+
uses: actions/setup-go@v5
79+
with:
80+
go-version: ${{ matrix.go-version }}
81+
cache: true
82+
cache-dependency-path: go.sum
83+
84+
- name: Build binaries
85+
run: |
86+
mkdir -p bin
87+
# Build CLI
88+
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" \
89+
-o bin/nextdeploy${{ matrix.suffix }} ./cli
90+
91+
# Build Daemon
92+
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" \
93+
-o bin/nextdeployd${{ matrix.suffix }} ./daemon
94+
95+
# Generate checksums
96+
cd bin && sha256sum * > checksums.txt
97+
98+
- name: Run integration tests
4399
run: |
44-
go build -o bin/nextdeployd ./daemon
100+
# Add platform-specific test commands if needed
101+
go test ./... -tags=integration -v
45102
46-
- name: Upload Artifacts
103+
- name: Upload build artifacts
47104
uses: actions/upload-artifact@v4
48105
with:
49-
name: nextdeploy-${{ matrix.os }}
50-
path: bin/
106+
name: binaries-${{ matrix.platform }}-${{ github.sha }}
107+
path: |
108+
bin/*
109+
!bin/*.txt
110+
retention-days: 7
51111

112+
- name: Upload checksums
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: checksums-${{ matrix.platform }}
116+
path: bin/checksums.txt
117+
retention-days: 7
118+
119+
# Release with extended platform support
52120
release:
53-
name: Release Binaries
121+
name: Create Release
54122
needs: build-test
55123
runs-on: ubuntu-latest
56124
if: startsWith(github.ref, 'refs/tags/v')
125+
57126
steps:
58127
- name: Checkout code
59128
uses: actions/checkout@v4
129+
with:
130+
fetch-depth: 0
60131

61132
- name: Setup Go
62133
uses: actions/setup-go@v5
63134
with:
64-
go-version: "1.22.x"
135+
go-version: ${{ env.GO_VERSION }}
65136

66-
- name: Build release binaries
67-
run: |
68-
mkdir -p dist
69-
GOOS=linux GOARCH=amd64 go build -o dist/nextdeploy-linux-amd64 ./cli
70-
GOOS=linux GOARCH=amd64 go build -o dist/nextdeployd-linux-amd64 ./daemon
71-
72-
GOOS=darwin GOARCH=amd64 go build -o dist/nextdeploy-darwin-amd64 ./cli
73-
GOOS=darwin GOARCH=amd64 go build -o dist/nextdeployd-darwin-amd64 ./daemon
74-
75-
GOOS=windows GOARCH=amd64 go build -o dist/nextdeploy-windows-amd64.exe ./cli
76-
GOOS=windows GOARCH=amd64 go build -o dist/nextdeployd-windows-amd64.exe ./daemon
137+
- name: Download all artifacts
138+
uses: actions/download-artifact@v4
139+
with:
140+
path: dist/
141+
pattern: binaries-*
142+
merge-multiple: true
77143

78-
- name: Upload Release Assets
144+
- name: Build multi-architecture binaries
145+
run: |
146+
mkdir -p release-binaries
147+
148+
# Build for additional architectures
149+
platforms=(
150+
"linux amd64"
151+
"linux arm64"
152+
"darwin amd64"
153+
"darwin arm64"
154+
"windows amd64"
155+
"windows arm64"
156+
)
157+
158+
for platform in "${platforms[@]}"; do
159+
read -r goos goarch <<< "$platform"
160+
suffix=""
161+
if [ "$goos" = "windows" ]; then
162+
suffix=".exe"
163+
fi
164+
165+
echo "Building for $goos/$goarch..."
166+
167+
# Build CLI
168+
GOOS=$goos GOARCH=$goarch go build \
169+
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
170+
-o release-binaries/nextdeploy-$goos-$goarch$suffix ./cli
171+
172+
# Build Daemon
173+
GOOS=$goos GOARCH=$goarch go build \
174+
-ldflags="-s -w -X main.version=${{ github.ref_name }}" \
175+
-o release-binaries/nextdeployd-$goos-$goarch$suffix ./daemon
176+
done
177+
178+
# Generate comprehensive checksums
179+
cd release-binaries && sha256sum * > checksums.txt
180+
181+
- name: Create GitHub Release
79182
uses: softprops/action-gh-release@v2
80183
with:
81-
files: dist/*
184+
files: |
185+
release-binaries/*
186+
dist/**/*
187+
body: |
188+
## NextDeploy ${{ github.ref_name }}
189+
190+
### Changes
191+
${{ github.event.head_commit.message }}
192+
193+
### Binaries
194+
Built for multiple platforms and architectures.
195+
196+
### Verification
197+
Verify downloads with:
198+
```bash
199+
sha256sum -c checksums.txt
200+
```
201+
draft: false
202+
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') }}
82203
env:
83204
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
205+
206+
# Notify on success
207+
notify:
208+
name: Notify Success
209+
needs: release
210+
runs-on: ubuntu-latest
211+
if: always()
212+
steps:
213+
- name: Send notification
214+
uses: actions/github-script@v7
215+
with:
216+
script: |
217+
const { data: release } = await github.rest.repos.getReleaseByTag({
218+
owner: context.repo.owner,
219+
repo: context.repo.repo,
220+
tag: context.ref.replace('refs/tags/', '')
221+
});
222+
223+
// Send to Slack/Discord/Teams here
224+
console.log(`Release created: ${release.html_url}`);

install-nextdeployd.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)