Skip to content

Commit bd0cd8e

Browse files
New release workflow (UBC-Thunderbots#3566)
* add tar to bazel build * clean commit history * add arm compilation * multi platform build * rerun release * rerun release * comment out macos option * bugfix * another bugfix * Add TODO for MacOS support Added a TODO comment to indicate future MacOS support. * remove tar from main build * remove tar from test builds * fix * fix tests * adjust file location * debug msgs * add trigger * testing * testing * testing * testing * fixed * add cron * rebase and update * fixes * fixes * fixes * fixes * fixes * fixes * fixes * remove old bazel commands * cron * cron and manual and versioning * delete old tar * Test * delete comments * add comment * reenable cron * remove on push * fux * add macos support * add macos build to github actions * fix * fix * debug * fix * better release notes * fix * fix * fix * add format * [pre-commit.ci lite] apply automatic fixes * fix * fix * tag input logic * fix race condition * fix race condition * fix race condition * fix race condition * fix race condition * fix * another fix * fixes * fixes * more fixes * please work * whitespace * Revert "please work" This reverts commit 7d13953. * Revert "more fixes" This reverts commit badca35. * rainbow * some crazy changes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent b6484da commit bd0cd8e

7 files changed

Lines changed: 197 additions & 7 deletions

File tree

.github/actions/environment-setup/action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
name: Environment Setup
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
210
runs:
311
using: "composite"
412
steps:
@@ -10,8 +18,15 @@ runs:
1018
sudo rm -rf /usr/share/dotnet
1119
sudo rm -rf /usr/local/lib/android
1220
sudo rm -rf /opt/ghc
13-
21+
1422
- name: Run setup_software.sh
1523
shell: bash
24+
if: runner.os == 'Linux'
1625
run: |
1726
"${GITHUB_WORKSPACE}"/environment_setup/setup_software.sh
27+
28+
- name: Run setup_software_mac.sh
29+
shell: bash
30+
if: runner.os == 'macOS'
31+
run: |
32+
"${GITHUB_WORKSPACE}"/environment_setup/setup_software_mac.sh

.github/release-drafter.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
2+
name-template: 'v$RESOLVED_VERSION'
3+
tag-template: 'v$RESOLVED_VERSION'
4+
change-title-escapes: '\<*_&'
5+
exclude-labels:
6+
- 'skip-changelog'
7+
8+
template: |
9+
## Changes
10+
11+
$CHANGES

.github/workflows/main.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
-//software/ai/hl/... \
3232
-//software/field_tests/... \
3333
-//software/embedded/... \
34-
-//toolchains/cc/...
34+
-//toolchains/cc/... \
35+
-//software:unix_full_system_tar_gen
3536
3637
- name: Jetson Nano Build Test
3738
run: |
@@ -60,7 +61,8 @@ jobs:
6061
-//software/ai/hl/... \
6162
-//software/field_tests/... \
6263
-//software/ai/navigator/... \
63-
-//toolchains/cc/...
64+
-//toolchains/cc/... \
65+
-//software:unix_full_system_tar_gen
6466
6567
robot-tests:
6668
name: Robot Software Tests
@@ -108,8 +110,8 @@ jobs:
108110
//software:unix_full_system \
109111
//software/simulated_tests/... \
110112
//software/ai/hl/... \
111-
//software/ai/navigator/...
112-
113+
//software/ai/navigator/...
114+
113115
- name: Upload simulated test proto logs
114116
# Ensure that simulated test logs get uploaded
115117
if: always()

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Release binary
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0' # Weekly Patch (Sundays)
6+
- cron: '0 0 1 * *' # Monthly Minor (1st of the month)
7+
workflow_dispatch:
8+
inputs:
9+
version_type:
10+
description: 'Manual Release Level'
11+
required: true
12+
default: 'major'
13+
type: choice
14+
options:
15+
- major
16+
- minor
17+
- patch
18+
release_tag:
19+
description: 'Specify the new release tag name (e.g., v1.2.3)'
20+
required: false
21+
type: string
22+
23+
target_commit:
24+
description: 'Optional commit SHA/branch to release (leave empty for current HEAD)'
25+
required: false
26+
type: string
27+
default: ''
28+
29+
jobs:
30+
prepare_release:
31+
runs-on: ubuntu-latest
32+
outputs:
33+
tag: ${{ steps.bump_logic.outputs.tag }}
34+
should_release: ${{ steps.check.outputs.count > 0 }}
35+
permissions:
36+
contents: write
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
ref: ${{ github.event.inputs.target_commit || github.sha }}
42+
43+
- name: Check for recent commits
44+
id: check
45+
run: |
46+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
47+
echo "count=1" >> $GITHUB_OUTPUT
48+
else
49+
COUNT=$(git log --since="1 week ago" --oneline | wc -l)
50+
echo "count=$COUNT" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Determine Version Bump
54+
if: steps.check.outputs.count > 0
55+
id: bump_logic
56+
run: |
57+
if [ "${{ github.event.inputs.release_tag }}" = "" ]; then
58+
BUMP="patch"
59+
if [ "$(date +%d)" = "01" ]; then BUMP="minor"; fi
60+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
61+
BUMP="${{ github.event.inputs.version_type }}"
62+
fi
63+
64+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")
65+
# Strip the 'v' prefix
66+
BASE_VERSION=${LATEST_TAG#v}
67+
68+
IFS='.' read -r major minor patch <<< "$BASE_VERSION"
69+
70+
if [ "$BUMP" = "major" ]; then
71+
major=$((major + 1)); minor=0; patch=0
72+
elif [ "$BUMP" = "minor" ]; then
73+
minor=$((minor + 1)); patch=0
74+
else
75+
patch=$((patch + 1))
76+
fi
77+
78+
NEW_TAG="v$major.$minor.$patch"
79+
else
80+
NEW_TAG="${{ github.event.inputs.release_tag }}"
81+
fi
82+
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
83+
echo "Using version: $NEW_TAG"
84+
85+
- name: Draft Release Notes
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
uses: release-drafter/release-drafter@v6
89+
with:
90+
version: ${{ steps.bump_logic.outputs.tag }}
91+
tag: ${{ steps.bump_logic.outputs.tag }}
92+
93+
- name: Create GitHub Release
94+
if: steps.check.outputs.count > 0
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
run: |
98+
gh release create "${{ steps.bump_logic.outputs.tag }}" \
99+
--title "${{ steps.bump_logic.outputs.tag }}" \
100+
--generate-notes \
101+
--draft
102+
103+
upload_assets:
104+
needs: prepare_release
105+
if: needs.prepare_release.outputs.should_release == 'true'
106+
strategy:
107+
matrix:
108+
platform: [ubuntu-x86, mac-arm64]
109+
include:
110+
- platform: ubuntu-x86
111+
runner: ubuntu-24.04
112+
- platform: mac-arm64
113+
runner: macos-latest
114+
runs-on: ${{ matrix.runner }}
115+
permissions:
116+
contents: write
117+
steps:
118+
- uses: actions/checkout@v4
119+
with:
120+
fetch-depth: 0
121+
ref: ${{ github.event.inputs.target_commit || github.ref }}
122+
123+
- uses: ./.github/actions/environment-setup
124+
125+
- name: Build Binaries
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
run: |
129+
cd src
130+
TAG="${{ needs.prepare_release.outputs.tag }}"
131+
bazel build --show_timestamps --copt=-O3 --verbose_failures \
132+
-- //software:unix_full_system_tar_gen
133+
mv bazel-bin/software/unix_full_system_tar_gen.tar.gz "${{ runner.temp }}/unix_full_system_${{ needs.prepare_release.outputs.tag }}_${{ matrix.platform }}.tar.gz"
134+
gh release upload "$TAG" "${{ runner.temp }}/unix_full_system_${{ needs.prepare_release.outputs.tag }}_${{ matrix.platform }}.tar.gz"
135+
136+
publish_release:
137+
needs: [prepare_release, upload_assets]
138+
runs-on: ubuntu-latest
139+
permissions:
140+
contents: write
141+
steps:
142+
- uses: actions/checkout@v4
143+
with:
144+
ref: ${{ github.event.inputs.target_commit || github.sha }}
145+
- name: Undraft Release
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
run: gh release edit "${{ needs.prepare_release.outputs.tag }}" --draft=false

src/MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ bazel_dep(name = "rules_proto", version = "7.1.0")
2222
bazel_dep(name = "yaml-cpp", version = "0.8.0")
2323
bazel_dep(name = "buildifier_prebuilt", version = "8.0.3")
2424
bazel_dep(name = "pybind11_protobuf", version = "0.0.0-20250210-f02a2b7")
25+
bazel_dep(name = "bazel_lib", version = "3.1.0")
2526

2627
##############################################
2728
# Load PIP packages and our Requirements

src/MODULE.bazel.lock

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/software/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
load("@bazel_lib//lib:write_source_files.bzl", "write_source_files")
12
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension", "pybind_library")
3+
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
24
load("@thunderscope_deps//:requirements.bzl", "requirement")
35

46
package(default_visibility = ["//visibility:public"])
@@ -27,6 +29,13 @@ cc_binary(
2729
],
2830
)
2931

32+
pkg_tar(
33+
name = "unix_full_system_tar_gen",
34+
srcs = [":unix_full_system"],
35+
extension = "tar.gz",
36+
mode = "0755",
37+
)
38+
3039
cc_binary(
3140
name = "er_force_simulator_main",
3241
srcs = ["er_force_simulator_main.cpp"],

0 commit comments

Comments
 (0)