Skip to content

Commit dcc10fa

Browse files
authored
Merge pull request #16 from DimmKirr/feature/switch-to-go-app
New Go CLI replacing previous shell-script/compose workflow:
2 parents 9e240ae + d109c87 commit dcc10fa

62 files changed

Lines changed: 4835 additions & 1030 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.dev.yml‎

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
name: Dev Build
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: false
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
- feature/wip
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
packages: write
17+
pages: write
18+
id-token: write
19+
20+
env:
21+
REGISTRY: ghcr.io
22+
IMAGE_NAME: ${{ github.repository }}
23+
24+
jobs:
25+
secrets:
26+
name: Detect Secrets
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- uses: gitleaks/gitleaks-action@v2
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
docker-build:
37+
name: Docker Build (${{ matrix.arch }})
38+
needs: secrets
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
include:
43+
- runner: ubuntu-latest
44+
arch: amd64
45+
platform: linux/amd64
46+
- runner: ubuntu-24.04-arm
47+
arch: arm64
48+
platform: linux/arm64
49+
runs-on: ${{ matrix.runner }}
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Set lowercase image name
54+
run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV
55+
56+
- name: Free disk space
57+
run: |
58+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
59+
sudo docker image prune -af
60+
df -h
61+
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Log in to GitHub Container Registry
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ${{ env.REGISTRY }}
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Build and push ci group
74+
run: docker buildx bake --push ci
75+
env:
76+
VERSION: v0.0.0-${{ matrix.arch }}
77+
PLATFORMS: ${{ matrix.platform }}
78+
REGISTRY: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}
79+
80+
docker-test:
81+
name: Docker Test (${{ matrix.arch }}, ${{ matrix.variant }})
82+
needs: docker-build
83+
strategy:
84+
fail-fast: false
85+
matrix:
86+
include:
87+
- runner: ubuntu-latest
88+
arch: amd64
89+
variant: nix
90+
- runner: ubuntu-24.04-arm
91+
arch: arm64
92+
variant: nix
93+
- runner: ubuntu-latest
94+
arch: amd64
95+
variant: ultimate
96+
- runner: ubuntu-24.04-arm
97+
arch: arm64
98+
variant: ultimate
99+
runs-on: ${{ matrix.runner }}
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: Set lowercase image name
104+
run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV
105+
106+
- name: Log in to GitHub Container Registry
107+
uses: docker/login-action@v3
108+
with:
109+
registry: ${{ env.REGISTRY }}
110+
username: ${{ github.actor }}
111+
password: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Set up Go
114+
uses: actions/setup-go@v5
115+
with:
116+
go-version-file: go.mod
117+
cache-dependency-path: go.sum
118+
119+
- name: Run container tests
120+
env:
121+
DEVCELL_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:v0.0.0-${{ matrix.arch }}-${{ matrix.variant }}
122+
MCP_SECRET_TEST_PASSWORD: fake-secret-ci-value
123+
MCP_SECRET_GITHUB_TOKEN: fake-token-ci-value
124+
run: go test -v -timeout 600s ./test/...
125+
126+
docker-manifest:
127+
name: Docker Manifests
128+
needs: [docker-build]
129+
if: always() && needs.docker-build.result == 'success'
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Set lowercase image name
133+
run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV
134+
env:
135+
IMAGE_NAME: ${{ github.repository }}
136+
137+
- name: Log in to GitHub Container Registry
138+
uses: docker/login-action@v3
139+
with:
140+
registry: ${{ env.REGISTRY }}
141+
username: ${{ github.actor }}
142+
password: ${{ secrets.GITHUB_TOKEN }}
143+
144+
- name: Create manifests
145+
run: |
146+
R=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}
147+
for suffix in "" "-nix" "-ultimate"; do
148+
docker buildx imagetools create \
149+
-t "${R}:dev${suffix}" \
150+
-t "${R}:v0.0.0${suffix}" \
151+
"${R}:v0.0.0-amd64${suffix}" \
152+
"${R}:v0.0.0-arm64${suffix}"
153+
done
154+
155+
cell-build:
156+
name: Cell CLI Dev Build
157+
needs: secrets
158+
runs-on: ubuntu-latest
159+
env:
160+
RELEASE_VERSION: v0.0.0
161+
steps:
162+
- uses: actions/checkout@v4
163+
with:
164+
fetch-depth: 0
165+
166+
- name: Set up Go
167+
uses: actions/setup-go@v5
168+
with:
169+
go-version-file: go.mod
170+
cache-dependency-path: go.sum
171+
172+
- name: Set SHORT_SHA
173+
run: echo "SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
174+
175+
- name: Delete existing tag
176+
run: |
177+
git config --global user.email "dmitry@atd.sh"
178+
git config --global user.name "Dmitry Kireev"
179+
git tag -d "${{ env.RELEASE_VERSION }}" || echo "No local tag to delete"
180+
git push origin :refs/tags/${{ env.RELEASE_VERSION }} || echo "No remote tag to delete"
181+
182+
- name: Add tag
183+
run: |
184+
git tag -a ${{ env.RELEASE_VERSION }} -m "Development release"
185+
git push origin ${{ github.ref_name }}
186+
187+
- name: Run GoReleaser
188+
uses: goreleaser/goreleaser-action@v6
189+
with:
190+
distribution: goreleaser
191+
version: "~> v2"
192+
args: release --clean -f .goreleaser.dev.yaml
193+
env:
194+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
195+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
196+
SHORT_SHA: ${{ env.SHORT_SHA }}
197+
198+
- name: Publish release
199+
env:
200+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
201+
run: gh release edit "${{ env.RELEASE_VERSION }}" --draft=false --latest=false
202+
203+
deploy-site:
204+
name: Deploy Site
205+
needs: secrets
206+
if: github.ref == 'refs/heads/main'
207+
runs-on: ubuntu-latest
208+
environment:
209+
name: github-pages
210+
url: ${{ steps.deployment.outputs.page_url }}
211+
steps:
212+
- uses: actions/checkout@v4
213+
214+
- name: Setup Node
215+
uses: actions/setup-node@v4
216+
with:
217+
node-version: 20
218+
cache: npm
219+
cache-dependency-path: web/package-lock.json
220+
221+
- name: Setup Pages
222+
uses: actions/configure-pages@v5
223+
224+
- name: Install dependencies
225+
run: npm ci
226+
working-directory: web
227+
228+
- name: Build with Astro
229+
run: npm run build
230+
working-directory: web
231+
232+
- name: Upload artifact
233+
uses: actions/upload-pages-artifact@v3
234+
with:
235+
path: ./web/dist
236+
237+
- name: Deploy to GitHub Pages
238+
id: deployment
239+
uses: actions/deploy-pages@v4
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Release Build
2+
3+
concurrency:
4+
group: ${{ github.workflow }}
5+
cancel-in-progress: false
6+
7+
on:
8+
release:
9+
types:
10+
- created
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: write
15+
packages: write
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
IMAGE_NAME: ${{ github.repository }}
20+
21+
jobs:
22+
docker-build:
23+
name: Docker Build (${{ matrix.arch }})
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- runner: ubuntu-latest
29+
arch: amd64
30+
platform: linux/amd64
31+
- runner: ubuntu-24.04-arm
32+
arch: arm64
33+
platform: linux/arm64
34+
runs-on: ${{ matrix.runner }}
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set lowercase image name
39+
run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV
40+
41+
- name: Set VERSION from tag
42+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
43+
44+
- name: Free disk space
45+
run: |
46+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
47+
sudo docker image prune -af
48+
df -h
49+
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Log in to GitHub Container Registry
55+
uses: docker/login-action@v3
56+
with:
57+
registry: ${{ env.REGISTRY }}
58+
username: ${{ github.actor }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Build and push release group
62+
run: docker buildx bake --push release
63+
env:
64+
VERSION: ${{ env.VERSION }}-${{ matrix.arch }}
65+
PLATFORMS: ${{ matrix.platform }}
66+
REGISTRY: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}
67+
68+
docker-manifest:
69+
name: Docker Manifests
70+
needs: docker-build
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Set lowercase image name
74+
run: echo "IMAGE_NAME_LC=${IMAGE_NAME,,}" >> $GITHUB_ENV
75+
env:
76+
IMAGE_NAME: ${{ github.repository }}
77+
78+
- name: Set VERSION from tag
79+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
80+
81+
- name: Log in to GitHub Container Registry
82+
uses: docker/login-action@v3
83+
with:
84+
registry: ${{ env.REGISTRY }}
85+
username: ${{ github.actor }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Create and push multi-arch manifests
89+
run: |
90+
R=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}
91+
V=${{ env.VERSION }}
92+
for suffix in "" "-nix"; do
93+
docker buildx imagetools create -t "${R}:${V}${suffix}" \
94+
"${R}:${V}-amd64${suffix}" \
95+
"${R}:${V}-arm64${suffix}"
96+
done
97+
98+
- name: Inspect manifests
99+
run: |
100+
R=${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}
101+
V=${{ env.VERSION }}
102+
for suffix in "" "-nix"; do
103+
echo "=== ${V}${suffix} ==="
104+
docker buildx imagetools inspect "${R}:${V}${suffix}"
105+
done
106+
107+
cell-release:
108+
name: Cell CLI Release Build
109+
runs-on: ubuntu-latest
110+
steps:
111+
- uses: actions/checkout@v4
112+
with:
113+
fetch-depth: 0
114+
115+
- name: Set up Go
116+
uses: actions/setup-go@v5
117+
with:
118+
go-version-file: go.mod
119+
cache-dependency-path: go.sum
120+
121+
- name: Set env
122+
run: |
123+
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
124+
echo "SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
125+
126+
- name: Run GoReleaser
127+
uses: goreleaser/goreleaser-action@v6
128+
with:
129+
distribution: goreleaser
130+
version: "~> v2"
131+
args: release --clean -f .goreleaser.yaml
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
135+
SHORT_SHA: ${{ env.SHORT_SHA }}
136+
137+
- name: Publish release
138+
env:
139+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
run: gh release edit "${{ env.RELEASE_VERSION }}" --draft=false --latest=false

0 commit comments

Comments
 (0)