Skip to content

Commit 08eede2

Browse files
committed
2 parents 38960b1 + fcb19ff commit 08eede2

3 files changed

Lines changed: 137 additions & 20 deletions

File tree

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Release on Changelog Update
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'CHANGELOG.md'
9+
10+
env:
11+
MAKEOPTS: -j
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
release:
18+
name: Build and Release
19+
runs-on: ubuntu-24.04
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: true
25+
fetch-depth: 0
26+
27+
- name: Extract latest version and release notes from CHANGELOG.md
28+
id: changelog
29+
run: |
30+
# Find the first versioned section (skip [Unreleased])
31+
# Pattern: ## [x.y.z...] - date
32+
VERSION=$(grep -oP '(?<=^## \[)[^\]]+(?=\])' CHANGELOG.md | grep -v -i '^Unreleased$' | head -1)
33+
34+
if [ -z "$VERSION" ]; then
35+
echo "No versioned release found in CHANGELOG.md"
36+
exit 1
37+
fi
38+
39+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
40+
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
41+
42+
# Extract release notes between this version's heading and the next ## heading
43+
# Use awk to capture lines between the target section and the next section
44+
ESCAPED_VERSION=$(printf '%s' "$VERSION" | sed 's/[.[\*^$()+?{|]/\\&/g')
45+
NOTES=$(awk "/^## \\[$ESCAPED_VERSION\\]/{found=1; next} found && /^## \\[/{exit} found{print}" CHANGELOG.md)
46+
47+
# Write notes to a file for the release body
48+
echo "$NOTES" > /tmp/release_notes.md
49+
50+
echo "Detected version: $VERSION"
51+
echo "Release notes:"
52+
cat /tmp/release_notes.md
53+
54+
- name: Check if release already exists
55+
id: check_release
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
TAG="v${{ steps.changelog.outputs.version }}"
60+
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
61+
echo "Release $TAG already exists. Skipping."
62+
echo "exists=true" >> "$GITHUB_OUTPUT"
63+
else
64+
echo "exists=false" >> "$GITHUB_OUTPUT"
65+
fi
66+
67+
- name: Install cross-compiler
68+
if: steps.check_release.outputs.exists == 'false'
69+
run: sudo apt-get update && sudo apt-get install --yes gcc-arm-none-eabi
70+
71+
- run: pipx install poetry
72+
if: steps.check_release.outputs.exists == 'false'
73+
74+
- run: poetry install --only=build
75+
if: steps.check_release.outputs.exists == 'false'
76+
77+
- name: Create credits file
78+
if: steps.check_release.outputs.exists == 'false'
79+
run: |
80+
echo "$PYBRICKS_EV3_CREDITS" > bricks/ev3/ci_credits.txt
81+
env:
82+
PYBRICKS_EV3_CREDITS: ${{ secrets.PYBRICKS_EV3_CREDITS }}
83+
84+
- name: Build firmware
85+
if: steps.check_release.outputs.exists == 'false'
86+
run: |
87+
TAG="${{ steps.changelog.outputs.tag }}"
88+
export MICROPY_GIT_TAG=ci-release-${{ github.run_number }}-${TAG}
89+
export MICROPY_GIT_HASH=$(echo ${{ github.sha }} | cut -c1-8)
90+
poetry run make $MAKEOPTS -C micropython/mpy-cross
91+
poetry run make $MAKEOPTS -C bricks/movehub
92+
poetry run make $MAKEOPTS -C bricks/cityhub
93+
poetry run make $MAKEOPTS -C bricks/technichub
94+
poetry run make $MAKEOPTS -C bricks/primehub
95+
poetry run make $MAKEOPTS -C bricks/essentialhub
96+
poetry run make $MAKEOPTS -C bricks/nxt
97+
poetry run make $MAKEOPTS -C bricks/ev3
98+
99+
- name: Create Release and Upload Assets
100+
if: steps.check_release.outputs.exists == 'false'
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
run: |
104+
TAG="${{ steps.changelog.outputs.tag }}"
105+
VERSION="${{ steps.changelog.outputs.version }}"
106+
107+
# Determine pre-release flag (alpha, beta, release candidate)
108+
PRERELEASE_FLAG=""
109+
if [[ "$VERSION" == *a* ]] || [[ "$VERSION" == *b* ]] || [[ "$VERSION" == *rc* ]]; then
110+
PRERELEASE_FLAG="--prerelease"
111+
fi
112+
113+
# Rename and collect firmware assets
114+
HUBS="movehub cityhub technichub primehub essentialhub nxt ev3"
115+
ASSETS=""
116+
for HUB in $HUBS; do
117+
NEW_FILENAME="./bricks/$HUB/build/pybricks-$HUB-$TAG.zip"
118+
mv "./bricks/$HUB/build/firmware.zip" "$NEW_FILENAME"
119+
ASSETS="$ASSETS $NEW_FILENAME"
120+
done
121+
122+
# Create the git tag and GitHub release
123+
git tag "$TAG"
124+
git push origin "$TAG"
125+
126+
gh release create "$TAG" \
127+
--repo="$GITHUB_REPOSITORY" \
128+
--title="${VERSION}" \
129+
-F /tmp/release_notes.md \
130+
$PRERELEASE_FLAG \
131+
$ASSETS

.github/workflows/release.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
on:
2-
push:
3-
tags:
4-
- 'v3.*'
5-
- 'v4.*'
1+
# This workflow is disabled. Releases are now handled by release-changelog.yml.
2+
on: workflow_dispatch
63

7-
name: Upload Release Assets
4+
name: Upload Release Assets (Disabled)
85

96
env:
107
MAKEOPTS: -j

CHANGELOG.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22

33
# Changelog
44

5-
## [Unreleased]
5+
## [psp0.1.0a] - 2026-03-15
66

77
### Added
8-
- Added `pybricks.pupdevices.MarioHub` to control it as a peripheral. It
9-
cannot be used as a standalone device since it cannot ne updated.
10-
11-
### Changed
12-
- The EV3 Color Sensor now returns `Color.NONE` instead of `None` when no color
13-
is detected, for consistency with other Color Sensors ([support#2603]).
14-
15-
### Fixed
16-
- Fixed EV3 light animation stopping when screen is used ([support#2599]).
17-
- Fixed Powered Up motors not resetting to the absolute value ([support#2620]).
8+
- Trigonometry testing in pybricks.experimental
189

19-
[support#2599]: https://github.com/pybricks/support/issues/2599
20-
[support#2603]: https://github.com/pybricks/support/issues/2603
21-
[support#2620]: https://github.com/pybricks/support/issues/2620
10+
This release it mainly to test the new action, it does not have any PySplanner features.
2211

2312
## [4.0.0b7] - 2026-02-19
2413

0 commit comments

Comments
 (0)