Skip to content

Commit

Permalink
CD - Push release to github releases on tags to master (#30)
Browse files Browse the repository at this point in the history
* CD - Push release to github releases on tags to master

* Explicitly create artifacts folder

* Add a feature/circleci filter to test circle ci config changes

* Ship to github releaes on tag push

* Add documentation for maintainers, add CHANGLOG, update contribution docs
  • Loading branch information
lakshmi-kannan authored Dec 11, 2019
1 parent e57cf64 commit 3cb3128
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 14 deletions.
69 changes: 55 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
aliases:
# Workflow filters
- &filter-not-release-or-master
tags:
ignore: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
branches:
ignore:
- master
- &filter-only-master
branches:
only: master

version: 2
jobs:
build:
Expand All @@ -27,6 +15,11 @@ jobs:
- dependency-cache-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- dependency-cache-
- run:
name: Setup Environment Variables
command: |
echo "export GIT_SHA1=$(echo ${CIRCLE_SHA1} | cut -c -7)" >> $BASH_ENV
source $BASH_ENV
- run:
name: yarn install
command: 'yarn install --pure-lockfile --no-progress'
Expand All @@ -35,6 +28,54 @@ jobs:
- node_modules
key: dependency-cache-{{ checksum "yarn.lock" }}
- run: yarn lint
- run: yarn build
- run: yarn test
- run:
name: Create directories for Artifacts
command: mkdir -p ~/artifacts/scalyr_plugin/target/
- run:
name: Build artifacts
command: |
yarn build
cp -rf dist/ ~/artifacts/scalyr_plugin/
echo Plugin git sha is ${GIT_SHA1}
cd ~/artifacts/scalyr_plugin/ && tar -czvf scalyr_grafana_plugin_${GIT_SHA1}.tar.gz dist/ && mv scalyr_grafana_plugin_${GIT_SHA1}.tar.gz target/
- persist_to_workspace:
root: ~/artifacts/scalyr_plugin/target/
paths:
- scalyr_grafana_plugin_*.tar.gz
- store_artifacts:
path: ~/artifacts/scalyr_plugin/target/
destination: scalyr_grafana_plugin

deploy-to-github-releases:
docker:
- image: circleci/golang:1.12
steps:
- attach_workspace:
at: ~/artifacts/scalyr_plugin/
- run:
name: "Publish Release on GitHub"
command: |
go get github.com/tcnksm/ghr
VERSION=${CIRCLE_TAG}
echo Releasing version $VERSION
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /home/circleci/artifacts/scalyr_plugin/
workflows:
version: 2
build-and-deploy:
jobs:
- build:
filters:
tags:
only: /.*/

# TODO: Ship dist/ folder to github releases and tag them
- deploy-to-github-releases:
requires:
- build
filters:
branches:
ignore: /.*/
tags:
# See https://discuss.circleci.com/t/filter-job-by-tag-not-working-regexp-possibly-unsupported/28484
only: /^(\d|[1-9]\d*)\.(\d|[1-9]\d*)\.(\d|[1-9]\d*)(-(0|[1-9A-Za-z-][0-9A-Za-z-]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9A-Za-z-][0-9A-Za-z-]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## In Development

## 1.0.0

Initial release
3 changes: 3 additions & 0 deletions HOW_TO_CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ We welcome and appreciate contributions of any kind (code, tests, documentation,
and use appropriate labels to indicate the kind of issue.
* Please fork this repo and create a branch to make your changes
* Please include the issues you are fixing in the commits
* Please add an entry in [CHANGELOG.md](./CHANGELOG.md) in `In Development` section along with
github issue number and author information. For example:
`Power queries now support blah (#1234) (Alice Wonderland)`

## Plugin development

Expand Down
17 changes: 17 additions & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Maintainers Documentation

## Release checklist

* Please make sure CHANGELOG reflects the new version to be released
(Usually, that's changing the `In Development` items to be reflected under
new version and leaving `In Development` empty)
* Set the new version to be released in plugin.json and package.json
* Please push a tag using git commands

```bash
git tag -a 0.1.0 -m "0.1.0 - Shiny new features and bug fixes"
git push upstream 0.1.0
```

* Circle CI builds the tag and ships to github releases
* Please ensure the released tar.gz contains the `dist` folder

0 comments on commit 3cb3128

Please sign in to comment.