|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: "Version to release (e.g., v1.0.0)" |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + packages: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + name: Build ${{ matrix.target }} |
| 21 | + runs-on: ${{ matrix.os }} |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + # Linux builds |
| 27 | + - target: bun-linux-x64 |
| 28 | + os: ubuntu-latest |
| 29 | + artifact: aish-linux-x64 |
| 30 | + - target: bun-linux-x64-baseline |
| 31 | + os: ubuntu-latest |
| 32 | + artifact: aish-linux-x64-baseline |
| 33 | + - target: bun-linux-arm64 |
| 34 | + os: ubuntu-latest |
| 35 | + artifact: aish-linux-arm64 |
| 36 | + |
| 37 | + # macOS builds |
| 38 | + - target: bun-darwin-x64 |
| 39 | + os: macos-13 # Intel runner |
| 40 | + artifact: aish-darwin-x64 |
| 41 | + - target: bun-darwin-arm64 |
| 42 | + os: macos-14 # Apple Silicon runner |
| 43 | + artifact: aish-darwin-arm64 |
| 44 | + |
| 45 | + # Windows builds |
| 46 | + - target: bun-windows-x64 |
| 47 | + os: windows-latest |
| 48 | + artifact: aish-windows-x64.exe |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Setup Bun |
| 55 | + uses: oven-sh/setup-bun@v2 |
| 56 | + with: |
| 57 | + bun-version: latest |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: bun install --frozen-lockfile |
| 61 | + |
| 62 | + - name: Build executable |
| 63 | + run: | |
| 64 | + VERSION=${GITHUB_REF_NAME#v} |
| 65 | + bun build --compile --minify --sourcemap --target=${{ matrix.target }} --define AISH_VERSION="\"$VERSION\"" src/index.ts --outfile ${{ matrix.artifact }} |
| 66 | + shell: bash |
| 67 | + |
| 68 | + - name: Test executable |
| 69 | + run: | |
| 70 | + if [ "$RUNNER_OS" == "Windows" ]; then |
| 71 | + ./${{ matrix.artifact }} --version |
| 72 | + else |
| 73 | + chmod +x ${{ matrix.artifact }} |
| 74 | + # Only test if the binary matches the runner architecture |
| 75 | + if [[ "${{ matrix.target }}" == *"arm64"* ]] && [[ "$(uname -m)" != "arm64" ]]; then |
| 76 | + echo "Skipping test for ARM64 binary on x64 runner" |
| 77 | + file ${{ matrix.artifact }} |
| 78 | + else |
| 79 | + ./${{ matrix.artifact }} --version |
| 80 | + fi |
| 81 | + fi |
| 82 | + shell: bash |
| 83 | + |
| 84 | + - name: Create tarball (Unix) |
| 85 | + if: runner.os != 'Windows' && success() |
| 86 | + run: | |
| 87 | + if [ -f "${{ matrix.artifact }}" ]; then |
| 88 | + tar -czf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }} |
| 89 | + if [ "$RUNNER_OS" == "macOS" ]; then |
| 90 | + shasum -a 256 ${{ matrix.artifact }}.tar.gz > ${{ matrix.artifact }}.tar.gz.sha256 |
| 91 | + else |
| 92 | + sha256sum ${{ matrix.artifact }}.tar.gz > ${{ matrix.artifact }}.tar.gz.sha256 |
| 93 | + fi |
| 94 | + else |
| 95 | + echo "Binary ${{ matrix.artifact }} not found, skipping tarball creation" |
| 96 | + fi |
| 97 | + shell: bash |
| 98 | + |
| 99 | + - name: Create zip (Windows) |
| 100 | + if: runner.os == 'Windows' && success() |
| 101 | + run: | |
| 102 | + if exist "${{ matrix.artifact }}" ( |
| 103 | + 7z a ${{ matrix.artifact }}.zip ${{ matrix.artifact }} |
| 104 | + certutil -hashfile ${{ matrix.artifact }}.zip SHA256 > ${{ matrix.artifact }}.zip.sha256 |
| 105 | + ) else ( |
| 106 | + echo Binary ${{ matrix.artifact }} not found, skipping zip creation |
| 107 | + ) |
| 108 | + shell: cmd |
| 109 | + |
| 110 | + - name: Upload artifacts |
| 111 | + uses: actions/upload-artifact@v4 |
| 112 | + if: always() |
| 113 | + with: |
| 114 | + name: ${{ matrix.artifact }} |
| 115 | + path: | |
| 116 | + ${{ matrix.artifact }}* |
| 117 | + retention-days: 30 |
| 118 | + |
| 119 | + release: |
| 120 | + name: Create Release |
| 121 | + needs: build |
| 122 | + runs-on: ubuntu-latest |
| 123 | + if: always() && (needs.build.result == 'success' || needs.build.result == 'failure') |
| 124 | + steps: |
| 125 | + - name: Checkout code |
| 126 | + uses: actions/checkout@v4 |
| 127 | + |
| 128 | + - name: Download all artifacts |
| 129 | + uses: actions/download-artifact@v4 |
| 130 | + with: |
| 131 | + path: artifacts |
| 132 | + continue-on-error: true |
| 133 | + |
| 134 | + - name: Prepare release assets |
| 135 | + run: | |
| 136 | + mkdir -p release-assets |
| 137 | + if [ -d "artifacts" ]; then |
| 138 | + find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.sha256" \) -exec cp {} release-assets/ \; 2>/dev/null || true |
| 139 | + fi |
| 140 | + echo "Available release assets:" |
| 141 | + ls -la release-assets/ || echo "No release assets found" |
| 142 | +
|
| 143 | + # Count successful builds |
| 144 | + ASSET_COUNT=$(ls release-assets/*.tar.gz release-assets/*.zip 2>/dev/null | wc -l || echo 0) |
| 145 | + echo "Found $ASSET_COUNT binary assets" |
| 146 | +
|
| 147 | + - name: Generate release notes |
| 148 | + id: release_notes |
| 149 | + run: | |
| 150 | + cat > release_notes.md << 'EOF' |
| 151 | + ## 🚀 What's New |
| 152 | +
|
| 153 | + This release includes pre-compiled binaries for multiple platforms: |
| 154 | +
|
| 155 | + ### 📦 Downloads |
| 156 | +
|
| 157 | + **Linux:** |
| 158 | + - `aish-linux-x64.tar.gz` - Standard x64 build |
| 159 | + - `aish-linux-x64-baseline.tar.gz` - Compatible with older CPUs (pre-2013) |
| 160 | + - `aish-linux-arm64.tar.gz` - ARM64 build for servers like AWS Graviton |
| 161 | +
|
| 162 | + **macOS:** |
| 163 | + - `aish-darwin-x64.tar.gz` - Intel Macs |
| 164 | + - `aish-darwin-arm64.tar.gz` - Apple Silicon Macs (M1/M2/M3) |
| 165 | +
|
| 166 | + **Windows:** |
| 167 | + - `aish-windows-x64.exe.zip` - Standard x64 build |
| 168 | + ### 🔧 Installation |
| 169 | +
|
| 170 | + **Quick install (recommended):** |
| 171 | + ```bash |
| 172 | + curl -fsSL https://raw.githubusercontent.com/abhishekbhardwaj/aish-cli/main/scripts/install.sh | bash |
| 173 | + ``` |
| 174 | +
|
| 175 | + **Manual installation:** |
| 176 | + 1. Download the appropriate binary for your platform |
| 177 | + 2. Extract the archive |
| 178 | + 3. Make executable (Unix): `chmod +x aish` |
| 179 | + 4. Move to PATH: `mv aish /usr/local/bin/` |
| 180 | +
|
| 181 | + ### ✅ Verification |
| 182 | +
|
| 183 | + All binaries include SHA256 checksums for verification: |
| 184 | + ```bash |
| 185 | + sha256sum -c aish-*.sha256 |
| 186 | + ``` |
| 187 | +
|
| 188 | + ### 🔐 Security |
| 189 | +
|
| 190 | + - All binaries are built in GitHub Actions for transparency |
| 191 | + - SHA256 checksums provided for verification |
| 192 | + EOF |
| 193 | +
|
| 194 | + echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 195 | + cat release_notes.md >> $GITHUB_OUTPUT |
| 196 | + echo "EOF" >> $GITHUB_OUTPUT |
| 197 | +
|
| 198 | + - name: Create Release |
| 199 | + uses: softprops/action-gh-release@v2 |
| 200 | + with: |
| 201 | + tag_name: ${{ github.ref_name || github.event.inputs.version }} |
| 202 | + name: Release ${{ github.ref_name || github.event.inputs.version }} |
| 203 | + body: ${{ steps.release_notes.outputs.notes }} |
| 204 | + files: release-assets/* |
| 205 | + draft: false |
| 206 | + prerelease: false |
| 207 | + env: |
| 208 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments