Skip to content

Add some debug logs to help diagnose config parsing issues #212

Add some debug logs to help diagnose config parsing issues

Add some debug logs to help diagnose config parsing issues #212

Workflow file for this run

name: "Release CLI"
on:
workflow_dispatch:
pull_request_target:
types:
- closed
paths:
- "cli/**"
jobs:
push-tag:
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && !contains(github.event.pull_request.body, 'release skip'))
runs-on: ubuntu-20.04
outputs:
version: ${{ steps.version.outputs.VERSION }}
steps:
- name: Checkout /buildbuddy
uses: actions/checkout@v3
with:
# We need to fetch git tags to obtain the latest cli version tag.
fetch-depth: 0
- name: Push tag
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions-release[bot]"
./cli/release.py --auto
- name: Get CLI version
id: version
run: |
version=$(git tag -l 'cli-v*' --sort=creatordate |
perl -nle 'if (/^cli-v(\d+\.\d+\.\d+)$/) { print $1 }' |
tail -n1)
echo $version
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
create-release:
runs-on: ubuntu-20.04
needs: push-tag
steps:
- name: Checkout buildbuddy-io/bazel
uses: actions/checkout@v3
with:
repository: buildbuddy-io/bazel
path: bazel-fork
token: ${{ secrets.BUILDBUDDY_GITHUB_USER_TOKEN }}
- name: Create draft release
env:
GITHUB_TOKEN: ${{ secrets.BUILDBUDDY_GITHUB_USER_TOKEN }}
run: |
set -x # print executed commands
if gh release view ${{ needs.push-tag.outputs.version }} --repo=buildbuddy-io/bazel; then
echo "buildbuddy-io/bazel release ${{ needs.push-tag.outputs.version }} already exists."
# It's OK if the release already exists; the build-artifacts job will just overwrite
# any existing artifacts.
exit 0
fi
TAG=${{ needs.push-tag.outputs.version }}
cd "${GITHUB_WORKSPACE}/bazel-fork"
git fetch --all --tags
if [[ "$(git tag -l "$TAG")" ]]; then
echo "Tag $TAG already exists."
else
git tag "$TAG"
git push origin "$TAG"
fi
gh release create "$TAG" \
--repo=buildbuddy-io/bazel --title="$TAG" --draft --notes="Release version $TAG"
sync-plugins:
runs-on: ubuntu-20.04
needs: [push-tag, create-release]
steps:
- name: Checkout buildbuddy-io/buildbuddy
uses: actions/checkout@v3
with:
path: buildbuddy
- name: Checkout buildbuddy-io/plugins
uses: actions/checkout@v3
with:
repository: buildbuddy-io/plugins
path: plugins
token: ${{ secrets.BUILDBUDDY_GITHUB_USER_TOKEN }}
- name: Sync plugins and push version tag
env:
GITHUB_TOKEN: ${{ secrets.BUILDBUDDY_GITHUB_USER_TOKEN }}
VERSION: ${{ needs.push-tag.outputs.version }}
run: |
set -e
cd "${GITHUB_WORKSPACE}/plugins"
git checkout main
git pull
git config --local user.name "BuildBuddy Bot"
git config --local user.email "[email protected]"
# Commit and push changes to cli/plugins dir from buildbuddy repo
# Remove any existing plugin directories in the plugins repo.
# Note, this implementation assumes all top-level directories
# are plugin directories (except the .git directory)
EXISTING_PLUGIN_DIRS=($(find . -mindepth 1 -maxdepth 1 -type d | grep -v './\.git'))
echo "Removing existing plugin dirs:" "${EXISTING_PLUGIN_DIRS[@]}"
rm -rf "${EXISTING_PLUGIN_DIRS[@]}"
# Copy all top-level plugin directories to the top-level of the
# plugins repo.
PLUGIN_DIRS=($(find "${GITHUB_WORKSPACE}/buildbuddy/cli/plugins" -mindepth 1 -maxdepth 1 -type d))
cp -r "${PLUGIN_DIRS[@]}" ./
# Commit and push the plugin dirs.
git add .
commit_output=$(mktemp)
if git commit -m "Update plugins to v${VERSION}" 2>&1 | tee "${commit_output}"; then
git push
elif grep 'nothing to commit' "${commit_output}" &>/dev/null; then
echo "No plugin changes in version $VERSION"
else
echo "Commit failed; exiting"
exit 1
fi
# Push new tag to match CLI release.
TAG="v${VERSION}"
git tag "$TAG"
git push origin "$TAG"
build-artifacts:
strategy:
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04-16cpu-arm64-arm-limited # linux arm64
- os: macos-13 # macOS amd64
- os: macos-13-xlarge # macOS arm64
runs-on: ${{ matrix.os }}
needs: [push-tag, create-release]
steps:
- name: Clean workspace
run: |
set -x
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- name: Checkout
uses: actions/checkout@v3
with:
path: buildbuddy
- name: Build Artifacts
id: build
env:
XCODE_VERSION: 12.4
run: |
set -x # print executed commands
if [[ "$OSTYPE" == darwin* ]]; then
OS=darwin
else
OS=linux
fi
ARCH=$(uname -m)
# bazelisk uses "x86_64" / "arm64" convention
if [[ "$ARCH" == "aarch64" ]]; then
ARCH=arm64
fi
VERSION=${{ needs.push-tag.outputs.version }}
cd "${GITHUB_WORKSPACE}/buildbuddy"
bazelisk build //cli/cmd/bb \
--remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_ORG_API_KEY }} \
--//cli/version:cli_version="$VERSION"
BINARY="bazel-${VERSION}-${OS}-${ARCH}"
cp bazel-bin/cli/cmd/bb/bb_/bb "$BINARY"
shasum -a 256 "$BINARY" > "${BINARY}.sha256"
echo "BINARY=${BINARY}" >> "$GITHUB_OUTPUT"
- name: Upload Artifacts
env:
GITHUB_TOKEN: ${{ secrets.BUILDBUDDY_GITHUB_USER_TOKEN }}
run: |
set -x # print executed commands
cd "${GITHUB_WORKSPACE}/buildbuddy"
gh release upload \
--repo buildbuddy-io/bazel \
--clobber \
"${{ needs.push-tag.outputs.version }}" \
"${{ steps.build.outputs.BINARY }}" \
"${{ steps.build.outputs.BINARY }}.sha256"
publish-release:
runs-on: ubuntu-20.04
needs: [push-tag, sync-plugins, build-artifacts]
steps:
- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.BUILDBUDDY_GITHUB_USER_TOKEN }}
run: |
gh release edit ${{ needs.push-tag.outputs.version }} --draft=false --repo=buildbuddy-io/bazel