@@ -27,15 +27,15 @@ script:
27
27
# compile and find the code size with the smallest configuration
28
28
- make clean size
29
29
OBJ="$(ls lfs*.o | tr '\n' ' ')"
30
- CFLAGS+="-DLFS_NO{ASSERT,DEBUG,WARN,ERROR} "
30
+ CFLAGS+="-DLFS_NO_ASSERT -DLFS_NO_DEBUG -DLFS_NO_WARN -DLFS_NO_ERROR "
31
31
| tee sizes
32
32
33
33
# update status if we succeeded, compare with master if possible
34
34
- |
35
35
if [ "$TRAVIS_TEST_RESULT" -eq 0 ]
36
36
then
37
37
CURR=$(tail -n1 sizes | awk '{print $1}')
38
- PREV=$(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
38
+ PREV=$(curl -u $GEKY_BOT_STATUSES https://api.github.com/repos/$TRAVIS_REPO_SLUG/status/master \
39
39
| jq -re "select(.sha != \"$TRAVIS_COMMIT\")
40
40
| .statuses[] | select(.context == \"$STAGE/$NAME\").description
41
41
| capture(\"code size is (?<size>[0-9]+)\").size" \
@@ -134,52 +134,44 @@ jobs:
134
134
- STAGE=deploy
135
135
- NAME=deploy
136
136
script :
137
- # Update tag for version defined in lfs.h
137
+ # Find version defined in lfs.h
138
138
- LFS_VERSION=$(grep -ox '#define LFS_VERSION .*' lfs.h | cut -d ' ' -f3)
139
139
- LFS_VERSION_MAJOR=$((0xffff & ($LFS_VERSION >> 16)))
140
140
- 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"
143
150
- |
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" ]
160
156
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 \
162
168
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
163
169
-d "{
164
170
\"tag_name\": \"$LFS_VERSION\",
165
- \"name\": \"$LFS_VERSION\"
171
+ \"target_commitish\": \"$TRAVIS_COMMIT\",
172
+ \"name\": \"${LFS_VERSION%.0}\",
173
+ \"body\": $(jq -sR '.' <<< "$CHANGES")
166
174
}"
167
- RELEASE=$(
168
- curl -f https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/tags/$LFS_VERSION
169
- )
170
- CHANGES=$(
171
- git log --oneline $LFS_PREV_VERSION.. --grep='^Merge' --invert-grep
172
- )
173
- curl -f -u $GEKY_BOT_RELEASES -X PATCH \
174
- https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/$(
175
- jq -r '.id' <<< "$RELEASE"
176
- ) \
177
- -d "$(
178
- jq -s '{
179
- "body": ((.[0] // "" | sub("(?<=\n)#+ Changes.*"; ""; "mi"))
180
- + "### Changes\n\n" + .[1])
181
- }' <(jq '.body' <<< "$RELEASE") <(jq -sR '.' <<< "$CHANGES")
182
- )"
183
175
fi
184
176
185
177
# Manage statuses
@@ -220,4 +212,4 @@ after_success:
220
212
stages :
221
213
- name : test
222
214
- name : deploy
223
- if : branch = master
215
+ if : branch = master AND type = push
0 commit comments