Skip to content

Commit 7c28667

Browse files
jctong/automate release (#45)
* ci(travis): github release via pushing git tag * linting issue * simplify * simplify some more * remove whitespace
1 parent cec5081 commit 7c28667

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

.travis.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ os: linux
44
stages:
55
- 'Lint markdown files'
66
- 'Test'
7+
- 'Publish'
78

89
jobs:
910
include:
@@ -30,9 +31,25 @@ jobs:
3031
- stage: 'Test'
3132
os: linux
3233
language: node_js
33-
node_js:
34-
- 10
34+
node_js: 10
3535
install: yarn
3636
script: yarn test
3737
addons:
3838
srcclr: true
39+
40+
- stage: 'Publish'
41+
if: type = push AND tag IS present AND tag =~ /^[0-9]+\.[0-9]+\.[0-9]+/
42+
name: publish to github release
43+
os: linux
44+
language: minimal
45+
install:
46+
# installs hub to /tmp/bin
47+
- URL=$(curl https://api.github.com/repos/github/hub/releases/latest 2>/dev/null | jq -r '.assets[] | select(.browser_download_url | contains("linux-amd64")) | .browser_download_url')
48+
- curl -fsSL "$URL" | tar xz -C /tmp --strip-components=1 --wildcards '*/bin/hub'
49+
- export PATH=/tmp/bin:$PATH
50+
- hub version
51+
script:
52+
- NEW_VERSION=$(grep -P '^## \[\d+\.\d+\.\d+.*\]' CHANGELOG.md | awk 'NR==1' | sed -e 's/\[/\\\[/' | sed -e 's/\]/\\\]/')
53+
- LAST_VERSION=$(grep -P '^## \[\d+\.\d+\.\d+.*\]' CHANGELOG.md | awk 'NR==2' | sed -e 's/\[/\\\[/' | sed -e 's/\]/\\\]/')
54+
- DESCRIPTION=$(awk "/^${NEW_VERSION}$/,/^${LAST_VERSION:-nothingmatched}$/" CHANGELOG.md | grep -v "^${LAST_VERSION:-nothingmatched}$")
55+
- hub release create -m "Release ${TRAVIS_TAG}" -m "${DESCRIPTION}" "${TRAVIS_TAG}"

0 commit comments

Comments
 (0)