chore(deps): update dependency aspect_bazel_lib to v2.13.0 #1242
This file contains 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
name: CI | |
on: | |
workflow_dispatch: | |
inputs: | |
publish: | |
description: 'Publish container images' | |
required: false | |
type: boolean | |
default: false | |
push: | |
branches: | |
- main | |
paths: | |
- '**.go' | |
- '**.bazel' | |
- '.bazelversion' | |
- '.bazelrc' | |
- 'go.mod' | |
- 'go.sum' | |
- 'MODULE.bazel' | |
- 'MODULE.bazel.lock' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- '**.go' | |
- '**.bazel' | |
- '.bazelversion' | |
- '.bazelrc' | |
- 'go.mod' | |
- 'go.sum' | |
- 'MODULE.bazel' | |
- 'MODULE.bazel.lock' | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Mount Bazel cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Fetch dependencies | |
run: bazel fetch //... | |
- name: Build | |
run: bazel build //... | |
- name: Test | |
run: bazel test //... | |
- name: Build Container Images | |
run: | | |
imageTargets=$(bazel query "kind(oci_image, //...)") | |
while IFS=';' read -ra targets; do | |
for target in "${targets[@]}"; do | |
bazel build $target | |
done | |
done <<< "$imageTargets" | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.ref_name == 'main' || inputs.publish }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Generate build version | |
id: info | |
run: | | |
formatted_date=$(date +'%Y.%m.%d') | |
time=$(date +'%H%M%S') | |
short_commit_id=$(git rev-parse --short HEAD) | |
echo "build_version=${formatted_date}.${time}.${short_commit_id}" >> $GITHUB_OUTPUT | |
- name: Mount Bazel cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and publish images | |
run: | | |
pushTargets=$(bazel query "kind(oci_push, //...)") | |
while IFS=';' read -ra targets; do | |
for target in "${targets[@]}"; do | |
bazel run --stamp --embed_label ${{ steps.info.outputs.build_version }} $target | |
done | |
done <<< "$pushTargets" |