File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 - name : Show Snapcraft version
3333 run : snapcraft --version
3434
35+ - name : Set Snap version from tag
36+ if : github.event_name == 'release'
37+ run : |
38+ # Extract version from GITHUB_REF (handles both v0.96.6 and 0.96.6 tags)
39+ VERSION="${GITHUB_REF#refs/tags/}"
40+ VERSION="${VERSION#v}"
41+ VERSION="${VERSION%%-*}"
42+ VERSION="${VERSION//[[:space:]]/}"
43+
44+ if [ -z "$VERSION" ]; then
45+ echo "ERROR: Version is empty after parsing GITHUB_REF: $GITHUB_REF" >&2
46+ exit 1
47+ fi
48+
49+ if [ ${#VERSION} -gt 32 ]; then
50+ echo "Snap version too long: $VERSION" >&2
51+ exit 1
52+ fi
53+
54+ # Verify snapcraft.yaml has a version line before modifying
55+ if ! grep -q '^version:' snap/snapcraft.yaml; then
56+ echo "ERROR: No version line found in snap/snapcraft.yaml" >&2
57+ exit 1
58+ fi
59+
60+ echo "Setting snap version to: $VERSION"
61+ sed -i "s/^version: .*/version: '${VERSION}'/" snap/snapcraft.yaml
62+ grep -m1 '^version:' snap/snapcraft.yaml
63+
3564 - name : Build snap
3665 run : sudo snapcraft --destructive-mode
3766
You can’t perform that action at this time.
0 commit comments