Skip to content

Commit d66723c

Browse files
authored
Merge pull request #81 from ARMmbed/simple-versioning
Simplified release process based on feedback
2 parents 84adead + 0234c77 commit d66723c

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://api.github.com/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://api.github.com/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://api.github.com/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://api.github.com/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://api.github.com/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://api.github.com/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://api.github.com/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)