name: Release CLI Binaries on: push: tags: - 'cli@*' workflow_dispatch: inputs: tag: description: 'Tag to release (e.g. cli@1.0.0)' required: true type: string permissions: contents: write jobs: build: name: Build CLI Binaries strategy: matrix: include: # - target: x86_64-unknown-linux-gnu # os: ubuntu-latest # package: grain-linux-x86_64 # artifact: grain-linux-x86_64 # - target: aarch64-unknown-linux-gnu # os: ubuntu-latest # package: grain-linux-aarch64 # artifact: grain-linux-aarch64 # - target: x86_64-apple-darwin # os: macos-13 # Intel Mac # package: grain-macos-x86_64 # artifact: grain-darwin-x86_64 - target: aarch64-apple-darwin os: macos-latest # Apple Silicon Mac package: grain-macos-aarch64 artifact: grain-darwin-aarch64 # - target: x86_64-pc-windows-gnu # os: ubuntu-latest # package: grain-windows-x86_64 # artifact: grain-windows-x86_64.exe runs-on: ${{ matrix.os }} defaults: run: working-directory: cli steps: - name: Checkout uses: actions/checkout@v4 - name: Install Nix uses: DeterminateSystems/nix-installer-action@main with: logger: pretty - name: Setup Nix cache uses: DeterminateSystems/magic-nix-cache-action@main - name: Check flake run: nix flake check - name: Build ${{ matrix.target }} run: nix build .#${{ matrix.package }} - name: Copy binary run: | mkdir -p releases if [ "${{ matrix.target }}" == "x86_64-pc-windows-gnu" ]; then cp result/bin/grain.exe releases/${{ matrix.artifact }} else cp result/bin/grain releases/${{ matrix.artifact }} fi - name: Upload artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: cli/releases/${{ matrix.artifact }} retention-days: 7 release: name: Create Release needs: build runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Prepare release assets run: | mkdir -p release-assets # Copy all binaries for dir in artifacts/*/; do for file in "$dir"*; do if [ -f "$file" ]; then cp "$file" release-assets/ fi done done # Copy install script cp cli/install.sh release-assets/ # Create checksums cd release-assets sha256sum * > checksums.txt # List files for verification ls -la - name: Get tag name id: tag run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT else echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT fi - name: Create Release uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.tag.outputs.tag }} name: Grain CLI ${{ steps.tag.outputs.tag }} draft: false prerelease: false files: | release-assets/* body: | ## Grain CLI ${{ steps.tag.outputs.tag }} ### Installation Quick install: ```bash curl -L https://github.com/grainsocial/grain/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash ``` Or download manually: - **Linux x86_64**: `grain-linux-x86_64` - **Linux aarch64**: `grain-linux-aarch64` - **macOS Intel**: `grain-darwin-x86_64` - **macOS Apple Silicon**: `grain-darwin-aarch64` - **Windows x86_64**: `grain-windows-x86_64.exe` ### Usage ```bash grain login grain gallery list grain gallery create ``` ### Checksums See `checksums.txt` for SHA256 checksums. env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} test-install: name: Test Installation needs: build strategy: matrix: os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v4 - name: Get tag name id: tag run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT else echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT fi - name: Test install script run: | # Wait for release to be available sleep 30 # Test the install script curl -L https://github.com/grainsocial/grain/releases/download/${{ steps.tag.outputs.tag }}/install.sh | bash