Bump version for alpha test release #27
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
| # Release workflow for celq binaries | |
| # Credit: Inspired by https://github.com/01mf02/jaq/blob/main/.github/workflows/release.yml | |
| # Also see: https://github.com/BurntSushi/ripgrep/blob/61733f6378b62fa2dc2e7f3eff2f2e7182069ca9/.github/workflows/release.yml | |
| name: GitHub Release | |
| on: | |
| workflow_dispatch: # Manual trigger only | |
| push: | |
| tags: | |
| - "v[0-9]*" # Trigger on version tags like v1.0.0 | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| NAME: celq | |
| VERSION: ${{ github.ref_name }} | |
| # Required for gh release upload | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| environment: github_release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # macOS ARM64 (native) | |
| - { target: aarch64-apple-darwin, os: macos-15 } | |
| # macOS x86-64 (native) | |
| - { target: x86_64-apple-darwin, os: macos-15-intel } | |
| # Windows x86-64 (native) | |
| - { target: x86_64-pc-windows-msvc, os: windows-2025 } | |
| # Linux x86-64 (native - musl static binary) | |
| - { target: x86_64-unknown-linux-musl, os: ubuntu-24.04 } | |
| # Linux ARM64 (native - musl static binary) | |
| - { target: aarch64-unknown-linux-musl, os: ubuntu-24.04-arm } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install musl tools (for musl targets) | |
| if: contains(matrix.target, 'musl') | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y musl-tools | |
| - name: Build | |
| run: cargo build --locked --release --target ${{ matrix.target }} | |
| - name: Create release archive | |
| id: archive | |
| run: | | |
| EXE_suffix="" | |
| case ${{ matrix.target }} in | |
| *-pc-windows-*) EXE_suffix=".exe" ;; | |
| esac | |
| BIN_PATH="target/${{ matrix.target }}/release/${NAME}${EXE_suffix}" | |
| BIN_NAME="${NAME}${EXE_suffix}" | |
| # Determine archive format based on platform | |
| case ${{ matrix.target }} in | |
| *-pc-windows-*) | |
| # Windows: create .zip archive | |
| ARCHIVE_NAME="${NAME}-${{ matrix.target }}.zip" | |
| 7z a "${ARCHIVE_NAME}" "${BIN_PATH}" | |
| ;; | |
| *) | |
| # Linux/macOS: create .tar.gz archive | |
| ARCHIVE_NAME="${NAME}-${{ matrix.target }}.tar.gz" | |
| tar czf "${ARCHIVE_NAME}" -C "target/${{ matrix.target }}/release" "${BIN_NAME}" | |
| ;; | |
| esac | |
| echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT | |
| - name: Upload release archive | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload ${VERSION} ${{ steps.archive.outputs.ARCHIVE_NAME }} | |
| build-zig: | |
| name: ${{ matrix.target }}${{ matrix.zigtargetsuffix }} | |
| runs-on: ${{ matrix.os }} | |
| environment: github_release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86-64 (zigbuild - glibc 2.28) | |
| - { target: x86_64-unknown-linux-gnu, os: ubuntu-24.04, zigtargetsuffix: .2.28 } | |
| # Linux ARM64 (zigbuild - glibc 2.28) | |
| - { target: aarch64-unknown-linux-gnu, os: ubuntu-24.04-arm, zigtargetsuffix: .2.28 } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install Zig | |
| uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.15.2 | |
| - name: Install cargo-zigbuild | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-zigbuild@0.20.1 | |
| - name: Build with Zig | |
| run: cargo zigbuild --locked --release --target ${{ matrix.target }}${{ matrix.zigtargetsuffix }} | |
| - name: Create release archive | |
| id: archive | |
| run: | | |
| BUILD_TARGET="${{ matrix.target }}${{ matrix.zigtargetsuffix }}" | |
| BIN_PATH="target/${BUILD_TARGET}/release/${NAME}" | |
| BIN_NAME="${NAME}" | |
| # Archive name uses base target without libc version | |
| ARCHIVE_NAME="${NAME}-${{ matrix.target }}.tar.gz" | |
| tar czf "${ARCHIVE_NAME}" -C "target/${BUILD_TARGET}/release" "${BIN_NAME}" | |
| echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT | |
| - name: Upload release archive | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload ${VERSION} ${{ steps.archive.outputs.ARCHIVE_NAME }} | |
| update-install-script: | |
| name: Update install script on GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: [build, build-zig] | |
| environment: github_release | |
| steps: | |
| - name: Checkout celq repository (for template) | |
| uses: actions/checkout@v4 | |
| with: | |
| path: celq-repo | |
| - name: Checkout get-celq.github.io repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: get-celq/get-celq.github.io | |
| token: ${{ secrets.PAGES_DEPLOY_TOKEN }} | |
| path: pages-repo | |
| - name: Generate install scripts | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| # Generate versioned install script (e.g., v0.1.1/install.sh or v0.2.0-beta.1/install.sh) | |
| mkdir -p "pages-repo/${VERSION}" | |
| sed "s/{{CELQ_VERSION}}/${VERSION}/g" celq-repo/template_install.sh > "pages-repo/${VERSION}/install.sh" | |
| chmod +x "pages-repo/${VERSION}/install.sh" | |
| # Only update root install.sh if this is NOT a pre-release | |
| # Pre-releases have a hyphen (e.g., v0.2.0-beta.1, v1.0.0-rc.1) | |
| if [[ ! "$VERSION" =~ -[a-zA-Z] ]]; then | |
| echo "Stable release detected, updating root install.sh" | |
| sed "s/{{CELQ_VERSION}}/${VERSION}/g" celq-repo/template_install.sh > pages-repo/install.sh | |
| chmod +x pages-repo/install.sh | |
| else | |
| echo "Pre-release detected, skipping root install.sh update" | |
| fi | |
| # Copy generated script for GitHub release attachment | |
| cp "pages-repo/${VERSION}/install.sh" celq-repo/install.sh | |
| - name: Upload install.sh to GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| cd celq-repo | |
| gh release upload ${{ github.ref_name }} install.sh --clobber | |
| - name: Commit and push changes to Pages repo | |
| run: | | |
| cd pages-repo | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| VERSION="${{ github.ref_name }}" | |
| # Add versioned install script | |
| git add "${VERSION}/install.sh" | |
| # Only add root install.sh if it was updated (stable release) | |
| if [[ ! "$VERSION" =~ -[a-zA-Z] ]]; then | |
| git add install.sh | |
| git commit -m "Update install script to $VERSION (stable release)" || echo "No changes to commit" | |
| else | |
| git commit -m "Add install script for $VERSION (pre-release)" || echo "No changes to commit" | |
| fi | |
| git push | |
| update-homebrew-formula: | |
| name: Update Homebrew formula | |
| runs-on: ubuntu-latest | |
| needs: [build, build-zig] | |
| environment: github_release | |
| steps: | |
| - name: Checkout celq repository (for template) | |
| uses: actions/checkout@v4 | |
| with: | |
| path: celq-repo | |
| - name: Check if pre-release | |
| id: check_prerelease | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| # Check if this is a pre-release (contains hyphen followed by alpha/beta/rc/etc) | |
| if [[ "$VERSION" =~ -[a-zA-Z] ]]; then | |
| echo "Pre-release detected: $VERSION" | |
| echo "Skipping Homebrew formula update (Homebrew doesn't support pre-releases in main formula)" | |
| echo "is_prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Stable release detected: $VERSION" | |
| echo "is_prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout homebrew-tap repository | |
| if: steps.check_prerelease.outputs.is_prerelease == 'false' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: get-celq/homebrew-tap | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| path: homebrew-tap | |
| - name: Update Homebrew formula | |
| if: steps.check_prerelease.outputs.is_prerelease == 'false' | |
| run: | | |
| VERSION="${{ github.ref_name }}" | |
| VERSION_WITHOUT_V="${VERSION#v}" # Remove 'v' prefix for version number | |
| echo "Updating Homebrew formula to version: $VERSION_WITHOUT_V" | |
| # Download the source tarball to calculate SHA256 | |
| TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${VERSION_WITHOUT_V}.tar.gz" | |
| echo "Downloading tarball from: $TARBALL_URL" | |
| curl -sL "$TARBALL_URL" -o "/tmp/celq-${VERSION_WITHOUT_V}.tar.gz" | |
| # Calculate SHA256 | |
| SHA256=$(sha256sum "/tmp/celq-${VERSION_WITHOUT_V}.tar.gz" | awk '{print $1}') | |
| echo "Calculated SHA256: $SHA256" | |
| # Generate formula from template using sed | |
| sed -e "s/{{CELQ_VERSION}}/${VERSION_WITHOUT_V}/g" \ | |
| -e "s/{{CELQ_SHA256}}/${SHA256}/g" \ | |
| celq-repo/brew/celq.rb > homebrew-tap/Formula/celq.rb | |
| echo "Formula updated successfully" | |
| - name: Commit and push Homebrew formula | |
| if: steps.check_prerelease.outputs.is_prerelease == 'false' | |
| run: | | |
| cd homebrew-tap | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/celq.rb | |
| git commit -m "Update celq to ${{ github.ref_name }}" || echo "No changes to commit" | |
| git push | |
| echo "✅ Homebrew formula updated to ${{ github.ref_name }}" |