added windows installer #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| # macOS | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| archive: tar.gz | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| archive: tar.gz | |
| # Linux | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| archive: tar.gz | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| archive: tar.gz | |
| # Windows | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| archive: zip | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: ${{ matrix.target }} | |
| override: true | |
| - name: Install cross-compilation tools | |
| if: matrix.target == 'aarch64-unknown-linux-gnu' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu | |
| - name: Build | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar -czvf ../../../memorycli-${{ matrix.target }}.tar.gz memorycli | |
| cd ../../.. | |
| - name: Package (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| 7z a ../../../memorycli-${{ matrix.target }}.zip memorycli.exe | |
| cd ../../.. | |
| - name: Setup NSIS | |
| if: matrix.os == 'windows-latest' | |
| uses: sebastianpopp/[email protected] | |
| - name: Build Windows Installer | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| # Copy executable to windows folder | |
| Copy-Item target\${{ matrix.target }}\release\memorycli.exe windows\memorycli.exe | |
| # Build installer | |
| cd windows | |
| makensis installer.nsi | |
| # Move installer to root for easier artifact handling | |
| Move-Item memvid-installer.exe ..\memvid-installer.exe | |
| cd .. | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: memorycli-${{ matrix.target }} | |
| path: | | |
| memorycli-${{ matrix.target }}.${{ matrix.archive }} | |
| memvid-installer.exe | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| memorycli-*/memorycli-* | |
| memorycli-x86_64-pc-windows-msvc/memvid-installer.exe | |
| generate_release_notes: true | |
| # Update Homebrew tap | |
| homebrew: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: memvid/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-tap | |
| - name: Download binaries and calculate SHA256 | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| BASE_URL="https://github.com/memvid/memory-cli/releases/download/${VERSION}" | |
| # Download and calculate SHA256 for each platform | |
| SHA_X86_64_MACOS=$(curl -sL "${BASE_URL}/memorycli-x86_64-apple-darwin.tar.gz" | shasum -a 256 | cut -d' ' -f1) | |
| SHA_AARCH64_MACOS=$(curl -sL "${BASE_URL}/memorycli-aarch64-apple-darwin.tar.gz" | shasum -a 256 | cut -d' ' -f1) | |
| SHA_X86_64_LINUX=$(curl -sL "${BASE_URL}/memorycli-x86_64-unknown-linux-gnu.tar.gz" | shasum -a 256 | cut -d' ' -f1) | |
| SHA_AARCH64_LINUX=$(curl -sL "${BASE_URL}/memorycli-aarch64-unknown-linux-gnu.tar.gz" | shasum -a 256 | cut -d' ' -f1) | |
| echo "SHA_X86_64_MACOS=${SHA_X86_64_MACOS}" >> $GITHUB_ENV | |
| echo "SHA_AARCH64_MACOS=${SHA_AARCH64_MACOS}" >> $GITHUB_ENV | |
| echo "SHA_X86_64_LINUX=${SHA_X86_64_LINUX}" >> $GITHUB_ENV | |
| echo "SHA_AARCH64_LINUX=${SHA_AARCH64_LINUX}" >> $GITHUB_ENV | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Update Homebrew formula | |
| working-directory: homebrew-tap | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| BASE_URL: https://github.com/memvid/memory-cli/releases/download/${{ github.ref_name }} | |
| run: | | |
| python3 << 'EOF' | |
| import re | |
| import os | |
| FORMULA_FILE = "Formula/memorycli.rb" | |
| VERSION = os.environ['VERSION'].lstrip('v') | |
| BASE_URL = os.environ['BASE_URL'] | |
| with open(FORMULA_FILE, 'r') as f: | |
| content = f.read() | |
| # Update version | |
| content = re.sub(r'version\s+"[^"]+"', f'version "{VERSION}"', content) | |
| # Update all URLs and SHA256s | |
| updates = [ | |
| ('x86_64-apple-darwin', os.environ['SHA_X86_64_MACOS']), | |
| ('aarch64-apple-darwin', os.environ['SHA_AARCH64_MACOS']), | |
| ('x86_64-unknown-linux-gnu', os.environ['SHA_X86_64_LINUX']), | |
| ('aarch64-unknown-linux-gnu', os.environ['SHA_AARCH64_LINUX']), | |
| ] | |
| for target, sha256 in updates: | |
| # Update URL | |
| url_pattern = rf'url\s+"[^"]*memorycli-{re.escape(target)}[^"]*"' | |
| new_url = f'url "{BASE_URL}/memorycli-{target}.tar.gz"' | |
| content = re.sub(url_pattern, new_url, content) | |
| # Update SHA256 (find the sha256 line after the URL) | |
| sha256_pattern = rf'(url\s+"[^"]*memorycli-{re.escape(target)}[^"]*"\s*\n\s*)sha256\s+"[^"]+"' | |
| replacement = rf'\1sha256 "{sha256}"' | |
| content = re.sub(sha256_pattern, replacement, content) | |
| with open(FORMULA_FILE, 'w') as f: | |
| f.write(content) | |
| EOF | |
| - name: Commit and push | |
| working-directory: homebrew-tap | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/memorycli.rb | |
| git diff --staged --quiet || git commit -m "Update memorycli to ${{ github.ref_name }}" | |
| git push |