Skip to content

Commit 3cb3128

Browse files
CD - Push release to github releases on tags to master (#30)
* 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
1 parent e57cf64 commit 3cb3128

File tree

4 files changed

+82
-14
lines changed

4 files changed

+82
-14
lines changed

.circleci/config.yml

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@
22
#
33
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
44
#
5-
aliases:
6-
# Workflow filters
7-
- &filter-not-release-or-master
8-
tags:
9-
ignore: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
10-
branches:
11-
ignore:
12-
- master
13-
- &filter-only-master
14-
branches:
15-
only: master
16-
175
version: 2
186
jobs:
197
build:
@@ -27,6 +15,11 @@ jobs:
2715
- dependency-cache-{{ checksum "yarn.lock" }}
2816
# fallback to using the latest cache if no exact match is found
2917
- dependency-cache-
18+
- run:
19+
name: Setup Environment Variables
20+
command: |
21+
echo "export GIT_SHA1=$(echo ${CIRCLE_SHA1} | cut -c -7)" >> $BASH_ENV
22+
source $BASH_ENV
3023
- run:
3124
name: yarn install
3225
command: 'yarn install --pure-lockfile --no-progress'
@@ -35,6 +28,54 @@ jobs:
3528
- node_modules
3629
key: dependency-cache-{{ checksum "yarn.lock" }}
3730
- run: yarn lint
38-
- run: yarn build
31+
- run: yarn test
32+
- run:
33+
name: Create directories for Artifacts
34+
command: mkdir -p ~/artifacts/scalyr_plugin/target/
35+
- run:
36+
name: Build artifacts
37+
command: |
38+
yarn build
39+
cp -rf dist/ ~/artifacts/scalyr_plugin/
40+
echo Plugin git sha is ${GIT_SHA1}
41+
cd ~/artifacts/scalyr_plugin/ && tar -czvf scalyr_grafana_plugin_${GIT_SHA1}.tar.gz dist/ && mv scalyr_grafana_plugin_${GIT_SHA1}.tar.gz target/
42+
- persist_to_workspace:
43+
root: ~/artifacts/scalyr_plugin/target/
44+
paths:
45+
- scalyr_grafana_plugin_*.tar.gz
46+
- store_artifacts:
47+
path: ~/artifacts/scalyr_plugin/target/
48+
destination: scalyr_grafana_plugin
49+
50+
deploy-to-github-releases:
51+
docker:
52+
- image: circleci/golang:1.12
53+
steps:
54+
- attach_workspace:
55+
at: ~/artifacts/scalyr_plugin/
56+
- run:
57+
name: "Publish Release on GitHub"
58+
command: |
59+
go get github.com/tcnksm/ghr
60+
VERSION=${CIRCLE_TAG}
61+
echo Releasing version $VERSION
62+
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /home/circleci/artifacts/scalyr_plugin/
63+
64+
workflows:
65+
version: 2
66+
build-and-deploy:
67+
jobs:
68+
- build:
69+
filters:
70+
tags:
71+
only: /.*/
3972

40-
# TODO: Ship dist/ folder to github releases and tag them
73+
- deploy-to-github-releases:
74+
requires:
75+
- build
76+
filters:
77+
branches:
78+
ignore: /.*/
79+
tags:
80+
# See https://discuss.circleci.com/t/filter-job-by-tag-not-working-regexp-possibly-unsupported/28484
81+
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-]+)*)?$/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## In Development
4+
5+
## 1.0.0
6+
7+
Initial release

HOW_TO_CONTRIBUTE.md

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

1316
## Plugin development
1417

MAINTAINERS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Maintainers Documentation
2+
3+
## Release checklist
4+
5+
* Please make sure CHANGELOG reflects the new version to be released
6+
(Usually, that's changing the `In Development` items to be reflected under
7+
new version and leaving `In Development` empty)
8+
* Set the new version to be released in plugin.json and package.json
9+
* Please push a tag using git commands
10+
11+
```bash
12+
git tag -a 0.1.0 -m "0.1.0 - Shiny new features and bug fixes"
13+
git push upstream 0.1.0
14+
```
15+
16+
* Circle CI builds the tag and ships to github releases
17+
* Please ensure the released tar.gz contains the `dist` folder

0 commit comments

Comments
 (0)