aicommit 0.1.141

A CLI tool that generates concise and descriptive git commit messages using LLMs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write
  packages: write

jobs:
  build-and-release:
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
    steps:
      - name: Create Release
        id: create_release
        uses: softprops/action-gh-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false

  build-linux-x86:
    needs: build-and-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: x86_64-unknown-linux-gnu
          override: true
      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: linux-x86_64-cargo-${{ hashFiles('**/Cargo.lock') }}
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target x86_64-unknown-linux-gnu
      - name: Prepare binary
        run: |
          mkdir -p dist
          cp ./target/x86_64-unknown-linux-gnu/release/aicommit ./dist/aicommit-linux-x86_64
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist/aicommit-linux-x86_64
          if-no-files-found: error
      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.build-and-release.outputs.upload_url }}
          asset_path: ./dist/aicommit-linux-x86_64
          asset_name: aicommit-linux-x86_64
          asset_content_type: application/octet-stream

  build-macos-x86:
    needs: build-and-release
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: x86_64-apple-darwin
          override: true
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target x86_64-apple-darwin
      - name: Prepare binary
        run: |
          mkdir -p dist
          cp ./target/x86_64-apple-darwin/release/aicommit ./dist/aicommit-macos-x86_64
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: binaries-macos-x86_64-${{ github.ref_name }}
          path: ./dist/aicommit-macos-x86_64
          if-no-files-found: error
      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.build-and-release.outputs.upload_url }}
          asset_path: ./dist/aicommit-macos-x86_64
          asset_name: aicommit-macos-x86_64
          asset_content_type: application/octet-stream

  build-macos-arm:
    needs: build-and-release
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: aarch64-apple-darwin
          override: true
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target aarch64-apple-darwin
      - name: Prepare binary
        run: |
          mkdir -p dist
          cp ./target/aarch64-apple-darwin/release/aicommit ./dist/aicommit-macos-aarch64
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: binaries-macos-aarch64-${{ github.ref_name }}
          path: ./dist/aicommit-macos-aarch64
          if-no-files-found: error
      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.build-and-release.outputs.upload_url }}
          asset_path: ./dist/aicommit-macos-aarch64
          asset_name: aicommit-macos-aarch64
          asset_content_type: application/octet-stream

  build-windows-x86:
    needs: build-and-release
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: x86_64-pc-windows-msvc
          override: true
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target x86_64-pc-windows-msvc
      - name: Prepare binary
        run: |
          mkdir -p dist
          cp ./target/x86_64-pc-windows-msvc/release/aicommit.exe ./dist/aicommit-windows-x86_64.exe
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: binaries-windows-x86_64-${{ github.ref_name }}
          path: ./dist/aicommit-windows-x86_64.exe
          if-no-files-found: error
      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.build-and-release.outputs.upload_url }}
          asset_path: ./dist/aicommit-windows-x86_64.exe
          asset_name: aicommit-windows-x86_64.exe
          asset_content_type: application/octet-stream

  build-windows-arm:
    needs: build-and-release
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          target: aarch64-pc-windows-msvc
          override: true
      - name: Build
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --target aarch64-pc-windows-msvc
      - name: Prepare binary
        run: |
          mkdir -p dist
          cp ./target/aarch64-pc-windows-msvc/release/aicommit.exe ./dist/aicommit-windows-aarch64.exe
      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: binaries-windows-aarch64-${{ github.ref_name }}
          path: ./dist/aicommit-windows-aarch64.exe
          if-no-files-found: error
      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.build-and-release.outputs.upload_url }}
          asset_path: ./dist/aicommit-windows-aarch64.exe
          asset_name: aicommit-windows-aarch64.exe
          asset_content_type: application/octet-stream

  publish-crates:
    needs: build-and-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          override: true
      - name: Publish to crates.io
        uses: actions-rs/cargo@v1
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        with:
          command: publish
          args: --allow-dirty

  publish-npm:
    needs: [build-linux-x86, build-macos-x86, build-macos-arm, build-windows-x86, build-windows-arm]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          pattern: binaries-*-${{ github.ref_name }}
          path: bin
          merge-multiple: true
      - name: Show binary files
        run: |
          echo "Binary files in bin/:"
          ls -la bin/
          # Проверяем наличие всех необходимых бинарников
          for file in aicommit-linux-x86_64 aicommit-macos-x86_64 aicommit-macos-aarch64 aicommit-windows-x86_64.exe aicommit-windows-aarch64.exe; do
            if [ ! -f "bin/$file" ]; then
              echo "Error: Missing binary: $file"
              exit 1
            fi
          done
          file bin/* || true
          chmod +x bin/aicommit-*
      - name: Rename binaries for npm
        run: |
          mkdir -p bin/linux-x64
          mkdir -p bin/darwin-x64
          mkdir -p bin/darwin-arm64
          mkdir -p bin/win32-x64
          mkdir -p bin/win32-arm64
          
          mv bin/aicommit-linux-x86_64 bin/linux-x64/aicommit
          mv bin/aicommit-macos-x86_64 bin/darwin-x64/aicommit
          mv bin/aicommit-macos-aarch64 bin/darwin-arm64/aicommit
          mv bin/aicommit-windows-x86_64.exe bin/win32-x64/aicommit.exe
          mv bin/aicommit-windows-aarch64.exe bin/win32-arm64/aicommit.exe
          
          chmod +x bin/**/aicommit*
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20.x'
          registry-url: 'https://registry.npmjs.org'
      - name: Publish to npm
        run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

  publish-homebrew:
    needs: [build-macos-x86, build-macos-arm]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout tap repo
        uses: actions/checkout@v4
        with:
          repository: suenot/homebrew-tap
          path: homebrew-tap
          token: ${{ secrets.GH_TOKEN }}
      
      - name: Download macOS binaries
        uses: actions/download-artifact@v4
        with:
          pattern: binaries-macos-*
          path: dist/
          merge-multiple: true

      - name: Calculate SHA256
        id: sha-calc
        run: |
          echo "sha256_x86=$(sha256sum dist/aicommit-macos-x86_64 | awk '{ print $1 }')" >> $GITHUB_OUTPUT
          echo "sha256_arm=$(sha256sum dist/aicommit-macos-aarch64 | awk '{ print $1 }')" >> $GITHUB_OUTPUT

      - name: Update formula
        env:
          VERSION: ${{ github.ref_name }}
          SHA256_X86: ${{ steps.sha-calc.outputs.sha256_x86 }}
          SHA256_ARM: ${{ steps.sha-calc.outputs.sha256_arm }}
        run: |
          cat > homebrew-tap/Formula/aicommit.rb <<EOL
          class Aicommit < Formula
            desc "AI-powered commit message generator"
            homepage "https://github.com/suenot/aicommit"
            version "${VERSION}"
            license "MIT"

            on_macos do
              on_arm do
                url "https://github.com/suenot/aicommit/releases/download/${VERSION}/aicommit-macos-aarch64"
                sha256 "${SHA256_ARM}"

                def install
                  bin.install "aicommit-macos-aarch64" => "aicommit"
                end
              end

              on_intel do
                url "https://github.com/suenot/aicommit/releases/download/${VERSION}/aicommit-macos-x86_64"
                sha256 "${SHA256_X86}"

                def install
                  bin.install "aicommit-macos-x86_64" => "aicommit"
                end
              end
            end
          end
          EOL

      - name: Debug formula
        run: |
          echo "Generated formula:"
          cat homebrew-tap/Formula/aicommit.rb
          echo "Files in dist:"
          ls -la dist/

      - name: Commit and push
        run: |
          cd homebrew-tap
          git config user.name "GitHub Actions"
          git config user.email "actions@github.com"
          git add Formula/aicommit.rb
          git commit -m "Update aicommit to ${{ github.ref_name }} with ARM support"
          git push

  build-deb-package:
    needs: [build-and-release, build-linux-x86]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Download Linux binary
        uses: actions/download-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist
      - name: Create .deb package
        run: |
          chmod +x ./dist/aicommit-linux-x86_64
          mkdir -p debian/DEBIAN debian/usr/bin
          cat > debian/DEBIAN/control << EOF
          Package: aicommit
          Version: ${GITHUB_REF#refs/tags/v}
          Section: utils
          Priority: optional
          Architecture: amd64
          Maintainer: Cascade Team
          Description: AI-powered commit message generator
           A tool that helps developers write better commit messages using AI.
          EOF
          cp ./dist/aicommit-linux-x86_64 debian/usr/bin/aicommit
          dpkg-deb --build debian ./dist/aicommit_${GITHUB_REF#refs/tags/v}_amd64.deb
      - name: Upload .deb artifact
        uses: actions/upload-artifact@v4
        with:
          name: aicommit-deb-${{ github.ref_name }}
          path: ./dist/aicommit_*_amd64.deb
          if-no-files-found: error
      - name: Upload .deb Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          UPLOAD_URL: ${{ needs.build-and-release.outputs.upload_url }}
        with:
          upload_url: ${{ env.UPLOAD_URL }}
          asset_path: ./dist/aicommit_${GITHUB_REF#refs/tags/v}_amd64.deb
          asset_name: aicommit_${{ github.ref_name }}_amd64.deb
          asset_content_type: application/vnd.debian.binary-package

  build-rpm-package:
    needs: [build-and-release, build-linux-x86]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install RPM tools
        run: sudo apt-get update && sudo apt-get install -y rpm
      - name: Download Linux binary
        uses: actions/download-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist
      - name: Create RPM structure
        run: |
          chmod +x ./dist/aicommit-linux-x86_64
          mkdir -p rpmbuild/{SPECS,BUILD,BUILDROOT,RPMS,SOURCES}
          cp ./dist/aicommit-linux-x86_64 rpmbuild/SOURCES/aicommit
          cat > rpmbuild/SPECS/aicommit.spec << EOF
          Name:           aicommit
          Version:        ${GITHUB_REF#refs/tags/v}
          Release:        1%{?dist}
          Summary:        AI-powered commit message generator
          License:        MIT
          URL:           https://github.com/suenot/aicommit
          BuildArch:     x86_64

          %description
          A tool that helps developers write better commit messages using AI.

          %install
          mkdir -p %{buildroot}/usr/bin
          cp %{_sourcedir}/aicommit %{buildroot}/usr/bin/aicommit

          %files
          /usr/bin/aicommit

          %changelog
          * $(date '+%a %b %d %Y') Cascade Team <team@cascade.dev> - ${GITHUB_REF#refs/tags/v}
          - Initial RPM release
          EOF
      - name: Build RPM package
        run: rpmbuild --define "_topdir $(pwd)/rpmbuild" -bb rpmbuild/SPECS/aicommit.spec
      - name: Move RPM to dist
        run: |
          mkdir -p dist
          cp rpmbuild/RPMS/x86_64/*.rpm ./dist/
      - name: Upload RPM artifact
        uses: actions/upload-artifact@v4
        with:
          name: aicommit-rpm-${{ github.ref_name }}
          path: ./dist/*.rpm
          if-no-files-found: error
      - name: Upload RPM Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          UPLOAD_URL: ${{ needs.build-and-release.outputs.upload_url }}
        with:
          upload_url: ${{ env.UPLOAD_URL }}
          asset_path: ./dist/aicommit-${{ github.ref_name }}-1.x86_64.rpm
          asset_name: aicommit-${{ github.ref_name }}-1.x86_64.rpm
          asset_content_type: application/x-rpm

  build-alpine-package:
    needs: [build-and-release, build-linux-x86]
    runs-on: ubuntu-latest
    container: alpine:latest
    steps:
      - uses: actions/checkout@v4
      - name: Install build tools
        run: |
          apk add --no-cache alpine-sdk
      - name: Download Linux binary
        uses: actions/download-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist
      - name: Create APKBUILD
        run: |
          chmod +x ./dist/aicommit-linux-x86_64
          mkdir -p ~/packages/aicommit
          cat > ~/packages/aicommit/APKBUILD << EOF
          # Contributor: Cascade Team
          # Maintainer: Cascade Team
          pkgname=aicommit
          pkgver=${GITHUB_REF#refs/tags/v}
          pkgrel=0
          pkgdesc="AI-powered commit message generator"
          url="https://github.com/suenot/aicommit"
          arch="x86_64"
          license="MIT"
          depends=""
          makedepends=""
          source=""
          builddir="\$srcdir/\$pkgname-\$pkgver"

          package() {
              mkdir -p "\$pkgdir"/usr/bin
              install -m755 ../../dist/aicommit-linux-x86_64 "\$pkgdir"/usr/bin/aicommit
          }
          EOF
      - name: Build Alpine package
        run: |
          cd ~/packages/aicommit
          abuild-keygen -a -n
          abuild -r
      - name: Copy package to dist
        run: |
          mkdir -p dist
          cp ~/packages/aicommit/packages/x86_64/*.apk ./dist/
      - name: Upload Alpine package artifact
        uses: actions/upload-artifact@v4
        with:
          name: aicommit-alpine-${{ github.ref_name }}
          path: ./dist/*.apk
          if-no-files-found: error
      - name: Upload Alpine Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          UPLOAD_URL: ${{ needs.build-and-release.outputs.upload_url }}
        with:
          upload_url: ${{ env.UPLOAD_URL }}
          asset_path: ./dist/aicommit-${{ github.ref_name }}-r0.apk
          asset_name: aicommit-${{ github.ref_name }}-r0.apk
          asset_content_type: application/x-alpine-linux-package

  build-arch-package:
    needs: [build-and-release, build-linux-x86]
    runs-on: ubuntu-latest
    container: archlinux:base-devel
    steps:
      - uses: actions/checkout@v4
      - name: Download Linux binary
        uses: actions/download-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist
      - name: Create PKGBUILD
        run: |
          chmod +x ./dist/aicommit-linux-x86_64
          mkdir -p pkg
          cat > pkg/PKGBUILD << EOF
          # Maintainer: Cascade Team
          pkgname=aicommit
          pkgver=${GITHUB_REF#refs/tags/v}
          pkgrel=1
          pkgdesc="AI-powered commit message generator"
          arch=('x86_64')
          url="https://github.com/suenot/aicommit"
          license=('MIT')
          depends=()
          source=()
          sha256sums=()

          package() {
              install -Dm755 ../dist/aicommit-linux-x86_64 "\$pkgdir/usr/bin/aicommit"
          }
          EOF
      - name: Build Arch package
        run: |
          cd pkg
          makepkg -f
      - name: Copy package to dist
        run: |
          mkdir -p dist
          cp pkg/*.pkg.tar.zst ./dist/
      - name: Upload Arch package artifact
        uses: actions/upload-artifact@v4
        with:
          name: aicommit-arch-${{ github.ref_name }}
          path: ./dist/*.pkg.tar.zst
          if-no-files-found: error
      - name: Upload Arch Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          UPLOAD_URL: ${{ needs.build-and-release.outputs.upload_url }}
        with:
          upload_url: ${{ env.UPLOAD_URL }}
          asset_path: ./dist/aicommit-${{ github.ref_name }}-1-x86_64.pkg.tar.zst
          asset_name: aicommit-${{ github.ref_name }}-1-x86_64.pkg.tar.zst
          asset_content_type: application/zstd

  build-snap-package:
    needs: [build-and-release, build-linux-x86]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Snapcraft
        run: |
          sudo snap install snapcraft --classic
          sudo snap install lxd
          sudo lxd init --auto
      - name: Download Linux binary
        uses: actions/download-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist
      - name: Create snapcraft.yaml
        run: |
          mkdir -p snap
          cat > snap/snapcraft.yaml << EOF
          name: aicommit
          version: '${GITHUB_REF#refs/tags/v}'
          summary: AI-powered commit message generator
          description: |
            A tool that helps developers write better commit messages using AI.
          grade: stable
          confinement: strict
          base: core22
          
          apps:
            aicommit:
              command: bin/aicommit
              plugs:
                - home
                - network
                - removable-media
          
          parts:
            aicommit:
              plugin: dump
              source: dist/
              prime:
                - aicommit-linux-x86_64
              override-prime: |
                craftctl default
                mv aicommit-linux-x86_64 bin/aicommit
                chmod +x bin/aicommit
          EOF
      - name: Build Snap package
        run: |
          sudo chmod a+w .
          snapcraft --destructive-mode
      - name: Upload Snap artifact
        uses: actions/upload-artifact@v4
        with:
          name: aicommit-snap-${{ github.ref_name }}
          path: ./*.snap
          if-no-files-found: error
      - name: Upload Snap Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          UPLOAD_URL: ${{ needs.build-and-release.outputs.upload_url }}
        with:
          upload_url: ${{ env.UPLOAD_URL }}
          asset_path: ./aicommit_${{ github.ref_name }}_amd64.snap
          asset_name: aicommit_${{ github.ref_name }}_amd64.snap
          asset_content_type: application/vnd.snap

  build-nix-package:
    needs: [build-and-release, build-linux-x86]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install Nix
        uses: cachix/install-nix-action@v24
      - name: Download Linux binary
        uses: actions/download-artifact@v4
        with:
          name: binaries-linux-x86_64-${{ github.ref_name }}
          path: ./dist
      - name: Create default.nix
        run: |
          cat > default.nix << EOF
          { lib, stdenv }:
          
          stdenv.mkDerivation rec {
            pname = "aicommit";
            version = "${GITHUB_REF#refs/tags/v}";
          
            src = ./dist;
          
            dontUnpack = true;
            dontBuild = true;
          
            installPhase = ''
              mkdir -p \$out/bin
              cp \$src/aicommit-linux-x86_64 \$out/bin/aicommit
              chmod +x \$out/bin/aicommit
            '';
          
            meta = with lib; {
              description = "AI-powered commit message generator";
              homepage = "https://github.com/suenot/aicommit";
              license = licenses.mit;
              maintainers = [];
              platforms = platforms.linux;
            };
          }
          EOF
      - name: Create flake.nix
        run: |
          cat > flake.nix << EOF
          {
            description = "AI-powered commit message generator";
          
            inputs = {
              nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
              flake-utils.url = "github:numtide/flake-utils";
            };
          
            outputs = { self, nixpkgs, flake-utils }:
              flake-utils.lib.eachDefaultSystem (system:
                let
                  pkgs = nixpkgs.legacyPackages.\${system};
                in
                {
                  packages = rec {
                    aicommit = pkgs.callPackage ./default.nix {};
                    default = aicommit;
                  };
                }
              );
          }
          EOF
      - name: Build Nix package
        run: |
          nix build
          mkdir -p dist-nix
          cp result dist-nix/aicommit-${{ github.ref_name }}.tar.gz
      - name: Upload Nix artifact
        uses: actions/upload-artifact@v4
        with:
          name: aicommit-nix-${{ github.ref_name }}
          path: dist-nix/*.tar.gz
          if-no-files-found: error
      - name: Upload Nix Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          UPLOAD_URL: ${{ needs.build-and-release.outputs.upload_url }}
        with:
          upload_url: ${{ env.UPLOAD_URL }}
          asset_path: ./dist-nix/aicommit-${{ github.ref_name }}.tar.gz
          asset_name: aicommit-${{ github.ref_name }}.tar.gz
          asset_content_type: application/gzip