Skip to content

Commit

Permalink
Add Drone pipeline to test packaging (grafana#6482)
Browse files Browse the repository at this point in the history
* Add Drone pipeline to test packaging
Currently, the packaging process only happens on tags, which could lead to surprises
Especially considering I'm working on deb and RPM packaging (lots more steps than now)

I also moved the publishing from Circle to Drone because:
1. I'll need some new secrets from Vault
2. It should be faster

* Fix make target

* Remove `-parallel` arg for `gox`
  • Loading branch information
julienduchesne authored Jun 27, 2022
1 parent 4c90d57 commit 6a9557a
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 27 deletions.
11 changes: 0 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ workflows:
requires: [test]
filters: { <<: *tag-or-main }

- publish/binaries:
requires: [test]
filters: { <<: *only-tags }


# https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/
.defaults: &defaults
Expand Down Expand Up @@ -81,10 +77,3 @@ jobs:
name: docker-driver
command: make docker-driver-push

publish/binaries:
<<: *defaults
steps:
- checkout
- run:
name: github release
command: make BUILD_IN_CONTAINER=false publish
24 changes: 21 additions & 3 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,11 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
fluentd(),
logstash(),
querytee(),
] + [
manifest(['promtail', 'loki', 'loki-canary']) {
trigger: condition('include').tagMain {
event: ['push', 'tag'],
},
},
] + [
pipeline('deploy') {
trigger: condition('include').tagMain {
event: ['push', 'tag'],
Expand Down Expand Up @@ -533,7 +531,27 @@ local manifest_ecr(apps, archs) = pipeline('manifest-ecr') {
},
],
},
] + [promtail_win()]
promtail_win(),
pipeline('release') {
trigger: {
event: ['pull_request', 'tag'],
},
image_pull_secrets: [pull_secret.name],
steps: [
run(
'test packaging',
commands=['make BUILD_IN_CONTAINER=false packages']
) { when: { event: ['pull_request'] } },
run(
'publish',
commands=['make BUILD_IN_CONTAINER=false publish'],
env={
GITHUB_TOKEN: { from_secret: github_secret.name },
}
) { when: { event: ['tag'] } },
],
},
]
+ [
lambda_promtail(arch)
for arch in ['amd64', 'arm64']
Expand Down
30 changes: 29 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,34 @@ trigger:
- pull_request
- tag
---
image_pull_secrets:
- dockerconfigjson
kind: pipeline
name: release
steps:
- commands:
- make BUILD_IN_CONTAINER=false packages
environment: {}
image: grafana/loki-build-image:0.21.0
name: test packaging
when:
event:
- pull_request
- commands:
- make BUILD_IN_CONTAINER=false publish
environment:
GITHUB_TOKEN:
from_secret: github_token
image: grafana/loki-build-image:0.21.0
name: publish
when:
event:
- tag
trigger:
event:
- pull_request
- tag
---
depends_on:
- check
kind: pipeline
Expand Down Expand Up @@ -1285,6 +1313,6 @@ kind: secret
name: deploy_config
---
kind: signature
hmac: 8335495d285498f513bb265cf90079175c25f5b6c5717deab7abfae65341726a
hmac: e56633097c3edb68fc784f2059f5c773f02ac485750610aaff59b43eb1417c5b

...
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ cmd/migrate/migrate:
#############
# Releasing #
#############
# concurrency is limited to 2 to prevent CircleCI from OOMing. Sorry
GOX = gox $(GO_FLAGS) -parallel=2 -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}"
CGO_GOX = gox $(DYN_GO_FLAGS) -cgo -parallel=2 -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}"
GOX = gox $(GO_FLAGS) -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}"
CGO_GOX = gox $(DYN_GO_FLAGS) -cgo -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}"
dist: clean
CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/loki
CGO_ENABLED=0 $(GOX) -osarch="linux/amd64 linux/arm64 linux/arm darwin/amd64 darwin/arm64 windows/amd64 freebsd/amd64" ./cmd/logcli
Expand Down
2 changes: 1 addition & 1 deletion tools/nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: "logcli"
arch: "amd64"
platform: "linux"
version: ${CIRCLE_TAG}
version: ${DRONE_TAG}
section: "default"
provides:
- logcli
Expand Down
8 changes: 4 additions & 4 deletions tools/release
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
ghr \
-t "${GITHUB_TOKEN}" \
-u "${CIRCLE_PROJECT_USERNAME}" \
-r "${CIRCLE_PROJECT_REPONAME}" \
-c "${CIRCLE_SHA1}" \
-u "${DRONE_REPO_OWNER}" \
-r "${DRONE_REPO_NAME}" \
-c "${DRONE_COMMIT}" \
-b="$(cat ./tools/release-note.md | envsubst)" \
-delete -draft \
"${CIRCLE_TAG}" ./dist/
"${DRONE_TAG}" ./dist/
8 changes: 4 additions & 4 deletions tools/release-note.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is release `${CIRCLE_TAG}` of Loki.
This is release `${DRONE_TAG}` of Loki.

### Notable changes:
:warning: **ADD RELEASE NOTES HERE** :warning:
Expand All @@ -11,8 +11,8 @@ The components of Loki are currently distributed in plain binary form and as Doc
* https://hub.docker.com/r/grafana/loki
* https://hub.docker.com/r/grafana/promtail
```bash
$ docker pull "grafana/loki:${CIRCLE_TAG}"
$ docker pull "grafana/promtail:${CIRCLE_TAG}"
$ docker pull "grafana/loki:${DRONE_TAG}"
$ docker pull "grafana/promtail:${DRONE_TAG}"
```

#### Binary
Expand All @@ -21,7 +21,7 @@ Choose from the assets below for the application and architecture matching your
Example for `Loki` on the `linux` operating system and `amd64` architecture:

```bash
$ curl -O -L "https://github.com/grafana/loki/releases/download/${CIRCLE_TAG}/loki-linux-amd64.zip"
$ curl -O -L "https://github.com/grafana/loki/releases/download/${DRONE_TAG}/loki-linux-amd64.zip"
# extract the binary
$ unzip "loki-linux-amd64.zip"
# make sure it is executable
Expand Down

0 comments on commit 6a9557a

Please sign in to comment.