Skip to content

Commit 36ef1a3

Browse files
authored
feat(ci): add publishing steps (#1)
1 parent 0772c2e commit 36ef1a3

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed

.drone.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
kind: pipeline
2+
type: docker
3+
name: default
4+
5+
steps:
6+
- name: Go lint
7+
image: golangci/golangci-lint:v1.49-alpine
8+
environment:
9+
GOLANGCI_LINT_CACHE: "/drone/src/.cache/golangci-lint"
10+
commands:
11+
- golangci-lint cache status
12+
- golangci-lint run --timeout 3m0s
13+
when:
14+
branch:
15+
exclude:
16+
- "master"
17+
- "*stable"
18+
19+
- name: Rebuild lint cache
20+
pull: if-not-exists
21+
image: drillster/drone-volume-cache
22+
volumes:
23+
- name: golint-cache
24+
path: /golint-cache
25+
settings:
26+
rebuild: true
27+
mount:
28+
- .cache/golangci-lint
29+
when:
30+
branch:
31+
exclude:
32+
- "master"
33+
- "*stable"
34+
35+
- name: Bump and tag
36+
image: golang:1.18
37+
environment:
38+
GITHUB_API_KEY:
39+
from_secret: github_api_key
40+
GITHUB_API_USER:
41+
from_secret: github_api_user
42+
commands:
43+
- go install github.com/guilhem/[email protected]
44+
- git remote add authenticated-origin https://$GITHUB_API_USER:[email protected]/$DRONE_REPO
45+
- git fetch --tags authenticated-origin
46+
- bump patch --allow-dirty
47+
- git push authenticated-origin --tags
48+
when:
49+
branch:
50+
- master
51+
52+
trigger:
53+
event:
54+
- push
55+
56+
---
57+
kind: pipeline
58+
type: docker
59+
name: publish
60+
61+
steps:
62+
- name: Build and publish
63+
image: golang:1.18
64+
environment:
65+
GO111MODULE: on
66+
GITHUB_API_KEY:
67+
from_secret: github_api_key
68+
commands:
69+
- echo $DRONE_TAG | grep -v / || exit 78 # Skip if submodule is tagged
70+
- go mod download
71+
- make build
72+
- go install github.com/tcnksm/[email protected]
73+
- ghr -t $GITHUB_API_KEY -u ${DRONE_REPO_NAMESPACE} -r ${DRONE_REPO_NAME} -c ${DRONE_COMMIT} -delete ${DRONE_TAG} ./bin
74+
75+
trigger:
76+
event:
77+
- tag

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
coverage.xml
22
.env
3+
tmp
4+
bin

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build: all
2+
3+
all: go-coverage
4+
5+
go-coverage:
6+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w' -o bin/go-coverage
7+
8+
clean:
9+
rm -rf bin/*

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,96 @@ export DRONE_TAG="1.0.0" # trigger this script on drone t
1616

1717
go run ./ coverage.xml
1818
```
19+
20+
## Postgresql
21+
22+
To create a Postgres instance with the `coverage_analytics` database by Helm
23+
24+
### Install postgresql
25+
```sh
26+
helm upgrade -i postgres-coverage bitnami/postgresql -f ./values.yml -n core
27+
```
28+
29+
values.yml
30+
```yaml
31+
image:
32+
tag: 14.5.0
33+
34+
auth:
35+
database: coverage_analytics
36+
enablePostgresUser: true
37+
existingSecret: ""
38+
password: changeme
39+
postgresPassword: changeme
40+
replicationPassword: ""
41+
replicationUsername: repl_user
42+
secretKeys:
43+
adminPasswordKey: postgres-password
44+
replicationPasswordKey: replication-password
45+
userPasswordKey: password
46+
usePasswordFiles: false
47+
username: coverage_analytics
48+
```
49+
50+
### Expose postgresql service (optional)
51+
52+
```sh
53+
kubectl apply -f ./service.yml -n ${your-namespace}
54+
kubectl apply -f ./ingress.yml -n ${your-namespace}
55+
```
56+
57+
service.yml
58+
```yml
59+
apiVersion: v1
60+
kind: Service
61+
metadata:
62+
name: postgres-coverage-postgresql
63+
labels:
64+
app.kubernetes.io/component: primary
65+
app.kubernetes.io/instance: postgres-coverage
66+
app.kubernetes.io/managed-by: Helm
67+
app.kubernetes.io/name: postgresql
68+
helm.sh/chart: postgresql-12.1.2
69+
annotations:
70+
meta.helm.sh/release-name: postgres-coverage
71+
meta.helm.sh/release-namespace: core
72+
spec:
73+
ports:
74+
- protocol: TCP
75+
port: 5432
76+
targetPort: 5432
77+
nodePort: 30432
78+
selector:
79+
app.kubernetes.io/component: primary
80+
app.kubernetes.io/instance: postgres-coverage
81+
app.kubernetes.io/name: postgresql
82+
type: NodePort
83+
sessionAffinity: None
84+
externalTrafficPolicy: Cluster
85+
```
86+
87+
ingress.yml
88+
```yml
89+
apiVersion: networking.k8s.io/v1beta1
90+
kind: Ingress
91+
metadata:
92+
name: postgres-coverage
93+
labels:
94+
app: postgres-coverage
95+
annotations:
96+
kubernetes.io/ingress.class: nginx
97+
kubernetes.io/tls-acme: 'true'
98+
spec:
99+
tls:
100+
- hosts:
101+
- pg.example.app
102+
secretName: postgres-coverage-tls
103+
rules:
104+
- host: pg.example.app
105+
http:
106+
paths:
107+
- path: /
108+
backend:
109+
serviceName: postgres-coverage-postgresql
110+
servicePort: 5432
111+
```

0 commit comments

Comments
 (0)