@@ -10,19 +10,22 @@ permissions:
1010 contents : write
1111
1212jobs :
13- build :
14- name : Build simple-container in branch
13+ build-setup :
14+ name : Build Setup (clean, tools, schemas, lint, fmt)
1515 runs-on : blacksmith-8vcpu-ubuntu-2204
1616 outputs :
17- cicd-bot-telegram-token : ${{ steps.prepare -secrets.outputs.cicd-bot-telegram-token }}
18- cicd-bot-telegram-chat-id : ${{ steps.prepare -secrets.outputs.cicd-bot-telegram-chat-id }}
17+ cicd-bot-telegram-token : ${{ steps.telegram -secrets.outputs.cicd-bot-telegram-token }}
18+ cicd-bot-telegram-chat-id : ${{ steps.telegram -secrets.outputs.cicd-bot-telegram-chat-id }}
1919 steps :
2020 - uses : actions/checkout@v4
2121 - uses : fregante/setup-git-user@v2
22+ - name : Set up Go with Blacksmith caching
23+ uses : useblacksmith/setup-go@v6
24+ with :
25+ go-version : ' 1.25'
2226 - name : install sc tool (latest release)
2327 shell : bash
2428 run : |-
25- # Install latest SC release to get secrets for embeddings generation
2629 curl -s "https://dist.simple-container.com/sc.sh" | bash
2730 - name : prepare secrets for build
2831 run : |
@@ -41,18 +44,157 @@ jobs:
4144 shell : bash
4245 env :
4346 OPENAI_API_KEY : ${{ steps.get-openai-key.outputs.openai-key }}
47+ SKIP_EMBEDDINGS : " true"
4448 run : |-
4549 git remote set-url origin https://${{ secrets.GITHUB_TOKEN }}@github.com/simple-container-com/api.git
4650 bash <(curl -Ls "https://welder.simple-container.com/welder.sh") run rebuild
47- - name : prepare additional secrets
48- id : prepare-secrets
51+ - name : clean
4952 run : |
50- echo "cicd-bot-telegram-token=$(${{ github.workspace }}/bin/sc stack secret-get -s dist cicd-bot-telegram-token)" >> $GITHUB_OUTPUT
51- echo "cicd-bot-telegram-chat-id=$(${{ github.workspace }}/bin/sc stack secret-get -s dist cicd-bot-telegram-chat-id)" >> $GITHUB_OUTPUT
52- - name : build sc tool
53- shell : bash
54- run : |-
55- bash <(curl -Ls "https://welder.simple-container.com/welder.sh") make --timestamps
53+ mkdir -p dist
54+ rm -fR dist/*
55+ mkdir -p .sc/stacks/dist/bundle
56+ rm -fR .sc/stacks/dist/bundle/*
57+ mkdir -p docs/site
58+ rm -fR docs/site/*
59+ mkdir -p docs/schemas
60+ rm -fR docs/schemas/*
61+ - name : tools
62+ run : |
63+ cat tools.go | grep _ | awk -F'"' '{print $2}' | xargs -tI % go get %
64+ go mod download
65+ go generate -tags tools
66+ go mod tidy
67+ - name : generate-schemas
68+ run : |
69+ echo "Generating JSON Schema files for Simple Container resources..."
70+ go build -o bin/schema-gen ./cmd/schema-gen
71+ bin/schema-gen docs/schemas
72+ echo "Successfully generated JSON Schema files in docs/schemas/"
73+ - name : fmt
74+ run : |
75+ go mod tidy
76+ bin/gofumpt -l -w ./
77+ bin/golangci-lint run --fix --timeout 3m -v
78+ - name : get telegram secrets
79+ id : telegram-secrets
80+ run : |
81+ echo "cicd-bot-telegram-token=$(./bin/sc stack secret-get -s dist cicd-bot-telegram-token)" >> $GITHUB_OUTPUT
82+ echo "cicd-bot-telegram-chat-id=$(./bin/sc stack secret-get -s dist cicd-bot-telegram-chat-id)" >> $GITHUB_OUTPUT
83+ - name : upload bin directory artifacts
84+ uses : actions/upload-artifact@v4
85+ with :
86+ name : bin-tools
87+ path : bin
88+ retention-days : 1
89+
90+ build-platforms :
91+ name : Build sc for ${{ matrix.os }}/${{ matrix.arch }}
92+ runs-on : blacksmith-8vcpu-ubuntu-2204
93+ needs : build-setup
94+ strategy :
95+ matrix :
96+ include :
97+ - os : linux
98+ arch : amd64
99+ - os : darwin
100+ arch : arm64
101+ - os : darwin
102+ arch : amd64
103+ steps :
104+ - uses : actions/checkout@v4
105+ - name : Set up Go with Blacksmith caching
106+ uses : useblacksmith/setup-go@v6
107+ with :
108+ go-version : ' 1.25'
109+ - name : create build directories
110+ run : |
111+ mkdir -p dist
112+ mkdir -p .sc/stacks/dist/bundle
113+ - name : build sc for ${{ matrix.os }}/${{ matrix.arch }}
114+ env :
115+ GOOS : ${{ matrix.os }}
116+ GOARCH : ${{ matrix.arch }}
117+ CGO_ENABLED : " 0"
118+ run : |
119+ echo "Building for ${GOOS}/${GOARCH}..."
120+ if [ "${GOOS}" = "windows" ]; then export EXT=".exe"; else export EXT=""; fi
121+ go build -ldflags "-s -w" -o dist/${GOOS}-${GOARCH}/sc${EXT} ./cmd/sc
122+ tar -czf .sc/stacks/dist/bundle/sc-${GOOS}-${GOARCH}.tar.gz -C dist/${GOOS}-${GOARCH} sc${EXT}
123+ - name : upload build artifacts
124+ uses : actions/upload-artifact@v4
125+ with :
126+ name : sc-${{ matrix.os }}-${{ matrix.arch }}
127+ path : .sc/stacks/dist/bundle/sc-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
128+ retention-days : 1
129+
130+ build-binaries :
131+ name : Build ${{ matrix.target }}
132+ runs-on : blacksmith-8vcpu-ubuntu-2204
133+ needs : build-setup
134+ strategy :
135+ matrix :
136+ include :
137+ - target : github-actions
138+ cmd : github-actions
139+ output : dist/github-actions
140+ - target : cloud-helpers
141+ cmd : cloud-helpers
142+ output : dist/cloud-helpers
143+ steps :
144+ - uses : actions/checkout@v4
145+ - name : Set up Go with Blacksmith caching
146+ uses : useblacksmith/setup-go@v6
147+ with :
148+ go-version : ' 1.25'
149+ - name : create build directories
150+ run : |
151+ mkdir -p dist
152+ - name : build ${{ matrix.target }}
153+ env :
154+ CGO_ENABLED : " 0"
155+ run : |
156+ go build -a -installsuffix cgo -ldflags "-s -w" -o ${{ matrix.output }} ./cmd/${{ matrix.cmd }}
157+ - name : upload ${{ matrix.target }} binary
158+ uses : actions/upload-artifact@v4
159+ with :
160+ name : ${{ matrix.target }}-binary
161+ path : ${{ matrix.output }}
162+ retention-days : 1
163+
164+ build-github-actions-staging :
165+ name : Build github-actions-staging
166+ runs-on : blacksmith-8vcpu-ubuntu-2204
167+ needs : build-setup
168+ steps :
169+ - uses : actions/checkout@v4
170+ - name : Set up Go with Blacksmith caching
171+ uses : useblacksmith/setup-go@v6
172+ with :
173+ go-version : ' 1.25'
174+ - name : build github-actions-staging
175+ run : |
176+ mkdir -p bin
177+ go build -ldflags "-s -w" -a -installsuffix cgo -o bin/github-actions ./cmd/github-actions
178+ - name : upload github-actions-staging binary
179+ uses : actions/upload-artifact@v4
180+ with :
181+ name : github-actions-staging-binary
182+ path : bin/github-actions
183+ retention-days : 1
184+
185+ test :
186+ name : Run tests
187+ runs-on : blacksmith-8vcpu-ubuntu-2204
188+ needs : build-setup
189+ steps :
190+ - uses : actions/checkout@v4
191+ - name : Set up Go with Blacksmith caching
192+ uses : useblacksmith/setup-go@v6
193+ with :
194+ go-version : ' 1.25'
195+ - name : test
196+ run : |
197+ go test ./...
56198
57199 finalize :
58200 name : Finalize build in branch
@@ -61,7 +203,11 @@ jobs:
61203 permissions :
62204 contents : write
63205 needs :
64- - build
206+ - build-setup
207+ - build-platforms
208+ - build-binaries
209+ - build-github-actions-staging
210+ - test
65211 steps :
66212 - uses : actions/checkout@v4
67213 if : ${{ always() }}
@@ -85,15 +231,15 @@ jobs:
85231 if : ${{ success() && !contains(needs.*.result, 'failure') }}
86232 continue-on-error : true
87233 with :
88- chat : ${{ needs.build.outputs.cicd-bot-telegram-chat-id }}
89- token : ${{ needs.build.outputs.cicd-bot-telegram-token }}
234+ chat : ${{ needs.build-setup .outputs.cicd-bot-telegram-chat-id }}
235+ token : ${{ needs.build-setup .outputs.cicd-bot-telegram-token }}
90236 status : ✅ success (${{ steps.extract_git_ref.outputs.branch }}) - ${{ steps.extract_git_ref.outputs.message }} by ${{ steps.extract_git_ref.outputs.author }}
91237 - uses : yanzay/notify-telegram@v0.1.0
92238 if : ${{ failure() || contains(needs.*.result, 'failure') }}
93239 continue-on-error : true
94240 with :
95- chat : ${{ needs.build.outputs.cicd-bot-telegram-chat-id }}
96- token : ${{ needs.build.outputs.cicd-bot-telegram-token }}
241+ chat : ${{ needs.build-setup .outputs.cicd-bot-telegram-chat-id }}
242+ token : ${{ needs.build-setup .outputs.cicd-bot-telegram-token }}
97243 status : ❗ failure (${{ steps.extract_git_ref.outputs.branch }}) - ${{ steps.extract_git_ref.outputs.message }} by ${{ steps.extract_git_ref.outputs.author }}
98244
99245 - name : Build failed due to previously failed steps
0 commit comments