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