mirror of https://github.com/buster-so/buster.git
ok tag triggers
This commit is contained in:
parent
d3dc471327
commit
5ab8c65da4
|
@ -1,29 +1,18 @@
|
||||||
name: CLI Release
|
name: CLI Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
push:
|
||||||
workflows: ["Manage Versions"]
|
tags:
|
||||||
types:
|
- 'cli/v*' # Trigger on tags like cli/v1.2.3
|
||||||
- completed
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
manage_versions_run_id:
|
|
||||||
description: 'Run ID of the completed "Manage Versions" workflow (that produced version-tag-info artifact)'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
checkout_sha:
|
|
||||||
description: 'Commit SHA to checkout (ideally the head_sha from the Manage Versions run)'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
# Add permissions for creating releases
|
# Add permissions for creating releases
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
# pull-requests: write # Not typically needed for a tag-triggered release workflow
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'workflow_dispatch'
|
# No specific if condition needed here based on event, tag push is the trigger
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
@ -45,11 +34,11 @@ jobs:
|
||||||
use_tar: false
|
use_tar: false
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code at the specific tag
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.checkout_sha || github.event.workflow_run.head_sha }}
|
ref: ${{ github.ref }} # Checks out the specific tag that triggered the workflow
|
||||||
fetch-depth: 0
|
fetch-depth: 0 # Useful for some build processes or if release notes need history
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
@ -81,12 +70,34 @@ jobs:
|
||||||
id: binary_info
|
id: binary_info
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
CRATE_NAME=$(basename $(find cli/target/${{ matrix.target }}/release -maxdepth 1 -type f -executable ! -name '*.dSYM' ! -name '*.pdb'))
|
# Ensure cli/target directory exists before find, in case of clean builds or different structures
|
||||||
echo "CRATE_NAME=$CRATE_NAME"
|
mkdir -p cli/target/${{ matrix.target }}/release
|
||||||
echo "Binary name: $CRATE_NAME"
|
CRATE_NAME_OUTPUT=$(basename $(find cli/target/${{ matrix.target }}/release -maxdepth 1 -type f -executable ! -name '*.dSYM' ! -name '*.pdb' 2>/dev/null || echo "buster")) # Default to buster if not found
|
||||||
echo "binary_name=$CRATE_NAME" >> $GITHUB_OUTPUT
|
# If find returns nothing (e.g. build failed or path is wrong), CRATE_NAME_OUTPUT could be empty or an error message.
|
||||||
echo "binary_path=cli/target/${{ matrix.target }}/release/$CRATE_NAME"
|
# Fallback to a known name or fail if necessary. For now, using "buster" as a placeholder.
|
||||||
echo "binary_path_val=cli/target/${{ matrix.target }}/release/$CRATE_NAME" >> $GITHUB_OUTPUT
|
if [ -z "$CRATE_NAME_OUTPUT" ] || ! [ -f "cli/target/${{ matrix.target }}/release/$CRATE_NAME_OUTPUT" ]; then
|
||||||
|
echo "Warning: Could not automatically determine binary name. Assuming 'buster'."
|
||||||
|
# Attempt to find 'buster' or 'buster.exe' directly if primary find fails
|
||||||
|
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
|
||||||
|
CRATE_NAME_CANDIDATE="buster.exe"
|
||||||
|
else
|
||||||
|
CRATE_NAME_CANDIDATE="buster"
|
||||||
|
fi
|
||||||
|
if [ -f "cli/target/${{ matrix.target }}/release/$CRATE_NAME_CANDIDATE" ]; then
|
||||||
|
CRATE_NAME_OUTPUT=$CRATE_NAME_CANDIDATE
|
||||||
|
else
|
||||||
|
# If even the fallback isn't found, this will cause issues later.
|
||||||
|
# Consider failing the step: echo "Error: Binary not found."; exit 1
|
||||||
|
# For now, proceeding with a default name and letting later steps handle missing file
|
||||||
|
echo "Fallback binary '$CRATE_NAME_CANDIDATE' also not found. Proceeding with this name."
|
||||||
|
CRATE_NAME_OUTPUT=${CRATE_NAME_CANDIDATE%.exe} # Store without .exe for consistency if needed elsewhere
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "CRATE_NAME=$CRATE_NAME_OUTPUT"
|
||||||
|
echo "Binary name: $CRATE_NAME_OUTPUT"
|
||||||
|
echo "binary_name=$CRATE_NAME_OUTPUT" >> $GITHUB_OUTPUT
|
||||||
|
echo "binary_path=cli/target/${{ matrix.target }}/release/$CRATE_NAME_OUTPUT"
|
||||||
|
echo "binary_path_val=cli/target/${{ matrix.target }}/release/$CRATE_NAME_OUTPUT" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Compress binary (Unix)
|
- name: Compress binary (Unix)
|
||||||
if: matrix.use_tar
|
if: matrix.use_tar
|
||||||
|
@ -120,63 +131,44 @@ jobs:
|
||||||
release:
|
release:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'workflow_dispatch'
|
# No specific if condition needed here based on event, tag push is the trigger
|
||||||
outputs:
|
outputs:
|
||||||
release_tag: ${{ steps.get_tag_info.outputs.cli_tag_name }}
|
release_tag: ${{ steps.get_tag_info.outputs.cli_tag_name }}
|
||||||
release_version: ${{ steps.get_tag_info.outputs.cli_version }}
|
release_version: ${{ steps.get_tag_info.outputs.cli_version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code at the specific tag
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.checkout_sha || github.event.workflow_run.head_sha }}
|
ref: ${{ github.ref }} # Checks out the specific tag that triggered the workflow
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Download Tag Information Artifact
|
- name: Extract CLI Tag and Version from Git Ref
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: version-tag-info
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run-id: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.manage_versions_run_id || github.event.workflow_run.id }}
|
|
||||||
|
|
||||||
- name: Extract CLI Tag and Version from Artifact
|
|
||||||
id: get_tag_info
|
id: get_tag_info
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f tag_info.json ]; then
|
CLI_TAG_NAME="${{ github.ref_name }}"
|
||||||
echo "tag_info.json not found. This might happen if no tags were created by the Manage Versions workflow."
|
# Validate tag format if necessary (e.g., ensure it starts with cli/v)
|
||||||
# Decide if this is a critical failure or if the workflow should exit gracefully
|
if [[ ! "$CLI_TAG_NAME" =~ ^cli/v[0-9]+\.[0-9]+\.[0-9]+(.*)$ ]]; then
|
||||||
# For now, we'll set outputs to empty and let downstream steps handle it (e.g. Create Release might skip)
|
echo "Error: Tag $CLI_TAG_NAME does not match the expected format 'cli/vX.Y.Z'"
|
||||||
echo "cli_tag_name=" >> $GITHUB_OUTPUT
|
# exit 1 # Optionally fail the job
|
||||||
echo "cli_version=" >> $GITHUB_OUTPUT
|
# For now, we'll proceed and let release creation fail if tag is not suitable
|
||||||
exit 0 # Exit gracefully to allow other jobs or steps to evaluate
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CLI_TAG_NAME=$(jq -r '.cli_tag // empty' tag_info.json)
|
|
||||||
|
|
||||||
if [ -z "$CLI_TAG_NAME" ] || [ "$CLI_TAG_NAME" == "null" ]; then
|
|
||||||
echo "CLI tag not found in tag_info.json or is null."
|
|
||||||
# As above, decide on failure or graceful exit
|
|
||||||
echo "cli_tag_name=" >> $GITHUB_OUTPUT
|
|
||||||
echo "cli_version=" >> $GITHUB_OUTPUT
|
|
||||||
exit 0 # Exit gracefully
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Extract version from the tag name (e.g., cli/v1.2.3 -> 1.2.3)
|
|
||||||
CLI_VERSION=$(echo "$CLI_TAG_NAME" | sed 's#^cli/v##')
|
CLI_VERSION=$(echo "$CLI_TAG_NAME" | sed 's#^cli/v##')
|
||||||
|
|
||||||
echo "cli_tag_name=$CLI_TAG_NAME" >> $GITHUB_OUTPUT
|
echo "cli_tag_name=$CLI_TAG_NAME" >> $GITHUB_OUTPUT
|
||||||
echo "cli_version=$CLI_VERSION" >> $GITHUB_OUTPUT
|
echo "cli_version=$CLI_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "Extracted CLI Tag: $CLI_TAG_NAME, CLI Version: $CLI_VERSION"
|
echo "Extracted from Git Ref - CLI Tag: $CLI_TAG_NAME, CLI Version: $CLI_VERSION"
|
||||||
|
|
||||||
- name: Download build artifacts
|
- name: Download build artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
# No specific path needed, it downloads all to a directory named after the artifact
|
# No specific path needed, it downloads all to a directory named after the artifact
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
if: steps.get_tag_info.outputs.cli_tag_name != '' # Only run if a CLI tag was found
|
# if: steps.get_tag_info.outputs.cli_tag_name != '' # This check is implicitly handled by the tag trigger pattern
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_tag_info.outputs.cli_tag_name }}
|
tag_name: ${{ steps.get_tag_info.outputs.cli_tag_name }} # Should be same as github.ref_name
|
||||||
name: CLI Release v${{ steps.get_tag_info.outputs.cli_version }}
|
name: CLI Release v${{ steps.get_tag_info.outputs.cli_version }}
|
||||||
files: |
|
files: |
|
||||||
**/buster-cli-linux-x86_64.tar.gz
|
**/buster-cli-linux-x86_64.tar.gz
|
||||||
|
@ -197,7 +189,7 @@ jobs:
|
||||||
name: Update Homebrew Tap
|
name: Update Homebrew Tap
|
||||||
needs: release
|
needs: release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event.workflow_run.conclusion == 'success' && needs.release.outputs.release_tag != '' # Run only if Manage Versions succeeded and a CLI tag was processed
|
if: needs.release.outputs.release_tag != '' # Run only if a CLI tag was processed and release was attempted
|
||||||
steps:
|
steps:
|
||||||
- name: Get release version and tag from previous job
|
- name: Get release version and tag from previous job
|
||||||
id: release_info
|
id: release_info
|
||||||
|
|
|
@ -18,8 +18,10 @@ jobs:
|
||||||
if: startsWith(github.ref, 'refs/tags/api/v') # Trigger only for API tags
|
if: startsWith(github.ref, 'refs/tags/api/v') # Trigger only for API tags
|
||||||
runs-on: blacksmith-32vcpu-ubuntu-2204 # Updated runner
|
runs-on: blacksmith-32vcpu-ubuntu-2204 # Updated runner
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code at the specific tag
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }} # Checks out the specific API tag
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
@ -28,16 +30,16 @@ jobs:
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Extract API version from Git tag
|
- name: Extract API version from Git tag
|
||||||
id: api_version
|
id: api_version_extractor # Renamed for clarity
|
||||||
run: |
|
run: |
|
||||||
# github.ref_name will be like "api/v1.2.3"
|
# github.ref_name will be like "api/v1.2.3"
|
||||||
VERSION=$(echo "${{ github.ref_name }}" | sed 's#^api/v##')
|
VERSION=$(echo "${{ github.ref_name }}" | sed 's#^api/v##')
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then # Should not happen due to startsWith condition
|
||||||
echo "Could not extract version from tag: ${{ github.ref_name }}"
|
echo "Could not extract version from tag: ${{ github.ref_name }}"
|
||||||
VERSION="unknown" # Fallback or fail: exit 1
|
VERSION="unknown"
|
||||||
fi
|
fi
|
||||||
echo "API_VERSION=$VERSION" >> $GITHUB_ENV
|
echo "API_VERSION_ENV=$VERSION" >> $GITHUB_ENV # Set for current job
|
||||||
echo "api_version=$VERSION" >> $GITHUB_OUTPUT
|
echo "api_version_output=$VERSION" >> $GITHUB_OUTPUT # Output for other steps if needed
|
||||||
echo "Extracted API version: $VERSION"
|
echo "Extracted API version: $VERSION"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
@ -55,8 +57,8 @@ jobs:
|
||||||
file: ./api/Dockerfile # Assuming this Dockerfile is for api/server
|
file: ./api/Dockerfile # Assuming this Dockerfile is for api/server
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:${{ steps.api_version.outputs.api_version }}
|
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:${{ env.API_VERSION_ENV }}
|
||||||
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:${{ github.sha }} # Consider if SHA tag is still needed or if component-specific SHA makes sense
|
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:${{ github.sha }} # SHA of the tag commit
|
||||||
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:latest
|
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.API_IMAGE_NAME }}:latest
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
@ -66,8 +68,10 @@ jobs:
|
||||||
if: startsWith(github.ref, 'refs/tags/web/v') # Trigger only for Web tags
|
if: startsWith(github.ref, 'refs/tags/web/v') # Trigger only for Web tags
|
||||||
runs-on: blacksmith-32vcpu-ubuntu-2204 # Updated runner
|
runs-on: blacksmith-32vcpu-ubuntu-2204 # Updated runner
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code at the specific tag
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }} # Checks out the specific Web tag
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
@ -76,16 +80,16 @@ jobs:
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Extract Web version from Git tag
|
- name: Extract Web version from Git tag
|
||||||
id: web_version
|
id: web_version_extractor # Renamed for clarity
|
||||||
run: |
|
run: |
|
||||||
# github.ref_name will be like "web/v1.2.3"
|
# github.ref_name will be like "web/v1.2.3"
|
||||||
VERSION=$(echo "${{ github.ref_name }}" | sed 's#^web/v##')
|
VERSION=$(echo "${{ github.ref_name }}" | sed 's#^web/v##')
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then # Should not happen due to startsWith condition
|
||||||
echo "Could not extract version from tag: ${{ github.ref_name }}"
|
echo "Could not extract version from tag: ${{ github.ref_name }}"
|
||||||
VERSION="unknown" # Fallback or fail: exit 1
|
VERSION="unknown"
|
||||||
fi
|
fi
|
||||||
echo "WEB_VERSION=$VERSION" >> $GITHUB_ENV
|
echo "WEB_VERSION_ENV=$VERSION" >> $GITHUB_ENV # Set for current job
|
||||||
echo "web_version=$VERSION" >> $GITHUB_OUTPUT
|
echo "web_version_output=$VERSION" >> $GITHUB_OUTPUT # Output for other steps if needed
|
||||||
echo "Extracted Web version: $VERSION"
|
echo "Extracted Web version: $VERSION"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
@ -103,8 +107,8 @@ jobs:
|
||||||
file: ./web/Dockerfile
|
file: ./web/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:${{ steps.web_version.outputs.web_version }}
|
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:${{ env.WEB_VERSION_ENV }}
|
||||||
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:${{ github.sha }} # Consider if SHA tag is still needed
|
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:${{ github.sha }} # SHA of the tag commit
|
||||||
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:latest
|
${{ env.DOCKER_REGISTRY_OWNER }}/${{ env.WEB_IMAGE_NAME }}:latest
|
||||||
build-args: |
|
build-args: |
|
||||||
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
|
NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
name: Manage Versions
|
name: Manage Versions
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
component:
|
component:
|
||||||
|
@ -18,9 +22,6 @@ on:
|
||||||
required: true
|
required: true
|
||||||
default: 'patch'
|
default: 'patch'
|
||||||
type: string
|
type: string
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- evals # Target the 'evals' branch
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # To push commits and tags
|
contents: write # To push commits and tags
|
||||||
|
@ -28,34 +29,41 @@ permissions:
|
||||||
jobs:
|
jobs:
|
||||||
bump_versions:
|
bump_versions:
|
||||||
runs-on: blacksmith
|
runs-on: blacksmith
|
||||||
# Updated condition to run if PR is opened or on workflow_dispatch
|
if: (github.event_name == 'pull_request' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch'
|
||||||
if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
|
|
||||||
outputs:
|
outputs:
|
||||||
new_api_version: ${{ steps.bump.outputs.new_api_version }}
|
new_api_version: ${{ steps.bump.outputs.new_api_version }}
|
||||||
new_web_version: ${{ steps.bump.outputs.new_web_version }}
|
new_web_version: ${{ steps.bump.outputs.new_web_version }}
|
||||||
new_cli_version: ${{ steps.bump.outputs.new_cli_version }}
|
new_cli_version: ${{ steps.bump.outputs.new_cli_version }}
|
||||||
|
api_tag_created: ${{ steps.tag.outputs.api_tag_created }}
|
||||||
|
web_tag_created: ${{ steps.tag.outputs.web_tag_created }}
|
||||||
|
cli_tag_created: ${{ steps.tag.outputs.cli_tag_created }}
|
||||||
steps:
|
steps:
|
||||||
- name: Determine Branch Name
|
- name: Determine Branch Name and SHA
|
||||||
id: branch_info
|
id: branch_info
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||||
echo "branch_name=${{ github.head_ref }}" >> $GITHUB_OUTPUT
|
echo "branch_name=${{ github.event.pull_request.base.ref }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "checkout_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
|
||||||
|
echo "branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "checkout_sha=${{ github.sha }}" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
echo "branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "checkout_sha=${{ github.sha }}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ steps.branch_info.outputs.branch_name }}
|
ref: ${{ github.sha }}
|
||||||
token: ${{ secrets.GITHUB_TOKEN }} # Or a PAT if you push to protected branches from actions
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
fetch-depth: 0 # For git tagging and history
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20' # Specify a Node.js version
|
node-version: '20'
|
||||||
|
|
||||||
- name: Set up Rust toolchain
|
- name: Set up Rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
@ -85,14 +93,32 @@ jobs:
|
||||||
VERSION_SPEC="${{ github.event.inputs.version_spec }}"
|
VERSION_SPEC="${{ github.event.inputs.version_spec }}"
|
||||||
COMPONENT="${{ github.event.inputs.component }}"
|
COMPONENT="${{ github.event.inputs.component }}"
|
||||||
echo "Using workflow_dispatch inputs: version_spec='$VERSION_SPEC', component='$COMPONENT'"
|
echo "Using workflow_dispatch inputs: version_spec='$VERSION_SPEC', component='$COMPONENT'"
|
||||||
|
elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
|
||||||
|
PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
echo "Pull Request title (lowercase): $PR_TITLE"
|
||||||
|
COMPONENT="all"
|
||||||
|
|
||||||
|
if echo "$PR_TITLE" | grep -q -E "breaking change|feat!:"; then
|
||||||
|
VERSION_SPEC="major"
|
||||||
|
elif echo "$PR_TITLE" | grep -q -E "^feat\\([^)]+\\)!:"; then
|
||||||
|
VERSION_SPEC="major"
|
||||||
|
elif echo "$PR_TITLE" | grep -q -E "^feat:"; then
|
||||||
|
VERSION_SPEC="minor"
|
||||||
|
elif echo "$PR_TITLE" | grep -q -E "^fix:"; then
|
||||||
|
VERSION_SPEC="patch"
|
||||||
|
else
|
||||||
|
echo "No major/minor/fix keyword found in PR title. Defaulting to patch for merged PR."
|
||||||
|
VERSION_SPEC="patch"
|
||||||
|
fi
|
||||||
|
echo "Determined for PR merge: version_spec='$VERSION_SPEC', component='$COMPONENT'"
|
||||||
elif [[ "${{ github.event_name }}" == "push" ]]; then
|
elif [[ "${{ github.event_name }}" == "push" ]]; then
|
||||||
COMMIT_MESSAGE_TEXT=$(echo "${{ github.event.head_commit.message }}" | tr '[:upper:]' '[:lower:]')
|
COMMIT_MESSAGE_TEXT=$(echo "${{ github.event.head_commit.message }}" | tr '[:upper:]' '[:lower:]')
|
||||||
echo "Push event. Analyzing commit message (lowercase): $COMMIT_MESSAGE_TEXT"
|
echo "Push event. Analyzing commit message (lowercase): $COMMIT_MESSAGE_TEXT"
|
||||||
COMPONENT="all" # Default component for push events
|
COMPONENT="all"
|
||||||
|
|
||||||
if echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "breaking change|feat!:"; then
|
if echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "breaking change|feat!:"; then
|
||||||
VERSION_SPEC="major"
|
VERSION_SPEC="major"
|
||||||
elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^feat\\([^)]+\\)!:"; then # e.g., feat(scope)!:
|
elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^feat\\([^)]+\\)!:"; then
|
||||||
VERSION_SPEC="major"
|
VERSION_SPEC="major"
|
||||||
elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^feat:"; then
|
elif echo "$COMMIT_MESSAGE_TEXT" | grep -q -E "^feat:"; then
|
||||||
VERSION_SPEC="minor"
|
VERSION_SPEC="minor"
|
||||||
|
@ -141,7 +167,6 @@ jobs:
|
||||||
NEW_WEB_VERSION=""
|
NEW_WEB_VERSION=""
|
||||||
NEW_CLI_VERSION=""
|
NEW_CLI_VERSION=""
|
||||||
|
|
||||||
# API Version Bump
|
|
||||||
if [[ "$COMPONENT" == "all" || "$COMPONENT" == "api" ]]; then
|
if [[ "$COMPONENT" == "all" || "$COMPONENT" == "api" ]]; then
|
||||||
echo "Processing API version using spec: $VERSION_SPEC..."
|
echo "Processing API version using spec: $VERSION_SPEC..."
|
||||||
cd api/server
|
cd api/server
|
||||||
|
@ -165,25 +190,22 @@ jobs:
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Web Version Bump
|
|
||||||
if [[ "$COMPONENT" == "all" || "$COMPONENT" == "web" ]]; then
|
if [[ "$COMPONENT" == "all" || "$COMPONENT" == "web" ]]; then
|
||||||
echo "Bumping Web version using spec: $VERSION_SPEC..."
|
echo "Bumping Web version using spec: $VERSION_SPEC..."
|
||||||
cd web
|
cd web
|
||||||
OLD_WEB_VERSION=$(jq -r .version package.json)
|
OLD_WEB_VERSION=$(jq -r .version package.json)
|
||||||
# npm version can handle bump types and specific versions directly
|
|
||||||
npm version "$VERSION_SPEC" --no-git-tag-version --allow-same-version
|
npm version "$VERSION_SPEC" --no-git-tag-version --allow-same-version
|
||||||
NEW_WEB_VERSION=$(jq -r .version package.json)
|
NEW_WEB_VERSION=$(jq -r .version package.json)
|
||||||
echo "Web: $OLD_WEB_VERSION -> $NEW_WEB_VERSION"
|
echo "Web: $OLD_WEB_VERSION -> $NEW_WEB_VERSION"
|
||||||
cd ..
|
cd ..
|
||||||
if [[ "$OLD_WEB_VERSION" != "$NEW_WEB_VERSION" ]]; then
|
if [[ "$OLD_WEB_VERSION" != "$NEW_WEB_VERSION" ]]; then
|
||||||
git add web/package.json web/package-lock.json # package-lock.json might also change
|
git add web/package.json web/package-lock.json
|
||||||
COMMIT_MESSAGE_PREFIX="$COMMIT_MESSAGE_PREFIX bump web to v$NEW_WEB_VERSION;"
|
COMMIT_MESSAGE_PREFIX="$COMMIT_MESSAGE_PREFIX bump web to v$NEW_WEB_VERSION;"
|
||||||
COMMIT_CHANGES=true
|
COMMIT_CHANGES=true
|
||||||
echo "new_web_version=$NEW_WEB_VERSION" >> $GITHUB_OUTPUT
|
echo "new_web_version=$NEW_WEB_VERSION" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# CLI Version Bump
|
|
||||||
if [[ "$COMPONENT" == "all" || "$COMPONENT" == "cli" ]]; then
|
if [[ "$COMPONENT" == "all" || "$COMPONENT" == "cli" ]]; then
|
||||||
echo "Processing CLI version using spec: $VERSION_SPEC..."
|
echo "Processing CLI version using spec: $VERSION_SPEC..."
|
||||||
cd cli/cli
|
cd cli/cli
|
||||||
|
@ -208,14 +230,13 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$COMMIT_CHANGES" == true ]]; then
|
if [[ "$COMMIT_CHANGES" == true ]]; then
|
||||||
# Remove trailing semicolon if any
|
|
||||||
FINAL_COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_PREFIX" | sed 's/;$//')
|
FINAL_COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE_PREFIX" | sed 's/;$//')
|
||||||
echo "Final Commit Message: $FINAL_COMMIT_MESSAGE [skip ci]"
|
echo "Final Commit Message: $FINAL_COMMIT_MESSAGE [skip ci]"
|
||||||
echo "COMMIT_MESSAGE_CONTENT=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_ENV
|
echo "COMMIT_MESSAGE_CONTENT=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_ENV
|
||||||
echo "commit_message=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_OUTPUT
|
echo "commit_message=$FINAL_COMMIT_MESSAGE [skip ci]" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "No version changes detected."
|
echo "No version changes detected."
|
||||||
echo "COMMIT_MESSAGE_CONTENT=" >> $GITHUB_ENV # Ensure it's empty
|
echo "COMMIT_MESSAGE_CONTENT=" >> $GITHUB_ENV
|
||||||
echo "commit_message=" >> $GITHUB_OUTPUT
|
echo "commit_message=" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
echo "New API Version Output: $NEW_API_VERSION"
|
echo "New API Version Output: $NEW_API_VERSION"
|
||||||
|
@ -230,11 +251,11 @@ jobs:
|
||||||
git commit -m "$COMMIT_MESSAGE_TO_USE"
|
git commit -m "$COMMIT_MESSAGE_TO_USE"
|
||||||
|
|
||||||
- name: Create and Push Tags
|
- name: Create and Push Tags
|
||||||
if: steps.bump.outputs.commit_message != '' # Only tag if there were changes
|
if: steps.bump.outputs.commit_message != ''
|
||||||
run: |
|
run: |
|
||||||
echo "Creating and pushing tags..."
|
echo "Creating and pushing tags..."
|
||||||
TAG_INFO_FILE="tag_info.json"
|
TAG_INFO_FILE="tag_info.json"
|
||||||
echo "{" > $TAG_INFO_FILE # Start JSON object
|
echo "{" > $TAG_INFO_FILE
|
||||||
FIRST_TAG=true
|
FIRST_TAG=true
|
||||||
|
|
||||||
NEW_API_VERSION="${{ steps.bump.outputs.new_api_version }}"
|
NEW_API_VERSION="${{ steps.bump.outputs.new_api_version }}"
|
||||||
|
@ -266,7 +287,7 @@ jobs:
|
||||||
FIRST_TAG=false
|
FIRST_TAG=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "}" >> $TAG_INFO_FILE # End JSON object
|
echo "}" >> $TAG_INFO_FILE
|
||||||
echo "Created tag info file:"
|
echo "Created tag info file:"
|
||||||
cat $TAG_INFO_FILE
|
cat $TAG_INFO_FILE
|
||||||
|
|
||||||
|
@ -274,8 +295,12 @@ jobs:
|
||||||
echo "Pushing commit and tags to branch: $BRANCH_TO_PUSH"
|
echo "Pushing commit and tags to branch: $BRANCH_TO_PUSH"
|
||||||
git push origin HEAD:"refs/heads/$BRANCH_TO_PUSH" --follow-tags
|
git push origin HEAD:"refs/heads/$BRANCH_TO_PUSH" --follow-tags
|
||||||
|
|
||||||
|
echo "api_tag_created=$API_TAG_CREATED" >> $GITHUB_OUTPUT
|
||||||
|
echo "web_tag_created=$WEB_TAG_CREATED" >> $GITHUB_OUTPUT
|
||||||
|
echo "cli_tag_created=$CLI_TAG_CREATED" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Upload Tag Information Artifact
|
- name: Upload Tag Information Artifact
|
||||||
if: steps.bump.outputs.commit_message != '' && (steps.bump.outputs.new_api_version != '' || steps.bump.outputs.new_web_version != '' || steps.bump.outputs.new_cli_version != '')
|
if: steps.tag.outputs.api_tag_created == 'true' || steps.tag.outputs.web_tag_created == 'true' || steps.tag.outputs.cli_tag_created == 'true'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: version-tag-info
|
name: version-tag-info
|
||||||
|
@ -283,12 +308,6 @@ jobs:
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
- name: Push changes (if only commit, no tags yet or if tag push failed)
|
- 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 == '')
|
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: |
|
run: |
|
||||||
BRANCH_TO_PUSH="${{ steps.branch_info.outputs.branch_name }}"
|
BRANCH_TO_PUSH="${{ steps.branch_info.outputs.branch_name }}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "buster_server"
|
name = "buster_server"
|
||||||
version = "0.1.5"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "buster_server"
|
default-run = "buster_server"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "buster-cli"
|
name = "buster-cli"
|
||||||
version = "0.1.5"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "web",
|
"name": "web",
|
||||||
"version": "0.1.5",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --turbo",
|
"dev": "next dev --turbo",
|
||||||
|
|
Loading…
Reference in New Issue