From 7c28667998a79f868dcaea7bb01b26c800ab6465 Mon Sep 17 00:00:00 2001 From: JC <40373238+juancarlostong@users.noreply.github.com> Date: Tue, 5 May 2020 09:14:59 -0700 Subject: [PATCH] jctong/automate release (#45) * ci(travis): github release via pushing git tag * linting issue * simplify * simplify some more * remove whitespace --- .travis.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2ee41da..386aeda7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ os: linux stages: - 'Lint markdown files' - 'Test' + - 'Publish' jobs: include: @@ -30,9 +31,25 @@ jobs: - stage: 'Test' os: linux language: node_js - node_js: - - 10 + node_js: 10 install: yarn script: yarn test addons: srcclr: true + + - stage: 'Publish' + if: type = push AND tag IS present AND tag =~ /^[0-9]+\.[0-9]+\.[0-9]+/ + name: publish to github release + os: linux + language: minimal + install: + # installs hub to /tmp/bin + - 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') + - curl -fsSL "$URL" | tar xz -C /tmp --strip-components=1 --wildcards '*/bin/hub' + - export PATH=/tmp/bin:$PATH + - hub version + script: + - NEW_VERSION=$(grep -P '^## \[\d+\.\d+\.\d+.*\]' CHANGELOG.md | awk 'NR==1' | sed -e 's/\[/\\\[/' | sed -e 's/\]/\\\]/') + - LAST_VERSION=$(grep -P '^## \[\d+\.\d+\.\d+.*\]' CHANGELOG.md | awk 'NR==2' | sed -e 's/\[/\\\[/' | sed -e 's/\]/\\\]/') + - DESCRIPTION=$(awk "/^${NEW_VERSION}$/,/^${LAST_VERSION:-nothingmatched}$/" CHANGELOG.md | grep -v "^${LAST_VERSION:-nothingmatched}$") + - hub release create -m "Release ${TRAVIS_TAG}" -m "${DESCRIPTION}" "${TRAVIS_TAG}"