b58uuid-cli 1.0.0

Compact Base58 UUID Encoder CLI - Convert UUIDs to 22-character Base58 format
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
name: Release

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
  contents: write

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          # Linux x86_64
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: b58uuid
            asset_name: b58uuid-linux-amd64
          
          # macOS x86_64
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact_name: b58uuid
            asset_name: b58uuid-darwin-amd64
          
          # macOS ARM64
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: b58uuid
            asset_name: b58uuid-darwin-arm64
          
          # Windows x86_64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact_name: b58uuid.exe
            asset_name: b58uuid-windows-amd64.exe

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Strip binary (Linux/macOS)
        if: matrix.os != 'windows-latest'
        run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

      - name: Create archive (Linux/macOS)
        if: matrix.os != 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
          mv ${{ matrix.asset_name }}.tar.gz ../../..

      - name: Create archive (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          7z a ${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
          mv ${{ matrix.asset_name }}.zip ../../..

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.asset_name }}
          path: ${{ matrix.asset_name }}.*

  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Prepare release files
        run: |
          mkdir -p release-files
          find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp {} release-files/ \;
          ls -lh release-files/

      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          files: release-files/*
          body_path: CHANGELOG.md
          draft: false
          prerelease: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish-crates:
    name: Publish to crates.io
    needs: release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CARGO_TOKEN }}

  build-linux-packages:
    name: Build Linux Packages
    needs: release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Download Linux binary
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          curl -LO https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-linux-amd64.tar.gz
          tar -xzf b58uuid-linux-amd64.tar.gz

      - name: Install packaging tools
        run: |
          sudo apt-get update
          sudo apt-get install -y dpkg-dev rpm

      - name: Build .deb package
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          ARCH="amd64"
          
          # Create package structure
          mkdir -p debian-pkg/DEBIAN
          mkdir -p debian-pkg/usr/local/bin
          mkdir -p debian-pkg/usr/share/doc/b58uuid
          mkdir -p debian-pkg/usr/share/man/man1
          
          # Copy binary
          cp b58uuid debian-pkg/usr/local/bin/
          chmod 755 debian-pkg/usr/local/bin/b58uuid
          
          # Create control file
          cat > debian-pkg/DEBIAN/control << EOF
          Package: b58uuid
          Version: ${VERSION}
          Section: utils
          Priority: optional
          Architecture: ${ARCH}
          Maintainer: B58UUID Contributors <hello@b58uuid.io>
          Description: Compact Base58 UUID Encoder CLI
           Convert UUIDs to 22-character Base58 format.
           Supports encoding, decoding, generation, and validation.
          Homepage: https://b58uuid.io
          EOF
          
          # Copy documentation
          cp README.md debian-pkg/usr/share/doc/b58uuid/
          cp LICENSE debian-pkg/usr/share/doc/b58uuid/
          cp CHANGELOG.md debian-pkg/usr/share/doc/b58uuid/
          
          # Create man page
          cat > debian-pkg/usr/share/man/man1/b58uuid.1 << 'EOF'
          .TH B58UUID 1 "2026-01-13" "${VERSION}" "B58UUID CLI Manual"
          .SH NAME
          b58uuid \- Compact Base58 UUID Encoder CLI
          .SH SYNOPSIS
          .B b58uuid
          [\fIOPTIONS\fR] \fICOMMAND\fR
          .SH DESCRIPTION
          B58UUID CLI converts UUIDs to compact 22-character Base58 format.
          .SH COMMANDS
          .TP
          .B encode
          Encode UUID to B58UUID format
          .TP
          .B decode
          Decode B58UUID to standard UUID format
          .TP
          .B generate
          Generate random B58UUID
          .TP
          .B validate
          Validate UUID or B58UUID format
          .SH OPTIONS
          .TP
          .B \-h, \-\-help
          Display help information
          .TP
          .B \-V, \-\-version
          Display version information
          .SH EXAMPLES
          .TP
          b58uuid encode 550e8400-e29b-41d4-a716-446655440000
          .TP
          b58uuid decode BWBeN28Vb7cMEx7Ym8AUzs
          .TP
          b58uuid generate
          .SH AUTHOR
          B58UUID Contributors
          .SH HOMEPAGE
          https://b58uuid.io
          EOF
          
          gzip -9 debian-pkg/usr/share/man/man1/b58uuid.1
          
          # Build package
          dpkg-deb --build debian-pkg b58uuid_${VERSION}_${ARCH}.deb

      - name: Build .rpm package
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          
          # Create RPM build structure
          mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
          
          # Copy binary to SOURCES directory
          cp b58uuid ~/rpmbuild/SOURCES/
          
          # Create spec file
          cat > ~/rpmbuild/SPECS/b58uuid.spec << EOF
          Name:           b58uuid
          Version:        ${VERSION}
          Release:        1%{?dist}
          Summary:        Compact Base58 UUID Encoder CLI
          License:        MIT
          URL:            https://b58uuid.io
          
          %description
          B58UUID CLI converts UUIDs to compact 22-character Base58 format.
          Supports encoding, decoding, generation, and validation.
          
          %prep
          
          %build
          
          %install
          mkdir -p %{buildroot}/usr/local/bin
          cp %{_sourcedir}/b58uuid %{buildroot}/usr/local/bin/
          chmod 755 %{buildroot}/usr/local/bin/b58uuid
          
          %files
          /usr/local/bin/b58uuid
          
          %changelog
          * $(date "+%a %b %d %Y") B58UUID Contributors <hello@b58uuid.io> - ${VERSION}-1
          - Release ${VERSION}
          EOF
          
          # Build RPM
          rpmbuild -bb ~/rpmbuild/SPECS/b58uuid.spec

      - name: Upload packages to release
        uses: softprops/action-gh-release@v1
        with:
          files: |
            b58uuid_*.deb
            ~/rpmbuild/RPMS/x86_64/b58uuid-*.rpm
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  update-package-managers:
    name: Update Package Manager Configs
    needs: release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Wait for release assets to be available
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          echo "Waiting for release assets to be available..."
          sleep 30
          
          # Verify all assets exist and are not empty
          for asset in b58uuid-darwin-amd64.tar.gz b58uuid-darwin-arm64.tar.gz b58uuid-linux-amd64.tar.gz b58uuid-windows-amd64.zip; do
            echo "Checking $asset..."
            for i in {1..10}; do
              SIZE=$(curl -sI "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/${asset}" | grep -i content-length | awk '{print $2}' | tr -d '\r')
              if [ "$SIZE" -gt 1000 ]; then
                echo "✓ $asset is available (${SIZE} bytes)"
                break
              fi
              echo "  Waiting for $asset... (attempt $i/10)"
              sleep 10
            done
          done

      - name: Download release assets
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          
          # Download all binaries
          curl -LO https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-darwin-amd64.tar.gz
          curl -LO https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-darwin-arm64.tar.gz
          curl -LO https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-linux-amd64.tar.gz
          curl -LO https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-windows-amd64.zip
          
          # Verify downloads
          ls -lh *.tar.gz *.zip

      - name: Calculate checksums
        id: checksums
        run: |
          echo "darwin_amd64=$(shasum -a 256 b58uuid-darwin-amd64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
          echo "darwin_arm64=$(shasum -a 256 b58uuid-darwin-arm64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
          echo "linux_amd64=$(shasum -a 256 b58uuid-linux-amd64.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT
          echo "windows_amd64=$(shasum -a 256 b58uuid-windows-amd64.zip | awk '{print $1}')" >> $GITHUB_OUTPUT
          
          # Display checksums for verification
          echo "Checksums:"
          echo "  darwin_amd64: $(shasum -a 256 b58uuid-darwin-amd64.tar.gz | awk '{print $1}')"
          echo "  darwin_arm64: $(shasum -a 256 b58uuid-darwin-arm64.tar.gz | awk '{print $1}')"
          echo "  linux_amd64: $(shasum -a 256 b58uuid-linux-amd64.tar.gz | awk '{print $1}')"
          echo "  windows_amd64: $(shasum -a 256 b58uuid-windows-amd64.zip | awk '{print $1}')"

      - name: Update Homebrew tap
        if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          
          # Clone homebrew-tap repository with token
          git clone https://x-access-token:${{ secrets.HOMEBREW_TAP_TOKEN }}@github.com/${{ github.repository_owner }}/homebrew-tap.git
          cd homebrew-tap
          
          # Create updated formula
          cat > Formula/b58uuid.rb << EOF
          class B58uuid < Formula
            desc "Compact Base58 UUID Encoder CLI"
            homepage "https://b58uuid.io"
            version "${VERSION}"
            license "MIT"
            
            on_macos do
              if Hardware::CPU.arm?
                url "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-darwin-arm64.tar.gz"
                sha256 "${{ steps.checksums.outputs.darwin_arm64 }}"
              else
                url "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-darwin-amd64.tar.gz"
                sha256 "${{ steps.checksums.outputs.darwin_amd64 }}"
              end
            end

            on_linux do
              url "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-linux-amd64.tar.gz"
              sha256 "${{ steps.checksums.outputs.linux_amd64 }}"
            end

            def install
              bin.install "b58uuid"
            end

            test do
              system "#{bin}/b58uuid", "--version"
              assert_match "b58uuid ${VERSION}", shell_output("#{bin}/b58uuid --version")
              
              # Test encode
              output = shell_output("#{bin}/b58uuid encode 550e8400-e29b-41d4-a716-446655440000")
              assert_match "BWBeN28Vb7cMEx7Ym8AUzs", output
              
              # Test decode
              output = shell_output("#{bin}/b58uuid decode BWBeN28Vb7cMEx7Ym8AUzs")
              assert_match "550e8400-e29b-41d4-a716-446655440000", output
              
              # Test generate (should output 22 characters)
              output = shell_output("#{bin}/b58uuid generate")
              assert_match /^[A-HJ-NP-Za-km-z1-9]{22}$/, output.strip
            end
          end
          EOF
          
          # Commit and push
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/b58uuid.rb
          if git diff --staged --quiet; then
            echo "No changes to commit"
          else
            git commit -m "Update b58uuid to v${VERSION}"
            git push
          fi

      - name: Update Scoop bucket
        if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          
          # Clone scoop-bucket repository with token
          git clone https://x-access-token:${{ secrets.SCOOP_BUCKET_TOKEN }}@github.com/${{ github.repository_owner }}/scoop-bucket.git
          cd scoop-bucket
          
          # Update manifest
          cat > b58uuid.json << EOF
          {
            "version": "${VERSION}",
            "description": "Compact Base58 UUID Encoder CLI - Convert UUIDs to 22-character Base58 format",
            "homepage": "https://b58uuid.io",
            "license": "MIT",
            "url": "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/b58uuid-windows-amd64.zip",
            "hash": "${{ steps.checksums.outputs.windows_amd64 }}",
            "bin": "b58uuid.exe",
            "checkver": {
              "github": "https://github.com/${{ github.repository }}"
            },
            "autoupdate": {
              "url": "https://github.com/${{ github.repository }}/releases/download/v\$version/b58uuid-windows-amd64.zip"
            }
          }
          EOF
          
          # Commit and push
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add b58uuid.json
          if git diff --staged --quiet; then
            echo "No changes to commit"
          else
            git commit -m "Update b58uuid to v${VERSION}"
            git push
          fi