Skip to content

Commit f3fa5bc

Browse files
committed
build: publish to github and docker hub
1 parent 629405e commit f3fa5bc

File tree

2 files changed

+54
-11
lines changed

2 files changed

+54
-11
lines changed

.circleci/config.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,40 @@ jobs:
117117
- store_artifacts:
118118
path: artifacts
119119

120-
publish-release:
121-
working_directory: ~/grafana-piechart-panel
120+
publish-github-release:
121+
working_directory: ~/grafana-image-renderer
122122
docker:
123123
- image: cibuilds/github:0.12
124124
steps:
125125
- checkout
126+
- add_ssh_keys:
127+
fingerprints:
128+
- "0b:66:0c:56:98:dc:ea:69:79:f1:56:22:3f:c1:22:99"
126129
- attach_workspace:
127130
at: .
128131
- run:
129132
name: "Install dependencies"
130133
command: 'apk add --update --no-cache jq'
131134
- run:
132135
name: "Publish Release on GitHub"
133-
command: |
134-
PLUGIN_NAME=grafana-image-renderer
135-
RELEASE_NOTES=`awk 'BEGIN {FS="##"; RS=""} FNR==3 {print; exit}' CHANGELOG.md`
136-
echo $RELEASE_NOTES
137-
VERSION=`cat plugin.json|jq '.info.version'| sed s/\"//g`
138-
echo $VERSION
139-
ls -al
140-
ls -al ./artifacts
136+
command: './scripts/publish_github_release.sh'
137+
138+
publish-docker-release:
139+
working_directory: ~/grafana-image-renderer
140+
environment:
141+
IMAGE_NAME: "${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
142+
docker:
143+
- image: circleci/buildpack-deps:stretch
144+
steps:
145+
- checkout
146+
- setup_remote_docker
147+
- run: |
148+
TAG=$(git describe --tags --abbrev=0)
149+
docker build -t ${IMAGE_NAME}:${TAG} .
150+
docker tag IMAGE_NAME:${TAG} IMAGE_NAME:latest .
151+
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
152+
docker push IMAGE_NAME:${TAG}
153+
docker push IMAGE_NAME:latest
141154
142155
workflows:
143156
version: 2
@@ -165,10 +178,14 @@ workflows:
165178
- package_darwin_x64
166179
- package_windows_x64
167180
filters: *filter-only-master
168-
- publish-release:
181+
- publish-github-release:
169182
requires:
170183
- approve-release
171184
filters: *filter-only-master
185+
- publish-docker-release:
186+
requires:
187+
- publish-github-release
188+
filters: *filter-only-master
172189

173190
build-branches-and-prs:
174191
jobs:

scripts/publish_github_release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
RELEASE_NOTES=`awk 'BEGIN {FS="##"; RS=""} FNR==3 {print; exit}' CHANGELOG.md`
6+
VERSION=`cat plugin.json|jq '.info.version'| sed s/\"//g`
7+
LATEST_TAG=$(git describe --tags --abbrev=0)
8+
9+
if [ v${VERSION} == ${LATEST_TAG} ]; then
10+
echo "Tag ${LATEST_TAG} have already been pushed. Exiting..."
11+
exit 1
12+
fi
13+
14+
git config user.email "[email protected]"
15+
git config user.name "CircleCI Automation"
16+
git tag v${VERSION}
17+
git push origin v${VERSION}
18+
ghr \
19+
-t ${GITHUB_TOKEN} \
20+
-u ${CIRCLE_PROJECT_USERNAME} \
21+
-r ${CIRCLE_PROJECT_REPONAME} \
22+
-c ${CIRCLE_SHA1} \
23+
-n "v${VERSION}" \
24+
-b "${RELEASE_NOTES}" \
25+
v${VERSION} \
26+
./artifacts/

0 commit comments

Comments
 (0)