44 push :
55 branches : [master]
66
7+ permissions :
8+ contents : write
9+
710env :
811 PKG_NAME : intercom-client
912 PKG_ARCH : arm64
1013 PKG_DEPENDS : " libgstreamer1.0-0, gstreamer1.0-plugins-base, gstreamer1.0-plugins-good, libv4l-0"
1114
1215jobs :
16+ bump :
17+ name : Bump version
18+ runs-on : ubuntu-22.04-arm
19+ outputs :
20+ new_version : ${{ steps.semver.outputs.new_version }}
21+ steps :
22+ - uses : actions/checkout@v5
23+ with :
24+ fetch-depth : 0
25+ token : ${{ secrets.GITHUB_TOKEN }}
26+
27+ - name : Determine next version from conventional commits
28+ id : semver
29+ run : |
30+ set -euo pipefail
31+
32+ CURRENT_VERSION=$(python3 -c "
33+ import tomllib
34+ with open('pyproject.toml', 'rb') as f:
35+ print(tomllib.load(f)['project']['version'])
36+ ")
37+ echo "Current version: ${CURRENT_VERSION}"
38+
39+ IFS='.' read -r MAJOR MINOR PATCH <<< "${CURRENT_VERSION}"
40+
41+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
42+
43+ if [ -z "${LAST_TAG}" ]; then
44+ echo "No existing tags — analyzing all commits"
45+ COMMITS=$(git log --format='%s')
46+ else
47+ echo "Last tag: ${LAST_TAG}"
48+ COMMITS=$(git log "${LAST_TAG}"..HEAD --format='%s')
49+ fi
50+
51+ BUMP="patch"
52+ while IFS= read -r subject; do
53+ # Major: breaking change via ! suffix
54+ if echo "$subject" | grep -qE '^[a-zA-Z]+(\([^)]+\))?!:'; then
55+ BUMP="major"
56+ break
57+ fi
58+ # Major: BREAKING CHANGE in commit body
59+ HASH=$(git log --format='%H %s' | grep -F "${subject}" | head -1 | awk '{print $1}')
60+ if [ -n "${HASH}" ] && git log -1 --format='%B' "${HASH}" | grep -q 'BREAKING CHANGE'; then
61+ BUMP="major"
62+ break
63+ fi
64+ # Minor: feat commits
65+ if [ "${BUMP}" != "major" ] && echo "$subject" | grep -qE '^feat(\([^)]+\))?:'; then
66+ BUMP="minor"
67+ fi
68+ done <<< "${COMMITS}"
69+
70+ echo "Bump type: ${BUMP}"
71+
72+ case "${BUMP}" in
73+ major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
74+ minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
75+ patch) PATCH=$((PATCH + 1)) ;;
76+ esac
77+
78+ NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
79+ echo "New version: ${NEW_VERSION}"
80+ echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
81+
82+ - name : Update pyproject.toml version
83+ run : |
84+ NEW_VERSION="${{ steps.semver.outputs.new_version }}"
85+ sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" pyproject.toml
86+ echo "Updated pyproject.toml to ${NEW_VERSION}"
87+ grep "^version" pyproject.toml
88+
89+ - name : Configure git
90+ run : |
91+ git config user.name "github-actions[bot]"
92+ git config user.email "github-actions[bot]@users.noreply.github.com"
93+
94+ - name : Commit version bump and push tag
95+ run : |
96+ NEW_VERSION="${{ steps.semver.outputs.new_version }}"
97+ git add pyproject.toml
98+ git commit -m "chore: bump version to ${NEW_VERSION}"
99+ git tag "v${NEW_VERSION}"
100+ git push origin HEAD
101+ git push origin "v${NEW_VERSION}"
102+
103+ - name : Create GitHub Release
104+ uses : softprops/action-gh-release@v2
105+ with :
106+ tag_name : v${{ steps.semver.outputs.new_version }}
107+ generate_release_notes : true
108+ env :
109+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
110+
13111 test :
14112 name : Run tests
113+ needs : bump
15114 runs-on : ubuntu-22.04-arm
16115 steps :
17116 - uses : actions/checkout@v5
117+ with :
118+ ref : v${{ needs.bump.outputs.new_version }}
18119
19120 - name : Install uv
20121 uses : astral-sh/setup-uv@v7
@@ -30,10 +131,12 @@ jobs:
30131
31132 build :
32133 name : Build .deb
33- needs : test
134+ needs : [ test, bump]
34135 runs-on : ubuntu-22.04-arm
35136 steps :
36137 - uses : actions/checkout@v5
138+ with :
139+ ref : v${{ needs.bump.outputs.new_version }}
37140
38141 - name : Install uv
39142 uses : astral-sh/setup-uv@v7
@@ -83,18 +186,11 @@ jobs:
83186 --include-package-data=cv2
84187 main.py
85188
86- - name : Read version from pyproject.toml
87- id : version
88- run : |
89- VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
90- echo "value=${VERSION}" >> "$GITHUB_OUTPUT"
91- echo "Package version: ${VERSION}"
92-
93189 - name : Build .deb package
94190 run : |
95191 set -euo pipefail
96192
97- PKG_VERSION="${{ steps.version .outputs.value }}"
193+ PKG_VERSION="${{ needs.bump .outputs.new_version }}"
98194 PKG_DIR="dist/${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}"
99195 DEB_FILE="${PKG_DIR}.deb"
100196
0 commit comments