Skip to content

Commit 0234c77

Browse files
committed
Simplified release process based on feedback
Previously, littlefs had mutable versions. That is, anytime a new commit landed on master, the bot would update the most recent version to contain the patch. The idea was that this would make sure users always had the most recent bug fixes. Immutable snapshots could be accessed through the git hashes. However, at this point multiple developers have pointed out that this is confusing, with mutable versions being non-standard and surprising. This new release process adopts SemVer in its entirety, with incrementing patch numbers and immutable versions. When a new commit lands on master: 1. The major/minor version is taken from lfs.h 2. The most recent patch version is looked up on GitHub and incremented 3. A changelog is built out of the commits to the previous version 4. A new release is created on GitHub Additionally, any commits that land while CI is still running are coalesced together. Which means multiple PRs can land in a single release.
1 parent 84adead commit 0234c77

File tree

1 file changed

+29
-38
lines changed

1 file changed

+29
-38
lines changed

.travis.yml

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -134,53 +134,44 @@ jobs:
134134
- STAGE=deploy
135135
- NAME=deploy
136136
script:
137-
# Update tag for version defined in lfs.h
137+
# Find version defined in lfs.h
138138
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
139139
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
140140
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
141-
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR"
142-
- echo "littlefs version $LFS_VERSION"
141+
# Grab latests patch from repo tags, default to 0
142+
- LFS_VERSION_PATCH=$(curl -f -u "$GEKY_BOT_RELEASES"
143+
https://github.com/api/repos/$TRAVIS_REPO_SLUG/git/refs
144+
| jq 'map(.ref | match(
145+
"refs/tags/v'"$LFS_VERSION_MAJOR"'\\.'"$LFS_VERSION_MINOR"'\\.(.*)$")
146+
.captures[].string | tonumber + 1) | max // 0')
147+
# We have our new version
148+
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
149+
- echo "VERSION $LFS_VERSION"
143150
- |
144-
curl -u $GEKY_BOT_RELEASES -X POST \
145-
https://github.com/api/repos/$TRAVIS_REPO_SLUG/git/refs \
146-
-d "{
147-
\"ref\": \"refs/tags/$LFS_VERSION\",
148-
\"sha\": \"$TRAVIS_COMMIT\"
149-
}"
150-
- |
151-
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
152-
https://github.com/api/repos/$TRAVIS_REPO_SLUG/git/refs/tags/$LFS_VERSION \
153-
-d "{
154-
\"sha\": \"$TRAVIS_COMMIT\"
155-
}"
156-
# Create release notes from commits
157-
- LFS_PREV_VERSION="v$LFS_VERSION_MAJOR.$(($LFS_VERSION_MINOR-1))"
158-
- |
159-
if [ $(git tag -l "$LFS_PREV_VERSION") ]
151+
# Check that we're the most recent commit
152+
CURRENT_COMMIT=$(curl -f -u "$GEKY_BOT_RELEASES" \
153+
https://github.com/api/repos/$TRAVIS_REPO_SLUG/commits/master \
154+
| jq -re '.sha')
155+
if [ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ]
160156
then
161-
curl -u $GEKY_BOT_RELEASES -X POST \
157+
# Build release notes
158+
PREV=$(git tag --sort=-v:refname -l "v*.*.*" | head -1)
159+
if [ ! -z "$PREV" ]
160+
then
161+
echo "PREV $PREV"
162+
CHANGES=$'### Changes\n\n'$( \
163+
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
164+
printf "CHANGES\n%s\n\n" "$CHANGES"
165+
fi
166+
# Create the release
167+
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
162168
https://github.com/api/repos/$TRAVIS_REPO_SLUG/releases \
163169
-d "{
164170
\"tag_name\": \"$LFS_VERSION\",
165-
\"name\": \"$LFS_VERSION\"
171+
\"target_commitish\": \"$TRAVIS_COMMIT\",
172+
\"name\": \"${LFS_VERSION%.0}\",
173+
\"body\": $(jq -sR '.' <<< "$CHANGES")
166174
}"
167-
RELEASE=$(
168-
curl -f -u $GEKY_BOT_RELEASES \
169-
https://github.com/api/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
170-
)
171-
CHANGES=$(
172-
git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
173-
)
174-
curl -f -u $GEKY_BOT_RELEASES -X PATCH \
175-
https://github.com/api/repos/$TRAVIS_REPO_SLUG/releases/$(
176-
jq -r '.id' <<< "$RELEASE"
177-
) \
178-
-d "$(
179-
jq -s '{
180-
"body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
181-
+ "### Changes\n\n" + .[1])
182-
}' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
183-
)"
184175
fi
185176
186177
# Manage statuses

0 commit comments

Comments
 (0)