Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ on:
description: "Create GitHub release"
type: boolean
default: false
version:
description: "Release version"
ref:
description: "Release version ref"
required: false
type: string

Expand All @@ -35,6 +35,8 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- uses: actions/cache@v4
with:
path: |
Expand All @@ -54,6 +56,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- uses: actions/cache@v4
with:
path: |
Expand All @@ -62,6 +66,12 @@ jobs:
key: bazel-${{ hashFiles('common.bazelrc', '.bazelrc', '.bazelversion', 'WORKSPACE', 'MODULE.bazel', 'requirements.txt') }}
restore-keys: bazel-
- run: bazel/tools/update_version_bzl.sh version.bzl
- name: Read version
id: version
run: echo "value=$(bazelisk run //:version)" >> $GITHUB_OUTPUT
- name: Echo version
run: echo ${{ steps.version.outputs.value }}

- run: bazelisk build --stamp "--platforms=@rules_go//go/toolchain:${{ matrix.os }}_${{ matrix.arch }}" //agent/cmd/agent //tools/nbictl/cmd/nbictl

- name: Package binary
Expand All @@ -87,6 +97,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- uses: actions/cache@v4
with:
path: |
Expand All @@ -106,23 +118,26 @@ jobs:
needs: [build-and-upload-tools]
runs-on: ubuntu-latest
if: |
github.event_name == 'workflow_dispatch' &&
inputs.create_release == true &&
inputs.version != ''

startsWith( github.ref, 'refs/heads/release-' ) ||
(github.event_name == 'workflow_dispatch' && inputs.create_release == true && inputs.ref != '')
steps:
- uses: actions/checkout@v4

with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: tools-*

- run: bazel/tools/update_version_bzl.sh version.bzl
- name: Read version
id: version
run: echo "value=$(bazelisk run //:version)" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: Release ${{ inputs.version }}
tag_name: v${{ steps.version.outputs.value }}
name: Release v${{ steps.version.outputs.value }}
# TODO: Change to non-draft after testing.
draft: true
files: |
Expand Down
9 changes: 9 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ gazelle_test(
tags = ["manual"],
workspace = "//:BUILD",
)

load("//:version.bzl", "VERSION")

genrule(
name = "version",
outs = ["print_version.sh"],
cmd = "echo '#!/bin/bash\necho " + VERSION + "' > $@",
executable = True,
)
2 changes: 2 additions & 0 deletions bazel/tools/update_version_bzl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ PATCH = ${git_data[1]}" "$versions_bzl_file_path"

sed -i "/^BUILD = /c\\
BUILD = \"${git_data[0]}\"" "$versions_bzl_file_path"

#FIXME