diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml index d98e68ab4..40e2a7abf 100644 --- a/.github/workflows/cli-release.yml +++ b/.github/workflows/cli-release.yml @@ -6,7 +6,7 @@ on: - 'cli/v*' # workflow_dispatch is kept to allow manual releases if needed. # Remove if all releases must be tag-triggered. - workflow_dispatch: + # workflow_dispatch: # Commenting this out as per user request # Add permissions for creating releases permissions: @@ -115,6 +115,9 @@ jobs: # Condition this job to run only for tag pushes, # or add logic to handle workflow_dispatch differently if version isn't from tag if: startsWith(github.ref, 'refs/tags/cli/v') + outputs: # Add outputs for the next job + release_tag: ${{ github.ref_name }} + release_version: ${{ steps.get_version.outputs.version }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -156,4 +159,161 @@ jobs: prerelease: false generate_release_notes: true # This uses conventional commits from the tag to main env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + update-homebrew-tap: + name: Update Homebrew Tap + needs: release + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/cli/v') # Ensure it runs only for CLI tags + steps: + - name: Get release version and tag from previous job + id: release_info + run: | + echo "RELEASE_VERSION=${{ needs.release.outputs.release_version }}" >> $GITHUB_ENV + echo "RELEASE_TAG=${{ needs.release.outputs.release_tag }}" >> $GITHUB_ENV + echo "Using version: ${{ needs.release.outputs.release_version }} from tag: ${{ needs.release.outputs.release_tag }}" + + - name: Set up GitHub CLI + uses: actions/setup-node@v4 # gh is often bundled, but this ensures it's available or can be installed + with: + node-version: '20' # Or any version that ensures gh is available + + - name: Download SHA256 sums from GitHub Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use GITHUB_TOKEN to interact with the current repo's release + GH_REPO: ${{ github.repository }} + run: | + gh release download ${{ env.RELEASE_TAG }} --pattern '*.sha256' -R $GH_REPO + echo "Downloaded SHA256 files:" + ls -la *.sha256 + + SHA_ARM64=$(cat buster-cli-darwin-arm64.tar.gz.sha256 | awk '{print $1}') + SHA_INTEL=$(cat buster-cli-darwin-x86_64.tar.gz.sha256 | awk '{print $1}') + SHA_LINUX=$(cat buster-cli-linux-x86_64.tar.gz.sha256 | awk '{print $1}') + + echo "SHA_ARM64=$SHA_ARM64" >> $GITHUB_ENV + echo "SHA_INTEL=$SHA_INTEL" >> $GITHUB_ENV + echo "SHA_LINUX=$SHA_LINUX" >> $GITHUB_ENV + + echo "ARM64 SHA: $SHA_ARM64" + echo "Intel SHA: $SHA_INTEL" + echo "Linux SHA: $SHA_LINUX" + + - name: Checkout Homebrew tap repository + uses: actions/checkout@v4 + with: + repository: buster-so/buster-homebrew + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} # PAT with repo scope for buster-so/buster-homebrew + path: buster-homebrew # Checkout to a specific path + + - name: Configure Git + working-directory: ./buster-homebrew + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Update Homebrew Formula + working-directory: ./buster-homebrew + env: + VERSION: ${{ env.RELEASE_VERSION }} + TAG: ${{ env.RELEASE_TAG }} + SHA_ARM64: ${{ env.SHA_ARM64 }} + SHA_INTEL: ${{ env.SHA_INTEL }} + SHA_LINUX: ${{ env.SHA_LINUX }} + run: | + FORMULA_FILE="Formula/buster.rb" + TEMP_FORMULA_FILE="Formula/buster.rb.tmp" + + # URLs for artifacts + URL_BASE="https://github.com/${{ github.repository_owner }}/buster/releases/download/$TAG" + URL_ARM64="$URL_BASE/buster-cli-darwin-arm64.tar.gz" + URL_INTEL="$URL_BASE/buster-cli-darwin-x86_64.tar.gz" + URL_LINUX="$URL_BASE/buster-cli-linux-x86_64.tar.gz" + + echo "Updating $FORMULA_FILE with Version: $VERSION" + echo "ARM64 URL: $URL_ARM64, SHA: $SHA_ARM64" + echo "Intel URL: $URL_INTEL, SHA: $SHA_INTEL" + echo "Linux URL: $URL_LINUX, SHA: $SHA_LINUX" + + # Update version + sed "s/^ version .*/ version \\"$VERSION\\"/" "$FORMULA_FILE" > "$TEMP_FORMULA_FILE" && mv "$TEMP_FORMULA_FILE" "$FORMULA_FILE" + + # Update top-level (defaults to ARM usually, as per your formula) + sed -E "s#^ url .*# url \\"$URL_ARM64\\"#" "$FORMULA_FILE" > "$TEMP_FORMULA_FILE" && mv "$TEMP_FORMULA_FILE" "$FORMULA_FILE" + sed "s/^ sha256 .*/ sha256 \\"$SHA_ARM64\\"/" "$FORMULA_FILE" > "$TEMP_FORMULA_FILE" && mv "$TEMP_FORMULA_FILE" "$FORMULA_FILE" + + # Update on_macos -> on_arm + # Use a block to target sed within the on_arm block. Delimit with unique markers. + awk ' + BEGIN { printing = 1; in_arm_block = 0; } + /on_macos do/,/end/ { + if (/on_arm do/) { in_arm_block = 1; } + if (in_arm_block && /url /) { + print " url \\"\\"" ENVIRON["URL_ARM64"] "\\"\\"" + next + } + if (in_arm_block && /sha256 /) { + print " sha256 \\"\\"" ENVIRON["SHA_ARM64"] "\\"\\"" + next + } + if (in_arm_block && /end/) { in_arm_block = 0; } + } + { print } + ' "$FORMULA_FILE" > "$TEMP_FORMULA_FILE" && mv "$TEMP_FORMULA_FILE" "$FORMULA_FILE" + + # Update on_macos -> on_intel + awk ' + BEGIN { printing = 1; in_intel_block = 0; } + /on_macos do/,/end/ { + if (/on_intel do/) { in_intel_block = 1; } + if (in_intel_block && /url /) { + print " url \\"\\"" ENVIRON["URL_INTEL"] "\\"\\"" + next + } + if (in_intel_block && /sha256 /) { + print " sha256 \\"\\"" ENVIRON["SHA_INTEL"] "\\"\\"" + next + } + if (in_intel_block && /end/) { in_intel_block = 0; } + } + { print } + ' "$FORMULA_FILE" > "$TEMP_FORMULA_FILE" && mv "$TEMP_FORMULA_FILE" "$FORMULA_FILE" + + # Update on_linux + awk ' + BEGIN { printing = 1; in_linux_block = 0; } + /on_linux do/,/end/ { + if (/url / && !in_linux_block) { next } # Skip top-level url if not already processed + if (/on_linux do/) { in_linux_block = 1; } + if (in_linux_block && /url /) { + print " url \\"\\"" ENVIRON["URL_LINUX"] "\\"\\"" + next + } + if (in_linux_block && /sha256 /) { + print " sha256 \\"\\"" ENVIRON["SHA_LINUX"] "\\"\\"" + next + } + if (in_linux_block && /end/) { in_linux_block = 0; } + } + { print } + ' "$FORMULA_FILE" > "$TEMP_FORMULA_FILE" && mv "$TEMP_FORMULA_FILE" "$FORMULA_FILE" + + echo "--- Formula file after updates ---" + cat "$FORMULA_FILE" + echo "--- End of formula file ---" + + - name: Commit and push changes to Homebrew tap + working-directory: ./buster-homebrew + run: | + git add Formula/buster.rb + # Check if there are changes to commit + if git diff --staged --quiet; then + echo "No changes to commit to Homebrew tap." + else + git commit -m "Update buster formula to version ${{ env.RELEASE_VERSION }} + + [skip ci]" + git push + echo "Pushed updated formula to buster-so/buster-homebrew." + fi \ No newline at end of file diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index d2dd57cf1..6fb8796e3 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -49,7 +49,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push API image - uses: docker/build-push-action@v5 + uses: useblacksmith/build-push-action@v1 with: context: ./api file: ./api/Dockerfile # Assuming this Dockerfile is for api/server @@ -97,7 +97,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Web image - uses: docker/build-push-action@v5 + uses: useblacksmith/build-push-action@v1 with: context: ./web file: ./web/Dockerfile diff --git a/.github/workflows/manage-versions.yml b/.github/workflows/manage-versions.yml index ed0875257..537560a0b 100644 --- a/.github/workflows/manage-versions.yml +++ b/.github/workflows/manage-versions.yml @@ -18,13 +18,19 @@ on: required: true default: 'patch' type: string + pull_request: + types: [closed] # Trigger only when a PR is closed + branches: + - evals # Target the 'evals' branch permissions: contents: write # To push commits and tags jobs: bump_versions: - runs-on: blacksmith + runs-on: blacksmith + # Add a condition to run only if the PR was merged + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true) outputs: new_api_version: ${{ steps.bump.outputs.new_api_version }} new_web_version: ${{ steps.bump.outputs.new_web_version }} @@ -49,11 +55,69 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + - name: Determine Version Spec and Component from Event + id: event_params + shell: bash + run: | + VERSION_SPEC="" + COMPONENT="" + COMMIT_MESSAGE_TEXT="" + + echo "Event name: ${{ github.event_name }}" + + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + VERSION_SPEC="${{ github.event.inputs.version_spec }}" + COMPONENT="${{ github.event.inputs.component }}" + echo "Using workflow_dispatch inputs: version_spec='$VERSION_SPEC', component='$COMPONENT'" + elif [[ "${{ github.event_name }}" == "push" ]]; then + COMMIT_MESSAGE_TEXT=$(echo "${{ github.event.head_commit.message }}" | tr '[:upper:]' '[:lower:]') + echo "Push event. Analyzing commit message (lowercase): $COMMIT_MESSAGE_TEXT" + COMPONENT="all" # Default component for push events + + if echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "breaking change|feat!:"; then + VERSION_SPEC="major" + elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^feat\\([^)]+\\)!:"; then # e.g., feat(scope)!: + VERSION_SPEC="major" + elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^feat:"; then + VERSION_SPEC="minor" + elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^fix:"; then + VERSION_SPEC="patch" + else + echo "No major/minor/fix keyword found in commit message. Defaulting to patch." + VERSION_SPEC="patch" + fi + echo "Determined for push: version_spec='$VERSION_SPEC', component='$COMPONENT'" + else + echo "Unhandled event type: ${{ github.event_name }}. Defaulting to patch and all." + VERSION_SPEC="patch" + COMPONENT="all" + fi + + if [[ -z "$VERSION_SPEC" ]]; then + echo "Warning: VERSION_SPEC is empty after evaluation. Defaulting to patch." + VERSION_SPEC="patch" + fi + if [[ -z "$COMPONENT" ]]; then + echo "Warning: COMPONENT is empty after evaluation. Defaulting to all." + COMPONENT="all" + fi + + echo "Final determined version_spec: $VERSION_SPEC" + echo "Final determined component: $COMPONENT" + + echo "version_spec=$VERSION_SPEC" >> $GITHUB_OUTPUT + echo "component=$COMPONENT" >> $GITHUB_OUTPUT + - name: Perform Version Bumps id: bump + shell: bash run: | - COMPONENT="${{ github.event.inputs.component }}" - VERSION_SPEC="${{ github.event.inputs.version_spec }}" + COMPONENT="${{ steps.event_params.outputs.component }}" + VERSION_SPEC="${{ steps.event_params.outputs.version_spec }}" + + echo "Component for bump: $COMPONENT" + echo "Version spec for bump: $VERSION_SPEC" + COMMIT_MESSAGE_PREFIX="chore(versions):" COMMIT_CHANGES=false @@ -63,24 +127,24 @@ jobs: # API Version Bump if [[ "$COMPONENT" == "all" || "$COMPONENT" == "api" ]]; then - echo "Bumping API version..." + echo "Bumping API version using spec: $VERSION_SPEC..." cd api/server - OLD_API_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\(.*\)"/\1/') + OLD_API_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\\(.*\\)"/\\1/') cargo bump "$VERSION_SPEC" - NEW_API_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\(.*\)"/\1/') + NEW_API_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\\(.*\\)"/\\1/') echo "API: $OLD_API_VERSION -> $NEW_API_VERSION" cd ../.. if [[ "$OLD_API_VERSION" != "$NEW_API_VERSION" ]]; then git add api/server/Cargo.toml COMMIT_MESSAGE_PREFIX="$COMMIT_MESSAGE_PREFIX bump api to v$NEW_API_VERSION;" COMMIT_CHANGES=true - echo "::set-output name=new_api_version::$NEW_API_VERSION" + echo "new_api_version=$NEW_API_VERSION" >> $GITHUB_OUTPUT fi fi # Web Version Bump if [[ "$COMPONENT" == "all" || "$COMPONENT" == "web" ]]; then - echo "Bumping Web version..." + echo "Bumping Web version using spec: $VERSION_SPEC..." cd web OLD_WEB_VERSION=$(jq -r .version package.json) npm version "$VERSION_SPEC" --no-git-tag-version --allow-same-version @@ -91,24 +155,24 @@ jobs: git add web/package.json web/package-lock.json # package-lock.json might also change COMMIT_MESSAGE_PREFIX="$COMMIT_MESSAGE_PREFIX bump web to v$NEW_WEB_VERSION;" COMMIT_CHANGES=true - echo "::set-output name=new_web_version::$NEW_WEB_VERSION" + echo "new_web_version=$NEW_WEB_VERSION" >> $GITHUB_OUTPUT fi fi # CLI Version Bump if [[ "$COMPONENT" == "all" || "$COMPONENT" == "cli" ]]; then - echo "Bumping CLI version..." + echo "Bumping CLI version using spec: $VERSION_SPEC..." cd cli/cli - OLD_CLI_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\(.*\)"/\1/') + OLD_CLI_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\\(.*\\)"/\\1/') cargo bump "$VERSION_SPEC" - NEW_CLI_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\(.*\)"/\1/') + NEW_CLI_VERSION=$(grep '^version *=' Cargo.toml | sed 's/version *= *"\\(.*\\)"/\\1/') echo "CLI: $OLD_CLI_VERSION -> $NEW_CLI_VERSION" cd ../.. if [[ "$OLD_CLI_VERSION" != "$NEW_CLI_VERSION" ]]; then git add cli/cli/Cargo.toml COMMIT_MESSAGE_PREFIX="$COMMIT_MESSAGE_PREFIX bump cli to v$NEW_CLI_VERSION;" COMMIT_CHANGES=true - echo "::set-output name=new_cli_version::$NEW_CLI_VERSION" + echo "new_cli_version=$NEW_CLI_VERSION" >> $GITHUB_OUTPUT fi fi @@ -116,21 +180,23 @@ jobs: # Remove trailing semicolon if any FINAL_COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_PREFIX" | sed 's/;$//') echo "Final Commit Message: $FINAL_COMMIT_MESSAGE [skip ci]" - echo "COMMIT_MESSAGE=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_ENV - echo "::set-output name=commit_message::$FINAL_COMMIT_MESSAGE [skip ci]" + echo "COMMIT_MESSAGE_CONTENT=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_ENV + echo "commit_message=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_OUTPUT else echo "No version changes detected." - echo "COMMIT_MESSAGE=" >> $GITHUB_ENV # Ensure it's empty - echo "::set-output name=commit_message::" + echo "COMMIT_MESSAGE_CONTENT=" >> $GITHUB_ENV # Ensure it's empty + echo "commit_message=" >> $GITHUB_OUTPUT fi - echo "New API Version: $NEW_API_VERSION" - echo "New Web Version: $NEW_WEB_VERSION" - echo "New CLI Version: $NEW_CLI_VERSION" + echo "New API Version Output: $NEW_API_VERSION" + echo "New Web Version Output: $NEW_WEB_VERSION" + echo "New CLI Version Output: $NEW_CLI_VERSION" - name: Commit version changes if: steps.bump.outputs.commit_message != '' + env: + COMMIT_MESSAGE_TO_USE: ${{ steps.bump.outputs.commit_message }} run: | - git commit -m "${{ steps.bump.outputs.commit_message }}" + git commit -m "$COMMIT_MESSAGE_TO_USE" - name: Create and Push Tags if: steps.bump.outputs.commit_message != '' # Only tag if there were changes @@ -156,7 +222,13 @@ jobs: git push origin HEAD --follow-tags # Push current branch and all tags - name: Push changes (if only commit, no tags yet or if tag push failed) + # This condition implies commit happened, but no versions were actually outputted. + # This might occur if a bump was attempted but the version didn't change. + # The original condition was: + # if: steps.bump.outputs.commit_message != '' && (steps.bump.outputs.new_api_version == '' && steps.bump.outputs.new_web_version == '' && steps.bump.outputs.new_cli_version == '') + # A simpler way to check if tags were created might be needed or this step might be redundant if --follow-tags is robust. + # For now, keeping the original logic. if: steps.bump.outputs.commit_message != '' && (steps.bump.outputs.new_api_version == '' && steps.bump.outputs.new_web_version == '' && steps.bump.outputs.new_cli_version == '') run: | - echo "Pushing commit without tags..." # Should not happen if logic is correct + echo "Pushing commit because changes were made but no version tags were generated (e.g. version already existed or no actual version change)." git push origin HEAD \ No newline at end of file