Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 202797d

Browse files
author
Sameer Naik
committed
add circleci v2.1 config
1 parent e6dfcd1 commit 202797d

File tree

2 files changed

+115
-30
lines changed

2 files changed

+115
-30
lines changed

.circleci/config.yml

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,90 @@
1-
version: 2
1+
version: 2.1
2+
3+
orbs:
4+
go: circleci/go@1
5+
26
jobs:
37
build:
4-
working_directory: /go/src/github.com/triggermesh/aws-custom-runtime
5-
docker:
6-
- image: circleci/golang
8+
executor:
9+
name: go/default
10+
tag: '1.15'
11+
working_directory: ~/go/src/github.com/triggermesh/aws-custom-runtime
712
steps:
813
- checkout
9-
- restore_cache:
10-
keys:
11-
- v1-pkg-cache
1214
- run:
13-
name: Build binaries
15+
name: Building package
1416
command: |
15-
CGO_ENABLED=0 go build
16-
- persist_to_workspace:
17-
root: /go/src/github.com/triggermesh/aws-custom-runtime
18-
paths:
19-
- aws-custom-runtime
20-
- save_cache:
21-
key: v1-pkg-cache
22-
paths:
23-
- "/go/pkg"
17+
pwd
18+
make build
19+
20+
test:
21+
executor:
22+
name: go/default
23+
tag: '1.15'
24+
working_directory: ~/go/src/github.com/triggermesh/aws-custom-runtime
25+
steps:
26+
- checkout
27+
- run:
28+
name: Run fmt-test
29+
command: make fmt-test
30+
- run:
31+
name: Installing golangci-lint
32+
command: make install-golangci-lint
33+
# - run:
34+
# name: Run lint
35+
# command: make lint
36+
- run:
37+
name: Run test/cover
38+
command: make cover
39+
environment:
40+
TEST_OUTPUT_DIR: /tmp/test-results/
41+
COVER_OUTPUT_DIR: /tmp/cover-results/
42+
- store_test_results:
43+
path: /tmp/test-results/
44+
- store_artifacts:
45+
path: /tmp/cover-results/
2446

2547
release:
26-
docker:
27-
- image: circleci/golang
48+
executor:
49+
name: go/default
50+
tag: '1.15'
51+
working_directory: ~/go/src/github.com/triggermesh/aws-custom-runtime
2852
steps:
2953
- checkout
30-
- attach_workspace:
31-
at: /tmp/artifacts
3254
- run:
33-
name: "Publish Release on GitHub"
55+
name: Building release packages
56+
command: make release
57+
environment:
58+
DIST_DIR: /tmp/dist/
59+
- run:
60+
name: Installing github-release tool
61+
command: go get github.com/meterup/github-release
62+
- run:
63+
name: Creating github release
3464
command: |
35-
go get github.com/tcnksm/ghr
36-
VERSION=$(curl -sI https://github.com/triggermesh/aws-custom-runtime/releases/latest | grep -i "Location:" | awk -F "/" '{print $NF}' | tr -d "\r")
37-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /tmp/artifacts
65+
PRE_RELEASE=${CIRCLE_TAG/${CIRCLE_TAG%-rc[0-9]*}/}
66+
github-release delete -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} 2>/dev/null ||:
67+
./hack/release-notes.sh ${CIRCLE_TAG} | github-release release ${PRE_RELEASE:+-p} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -d -
68+
for f in $(find /tmp/dist -type f); do github-release upload -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -n $(basename ${f}) -f ${f} ; done
69+
3870
workflows:
39-
version: 2
40-
main:
71+
build-test-and-release:
4172
jobs:
4273
- build:
4374
filters:
4475
tags:
45-
only: /^v\d+\.\d+\.\d+$/
76+
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
77+
- test:
78+
filters:
79+
tags:
80+
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
4681
- release:
82+
context: production
4783
requires:
4884
- build
85+
- test
4986
filters:
87+
tags:
88+
only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
5089
branches:
5190
ignore: /.*/
52-
tags:
53-
only: /^v\d+\.\d+\.\d+$/

scripts/release-notes.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env sh
2+
3+
RELEASE=${1:-${GIT_TAG}}
4+
RELEASE=${RELEASE:-${CIRCLE_TAG}}
5+
6+
if [ -z "${RELEASE}" ]; then
7+
echo "Usage:"
8+
echo "release-notes.sh VERSION"
9+
exit 1
10+
fi
11+
12+
if ! git rev-list ${RELEASE} >/dev/null 2>&1; then
13+
echo "${RELEASE} does not exist"
14+
exit
15+
fi
16+
17+
PACKAGE="aws-custom-runtime"
18+
BASE_URL="https://github.com/triggermesh/${PACKAGE}/releases/download/${RELEASE}"
19+
PREV_RELEASE=${PREV_RELEASE:-$(git describe --tags --abbrev=0 ${RELEASE}^ 2>/dev/null)}
20+
PREV_RELEASE=${PREV_RELEASE:-$(git rev-list --max-parents=0 ${RELEASE}^ 2>/dev/null)}
21+
NOTABLE_CHANGES=$(git cat-file -p ${RELEASE} | sed '/-----BEGIN PGP SIGNATURE-----/,//d' | tail -n +6)
22+
CHANGELOG=$(git log --no-merges --pretty=format:'- [%h] %s (%aN)' ${PREV_RELEASE}..${RELEASE})
23+
if [ $? -ne 0 ]; then
24+
echo "Error creating changelog"
25+
exit 1
26+
fi
27+
28+
PLATFORMS=$(sed -n -e "s/^\(TARGETS[[:space:]]*?=[[:space:]]*\)\(.*\)$/\2/p" Makefile)
29+
RELEASE_ASSETS_TABLE=$(
30+
for platform in ${PLATFORMS}; do
31+
echo -n " ([${platform}](${BASE_URL}/${PACKAGE}-${platform%/*}-${platform#*/}))"
32+
done
33+
echo
34+
)
35+
36+
cat <<EOF
37+
${NOTABLE_CHANGES}
38+
39+
## Installation
40+
41+
Download Triggermesh AWS Lambda Custom Runtime ${RELEASE}
42+
43+
${RELEASE_ASSETS_TABLE}
44+
45+
## Changelog
46+
47+
${CHANGELOG}
48+
EOF

0 commit comments

Comments
 (0)