Skip to content

Commit 7b4977a

Browse files
committed
initial commit
0 parents  commit 7b4977a

Some content is hidden

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

72 files changed

+10346
-0
lines changed

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
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: Setup Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.24'
21+
cache: true
22+
23+
- name: Download dependencies
24+
run: go mod download
25+
26+
- name: Run tests
27+
run: go test -v -race -coverprofile=coverage.out ./...
28+
29+
- name: Upload coverage
30+
uses: codecov/codecov-action@v4
31+
with:
32+
files: coverage.out
33+
fail_ci_if_error: false
34+
35+
lint:
36+
name: Lint
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.24'
46+
cache: true
47+
48+
- name: Run golangci-lint
49+
uses: golangci/golangci-lint-action@v6
50+
with:
51+
version: latest
52+
args: --timeout=5m
53+
54+
build:
55+
name: Build
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
goos: [darwin, linux]
60+
goarch: [amd64, arm64]
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v4
64+
65+
- name: Setup Go
66+
uses: actions/setup-go@v5
67+
with:
68+
go-version: '1.24'
69+
cache: true
70+
71+
- name: Build
72+
env:
73+
GOOS: ${{ matrix.goos }}
74+
GOARCH: ${{ matrix.goarch }}
75+
run: go build -o devstrap_${{ matrix.goos }}_${{ matrix.goarch }} .

.github/workflows/release.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
goos: [darwin, linux]
18+
goarch: [amd64, arm64]
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: '1.24'
29+
cache: true
30+
31+
- name: Get version
32+
id: version
33+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
34+
35+
- name: Build binary
36+
env:
37+
GOOS: ${{ matrix.goos }}
38+
GOARCH: ${{ matrix.goarch }}
39+
CGO_ENABLED: 0
40+
run: |
41+
VERSION=${{ steps.version.outputs.VERSION }}
42+
COMMIT=$(git rev-parse --short HEAD)
43+
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
44+
go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.buildDate=${BUILD_DATE}" \
45+
-o devstrap_${{ matrix.goos }}_${{ matrix.goarch }} .
46+
47+
- name: Create tarball
48+
run: |
49+
VERSION=${{ steps.version.outputs.VERSION }}
50+
ARCHIVE=devstrap_${VERSION#v}_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
51+
tar -czf ${ARCHIVE} devstrap_${{ matrix.goos }}_${{ matrix.goarch }}
52+
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: devstrap_${{ matrix.goos }}_${{ matrix.goarch }}
58+
path: devstrap_*.tar.gz
59+
60+
release:
61+
name: Release
62+
needs: build
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Download all artifacts
69+
uses: actions/download-artifact@v4
70+
with:
71+
path: artifacts
72+
merge-multiple: true
73+
74+
- name: List artifacts
75+
run: ls -la artifacts/
76+
77+
- name: Generate checksums
78+
run: |
79+
cd artifacts
80+
shasum -a 256 *.tar.gz > checksums.txt
81+
cat checksums.txt
82+
83+
- name: Get version
84+
id: version
85+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
86+
87+
- name: Generate Homebrew formula
88+
run: |
89+
VERSION=${{ steps.version.outputs.VERSION }}
90+
VERSION_NUM=${VERSION#v}
91+
92+
# Get checksums
93+
DARWIN_AMD64_SHA=$(grep darwin_amd64 artifacts/checksums.txt | awk '{print $1}')
94+
DARWIN_ARM64_SHA=$(grep darwin_arm64 artifacts/checksums.txt | awk '{print $1}')
95+
LINUX_AMD64_SHA=$(grep linux_amd64 artifacts/checksums.txt | awk '{print $1}')
96+
LINUX_ARM64_SHA=$(grep linux_arm64 artifacts/checksums.txt | awk '{print $1}')
97+
98+
cat > artifacts/devstrap.rb << EOF
99+
# Homebrew formula for devstrap
100+
# Generated automatically by GitHub Actions
101+
102+
class Devstrap < Formula
103+
desc "Developer environment automation tool"
104+
homepage "https://github.com/codoworks/devstrap"
105+
version "${VERSION_NUM}"
106+
license "MIT"
107+
108+
on_macos do
109+
if Hardware::CPU.arm?
110+
url "https://github.com/codoworks/devstrap/releases/download/${VERSION}/devstrap_${VERSION_NUM}_darwin_arm64.tar.gz"
111+
sha256 "${DARWIN_ARM64_SHA}"
112+
else
113+
url "https://github.com/codoworks/devstrap/releases/download/${VERSION}/devstrap_${VERSION_NUM}_darwin_amd64.tar.gz"
114+
sha256 "${DARWIN_AMD64_SHA}"
115+
end
116+
end
117+
118+
on_linux do
119+
if Hardware::CPU.arm?
120+
url "https://github.com/codoworks/devstrap/releases/download/${VERSION}/devstrap_${VERSION_NUM}_linux_arm64.tar.gz"
121+
sha256 "${LINUX_ARM64_SHA}"
122+
else
123+
url "https://github.com/codoworks/devstrap/releases/download/${VERSION}/devstrap_${VERSION_NUM}_linux_amd64.tar.gz"
124+
sha256 "${LINUX_AMD64_SHA}"
125+
end
126+
end
127+
128+
def install
129+
bin.install "devstrap_#{OS.kernel_name.downcase}_#{Hardware::CPU.arch}" => "devstrap"
130+
end
131+
132+
test do
133+
system "#{bin}/devstrap", "--help"
134+
end
135+
end
136+
EOF
137+
138+
echo "Generated Homebrew formula:"
139+
cat artifacts/devstrap.rb
140+
141+
- name: Create Release
142+
uses: softprops/action-gh-release@v2
143+
with:
144+
files: |
145+
artifacts/*.tar.gz
146+
artifacts/checksums.txt
147+
artifacts/devstrap.rb
148+
generate_release_notes: true
149+
draft: false
150+
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
151+
env:
152+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Go build artifacts
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
bin/
8+
9+
# Test artifacts
10+
*.test
11+
*.out
12+
coverage.html
13+
coverage.txt
14+
15+
# Dependency directories
16+
vendor/
17+
18+
# IDE and editor files
19+
.idea/
20+
*.swp
21+
*.swo
22+
*~
23+
.vscode/
24+
25+
# OS-specific files
26+
.DS_Store
27+
.DS_Store?
28+
Thumbs.db
29+
30+
# Environment and secrets
31+
.env
32+
.env.*
33+
*.pem
34+
credentials.json
35+
36+
# Debug files
37+
debug
38+
*.log
39+
40+
# Copilot files
41+
.copilot/
42+
.claude/

0 commit comments

Comments
 (0)