mirror of
https://github.com/thegeeklab/github-releases-notifier.git
synced 2024-11-21 12:40:38 +00:00
refactoring
This commit is contained in:
parent
57418eaed5
commit
731d2b8aa7
317
.drone.jsonnet
Normal file
317
.drone.jsonnet
Normal file
@ -0,0 +1,317 @@
|
||||
local PipelineTest = {
|
||||
kind: 'pipeline',
|
||||
name: 'test',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'staticcheck',
|
||||
image: 'golang:1.14',
|
||||
commands: [
|
||||
'go run honnef.co/go/tools/cmd/staticcheck ./...',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'lint',
|
||||
image: 'golang:1.14',
|
||||
commands: [
|
||||
'go run golang.org/x/lint/golint -set_exit_status ./...',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'vet',
|
||||
image: 'golang:1.14',
|
||||
commands: [
|
||||
'go vet ./...',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
image: 'golang:1.14',
|
||||
commands: [
|
||||
'go test -cover ./...',
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
path: '/go',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
volumes: [
|
||||
{
|
||||
name: 'gopath',
|
||||
temp: {},
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
local PipelineBuildBinaries = {
|
||||
kind: 'pipeline',
|
||||
name: 'build-binaries',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'build',
|
||||
image: 'techknowlogick/xgo:go-1.14.x',
|
||||
commands: [
|
||||
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
|
||||
'mkdir -p release/',
|
||||
"cd cmd/github-releases-notifier && xgo -ldflags \"-s -w -X main.version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' -out github-releases-notifier .",
|
||||
'mv /build/* /drone/src/release/',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'executable',
|
||||
image: 'alpine',
|
||||
commands: [
|
||||
'$(find release/ -executable -type f | grep github-releases-notifier-linux-amd64) --help',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'compress',
|
||||
image: 'alpine',
|
||||
commands: [
|
||||
'apk add upx',
|
||||
'find release/ -maxdepth 1 -executable -type f -exec upx {} \\;',
|
||||
'ls -lh release/',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'checksum',
|
||||
image: 'alpine',
|
||||
commands: [
|
||||
'cd release/ && sha256sum * > sha256sum.txt',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'publish',
|
||||
image: 'plugins/github-release',
|
||||
settings: {
|
||||
overwrite: true,
|
||||
api_key: {
|
||||
from_secret: 'github_token',
|
||||
},
|
||||
files: ['release/*'],
|
||||
title: '${DRONE_TAG}',
|
||||
note: 'CHANGELOG.md',
|
||||
},
|
||||
when: {
|
||||
ref: [
|
||||
'refs/tags/**',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
'test',
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineBuildContainer(arch='amd64') = {
|
||||
kind: 'pipeline',
|
||||
name: 'build-container-' + arch,
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: arch,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'build',
|
||||
image: 'golang:1.14',
|
||||
commands: [
|
||||
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
|
||||
'go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/' + arch + '/github-releases-notifier ./cmd/github-releases-notifier',
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'dryrun',
|
||||
image: 'plugins/docker:18-linux-' + arch,
|
||||
settings: {
|
||||
dry_run: true,
|
||||
dockerfile: 'docker/Dockerfile.' + arch,
|
||||
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
},
|
||||
depends_on: ['build'],
|
||||
when: {
|
||||
ref: ['refs/pull/**'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'publish-dockerhub',
|
||||
image: 'plugins/docker:18-linux-' + arch,
|
||||
settings: {
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: arch,
|
||||
dockerfile: 'docker/Dockerfile.' + arch,
|
||||
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
},
|
||||
when: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||
},
|
||||
depends_on: ['dryrun'],
|
||||
},
|
||||
{
|
||||
name: 'publish-quay',
|
||||
image: 'plugins/docker:18-linux-' + arch,
|
||||
settings: {
|
||||
auto_tag: true,
|
||||
auto_tag_suffix: arch,
|
||||
dockerfile: 'docker/Dockerfile.' + arch,
|
||||
registry: 'quay.io',
|
||||
repo: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
||||
username: { from_secret: 'quay_username' },
|
||||
password: { from_secret: 'quay_password' },
|
||||
},
|
||||
when: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||
},
|
||||
depends_on: ['dryrun'],
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
'test',
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
local PipelineNotifications = {
|
||||
kind: 'pipeline',
|
||||
name: 'notifications',
|
||||
platform: {
|
||||
os: 'linux',
|
||||
arch: 'amd64',
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
image: 'plugins/manifest',
|
||||
name: 'manifest-dockerhub',
|
||||
settings: {
|
||||
ignore_missing: true,
|
||||
auto_tag: true,
|
||||
username: { from_secret: 'docker_username' },
|
||||
password: { from_secret: 'docker_password' },
|
||||
spec: 'docker/manifest.tmpl',
|
||||
},
|
||||
when: {
|
||||
status: ['success'],
|
||||
},
|
||||
},
|
||||
{
|
||||
image: 'plugins/manifest',
|
||||
name: 'manifest-quay',
|
||||
settings: {
|
||||
ignore_missing: true,
|
||||
auto_tag: true,
|
||||
username: { from_secret: 'quay_username' },
|
||||
password: { from_secret: 'quay_password' },
|
||||
spec: 'docker/manifest-quay.tmpl',
|
||||
},
|
||||
when: {
|
||||
status: ['success'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'pushrm-dockerhub',
|
||||
image: 'chko/docker-pushrm:1',
|
||||
environment: {
|
||||
DOCKER_PASS: {
|
||||
from_secret: 'docker_password',
|
||||
},
|
||||
DOCKER_USER: {
|
||||
from_secret: 'docker_username',
|
||||
},
|
||||
PUSHRM_FILE: 'README.md',
|
||||
PUSHRM_SHORT: 'GitHub release notification bot',
|
||||
PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}',
|
||||
},
|
||||
when: {
|
||||
status: ['success'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'pushrm-quay',
|
||||
image: 'chko/docker-pushrm:1',
|
||||
environment: {
|
||||
APIKEY__QUAY_IO: {
|
||||
from_secret: 'quay_token',
|
||||
},
|
||||
PUSHRM_FILE: 'README.md',
|
||||
PUSHRM_TARGET: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
||||
},
|
||||
when: {
|
||||
status: ['success'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'matrix',
|
||||
image: 'plugins/matrix',
|
||||
settings: {
|
||||
homeserver: { from_secret: 'matrix_homeserver' },
|
||||
roomid: { from_secret: 'matrix_roomid' },
|
||||
template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
|
||||
username: { from_secret: 'matrix_username' },
|
||||
password: { from_secret: 'matrix_password' },
|
||||
},
|
||||
when: {
|
||||
status: ['success', 'failure'],
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: [
|
||||
'build-binaries',
|
||||
'build-container-amd64',
|
||||
'build-container-arm',
|
||||
'build-container-arm64',
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||
status: ['success', 'failure'],
|
||||
},
|
||||
};
|
||||
|
||||
[
|
||||
PipelineTest,
|
||||
PipelineBuildBinaries,
|
||||
PipelineBuildContainer(arch='amd64'),
|
||||
PipelineBuildContainer(arch='arm64'),
|
||||
PipelineBuildContainer(arch='arm'),
|
||||
PipelineNotifications,
|
||||
]
|
297
.drone.star
297
.drone.star
@ -1,297 +0,0 @@
|
||||
def main(ctx):
|
||||
before = testing()
|
||||
|
||||
stages = [
|
||||
linux('amd64'),
|
||||
linux('arm64'),
|
||||
linux('arm'),
|
||||
binaries([]),
|
||||
]
|
||||
|
||||
after = notification()
|
||||
|
||||
for b in before:
|
||||
for s in stages:
|
||||
s['depends_on'].append(b['name'])
|
||||
|
||||
for s in stages:
|
||||
for a in after:
|
||||
a['depends_on'].append(s['name'])
|
||||
|
||||
return before + stages + after
|
||||
|
||||
def testing():
|
||||
return [{
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'testing',
|
||||
'platform': {
|
||||
'os': 'linux',
|
||||
'arch': 'amd64',
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'vet',
|
||||
'image': 'golang:1.12',
|
||||
'commands': [
|
||||
'go vet ./...'
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/go'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'test',
|
||||
'image': 'golang:1.12',
|
||||
'commands': [
|
||||
'go test -cover ./...'
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'path': '/go'
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
'name': 'gopath',
|
||||
'temp': {}
|
||||
}
|
||||
],
|
||||
'trigger': {
|
||||
'ref': [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**'
|
||||
]
|
||||
}
|
||||
}]
|
||||
|
||||
def linux(arch):
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'build-container-%s' % arch,
|
||||
'platform': {
|
||||
'os': 'linux',
|
||||
'arch': arch,
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'build',
|
||||
'image': 'golang:1.12',
|
||||
'environment': {
|
||||
'CGO_ENABLED': '0',
|
||||
},
|
||||
'commands': [
|
||||
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
|
||||
'go build -v -ldflags "-X main.Version=$BUILD_VERSION" -a -tags netgo -o release/%s/github-releases-notifier' % arch
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'executable',
|
||||
'image': 'golang:1.12',
|
||||
'commands': [
|
||||
'./release/%s/github-releases-notifier --help' % arch,
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'dryrun',
|
||||
'image': 'plugins/docker',
|
||||
'settings': {
|
||||
'dry_run': True,
|
||||
'tags': arch,
|
||||
'dockerfile': 'docker/Dockerfile.%s' % arch,
|
||||
'repo': 'xoxys/github-releases-notifier',
|
||||
'username': {
|
||||
'from_secret': 'docker_username'
|
||||
},
|
||||
'password': {
|
||||
'from_secret': 'docker_password'
|
||||
}
|
||||
},
|
||||
'when': {
|
||||
'event': [
|
||||
'pull_request'
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'publish',
|
||||
'image': 'plugins/docker',
|
||||
'settings': {
|
||||
'auto_tag': True,
|
||||
'auto_tag_suffix': arch,
|
||||
'dockerfile': 'docker/Dockerfile.%s' % arch,
|
||||
'repo': 'xoxys/github-releases-notifier',
|
||||
'username': {
|
||||
'from_secret': 'docker_username'
|
||||
},
|
||||
'password': {
|
||||
'from_secret': 'docker_password'
|
||||
}
|
||||
},
|
||||
'when': {
|
||||
'event': {
|
||||
'exclude': [
|
||||
'pull_request'
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
'depends_on': [],
|
||||
'trigger': {
|
||||
'ref': [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
def binaries(arch):
|
||||
return {
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'build-binaries',
|
||||
'steps': [
|
||||
{
|
||||
'name': 'build',
|
||||
'image': 'techknowlogick/xgo:latest',
|
||||
'commands': [
|
||||
'[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}',
|
||||
'mkdir -p release/',
|
||||
"xgo -ldflags \"-X main.Version=$BUILD_VERSION\" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' -out github-releases-notifier-$BUILD_VERSION .",
|
||||
'cp /build/* release/'
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': 'checksum',
|
||||
'image': 'alpine',
|
||||
'commands': [
|
||||
'cd release/ && sha256sum * > sha256sum.txt',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'publish',
|
||||
'image': 'plugins/github-release',
|
||||
'settings': {
|
||||
'overwrite': True,
|
||||
'api_key': {
|
||||
'from_secret': 'github_token'
|
||||
},
|
||||
'files': [ "release/*" ],
|
||||
'title': '${DRONE_TAG}',
|
||||
'note': 'CHANGELOG.md',
|
||||
},
|
||||
'when': {
|
||||
'ref': [
|
||||
'refs/tags/**'
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
'depends_on': [],
|
||||
'trigger': {
|
||||
'ref': [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
def notification():
|
||||
return [{
|
||||
'kind': 'pipeline',
|
||||
'type': 'docker',
|
||||
'name': 'notification',
|
||||
'steps': [
|
||||
{
|
||||
'name': 'manifest',
|
||||
'image': 'plugins/manifest',
|
||||
'settings': {
|
||||
'auto_tag': True,
|
||||
'username': {
|
||||
'from_secret': 'docker_username'
|
||||
},
|
||||
'password': {
|
||||
'from_secret': 'docker_password'
|
||||
},
|
||||
'spec': 'docker/manifest.tmpl',
|
||||
'ignore_missing': 'true',
|
||||
},
|
||||
'when' : {
|
||||
'status': [
|
||||
'success',
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
'name': 'readme',
|
||||
'image': 'sheogorath/readme-to-dockerhub',
|
||||
'environment': {
|
||||
'DOCKERHUB_USERNAME': {
|
||||
'from_secret': 'docker_username'
|
||||
},
|
||||
'DOCKERHUB_PASSWORD': {
|
||||
'from_secret': 'docker_password'
|
||||
},
|
||||
'DOCKERHUB_REPO_PREFIX': 'xoxys',
|
||||
'DOCKERHUB_REPO_NAME': 'github-releases-notifier',
|
||||
'README_PATH': 'README.md',
|
||||
'SHORT_DESCRIPTION': 'Receive Slack notifications for new GitHub releases'
|
||||
},
|
||||
},
|
||||
{
|
||||
'name': 'microbadger',
|
||||
'image': 'plugins/webhook',
|
||||
'settings': {
|
||||
'urls': {
|
||||
'from_secret': 'microbadger_url'
|
||||
}
|
||||
},
|
||||
'when' : {
|
||||
'status': [
|
||||
'success',
|
||||
]
|
||||
},
|
||||
},
|
||||
{
|
||||
'name': 'matrix',
|
||||
'image': 'plugins/matrix',
|
||||
'settings': {
|
||||
'homeserver': {
|
||||
'from_secret': 'matrix_homeserver',
|
||||
},
|
||||
'password': {
|
||||
'from_secret': 'matrix_password',
|
||||
},
|
||||
'roomid': {
|
||||
'from_secret': 'matrix_roomid',
|
||||
},
|
||||
'template': 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
|
||||
'username': {
|
||||
'from_secret': 'matrix_username',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
'depends_on': [],
|
||||
'trigger': {
|
||||
'ref': [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**'
|
||||
],
|
||||
'status': [
|
||||
'success',
|
||||
'failure'
|
||||
]
|
||||
}
|
||||
}]
|
531
.drone.yml
531
.drone.yml
@ -1,15 +1,30 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: testing
|
||||
name: test
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: staticcheck
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- go run honnef.co/go/tools/cmd/staticcheck ./...
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: lint
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- go run golang.org/x/lint/golint -set_exit_status ./...
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: vet
|
||||
image: golang:1.12
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- go vet ./...
|
||||
volumes:
|
||||
@ -17,7 +32,7 @@ steps:
|
||||
path: /go
|
||||
|
||||
- name: test
|
||||
image: golang:1.12
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- go test -cover ./...
|
||||
volumes:
|
||||
@ -36,196 +51,6 @@ trigger:
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build-container-amd64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.12
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.Version=$BUILD_VERSION" -a -tags netgo -o release/amd64/github-releases-notifier
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
|
||||
- name: executable
|
||||
image: golang:1.12
|
||||
commands:
|
||||
- ./release/amd64/github-releases-notifier --help
|
||||
|
||||
- name: dryrun
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: xoxys/github-releases-notifier
|
||||
tags: amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: xoxys/github-releases-notifier
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build-container-arm64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.12
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.Version=$BUILD_VERSION" -a -tags netgo -o release/arm64/github-releases-notifier
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
|
||||
- name: executable
|
||||
image: golang:1.12
|
||||
commands:
|
||||
- ./release/arm64/github-releases-notifier --help
|
||||
|
||||
- name: dryrun
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: xoxys/github-releases-notifier
|
||||
tags: arm64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: xoxys/github-releases-notifier
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build-container-arm
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.12
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.Version=$BUILD_VERSION" -a -tags netgo -o release/arm/github-releases-notifier
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
|
||||
- name: executable
|
||||
image: golang:1.12
|
||||
commands:
|
||||
- ./release/arm/github-releases-notifier --help
|
||||
|
||||
- name: dryrun
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: xoxys/github-releases-notifier
|
||||
tags: arm
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: xoxys/github-releases-notifier
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
- pull_request
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build-binaries
|
||||
|
||||
platform:
|
||||
@ -234,12 +59,24 @@ platform:
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: techknowlogick/xgo:latest
|
||||
image: techknowlogick/xgo:go-1.14.x
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- mkdir -p release/
|
||||
- xgo -ldflags "-X main.Version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' -out github-releases-notifier-$BUILD_VERSION .
|
||||
- cp /build/* release/
|
||||
- cd cmd/github-releases-notifier && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm64' -out github-releases-notifier .
|
||||
- mv /build/* /drone/src/release/
|
||||
|
||||
- name: executable
|
||||
image: alpine
|
||||
commands:
|
||||
- $(find release/ -executable -type f | grep github-releases-notifier-linux-amd64) --help
|
||||
|
||||
- name: compress
|
||||
image: alpine
|
||||
commands:
|
||||
- apk add upx
|
||||
- find release/ -maxdepth 1 -executable -type f -exec upx {} \;
|
||||
- ls -lh release/
|
||||
|
||||
- name: checksum
|
||||
image: alpine
|
||||
@ -267,19 +104,249 @@ trigger:
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
- test
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: notification
|
||||
name: build-container-amd64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: manifest
|
||||
- name: build
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/github-releases-notifier ./cmd/github-releases-notifier
|
||||
|
||||
- name: dryrun
|
||||
image: plugins/docker:18-linux-amd64
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/pull/**
|
||||
depends_on:
|
||||
- build
|
||||
|
||||
- name: publish-dockerhub
|
||||
image: plugins/docker:18-linux-amd64
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
- name: publish-quay
|
||||
image: plugins/docker:18-linux-amd64
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
dockerfile: docker/Dockerfile.amd64
|
||||
password:
|
||||
from_secret: quay_password
|
||||
registry: quay.io
|
||||
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: quay_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: build-container-arm64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/github-releases-notifier ./cmd/github-releases-notifier
|
||||
|
||||
- name: dryrun
|
||||
image: plugins/docker:18-linux-arm64
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/pull/**
|
||||
depends_on:
|
||||
- build
|
||||
|
||||
- name: publish-dockerhub
|
||||
image: plugins/docker:18-linux-arm64
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
- name: publish-quay
|
||||
image: plugins/docker:18-linux-arm64
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64
|
||||
dockerfile: docker/Dockerfile.arm64
|
||||
password:
|
||||
from_secret: quay_password
|
||||
registry: quay.io
|
||||
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: quay_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: build-container-arm
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang:1.14
|
||||
commands:
|
||||
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
|
||||
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/github-releases-notifier ./cmd/github-releases-notifier
|
||||
|
||||
- name: dryrun
|
||||
image: plugins/docker:18-linux-arm
|
||||
settings:
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
dry_run: true
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/pull/**
|
||||
depends_on:
|
||||
- build
|
||||
|
||||
- name: publish-dockerhub
|
||||
image: plugins/docker:18-linux-arm
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: docker_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
- name: publish-quay
|
||||
image: plugins/docker:18-linux-arm
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm
|
||||
dockerfile: docker/Dockerfile.arm
|
||||
password:
|
||||
from_secret: quay_password
|
||||
registry: quay.io
|
||||
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||
username:
|
||||
from_secret: quay_username
|
||||
when:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
depends_on:
|
||||
- dryrun
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- test
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: notifications
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: manifest-dockerhub
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: true
|
||||
@ -293,23 +360,41 @@ steps:
|
||||
status:
|
||||
- success
|
||||
|
||||
- name: readme
|
||||
image: sheogorath/readme-to-dockerhub
|
||||
environment:
|
||||
DOCKERHUB_PASSWORD:
|
||||
from_secret: docker_password
|
||||
DOCKERHUB_REPO_NAME: github-releases-notifier
|
||||
DOCKERHUB_REPO_PREFIX: xoxys
|
||||
DOCKERHUB_USERNAME:
|
||||
from_secret: docker_username
|
||||
README_PATH: README.md
|
||||
SHORT_DESCRIPTION: Receive Slack notifications for new GitHub releases
|
||||
|
||||
- name: microbadger
|
||||
image: plugins/webhook
|
||||
- name: manifest-quay
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
urls:
|
||||
from_secret: microbadger_url
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
password:
|
||||
from_secret: quay_password
|
||||
spec: docker/manifest-quay.tmpl
|
||||
username:
|
||||
from_secret: quay_username
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
|
||||
- name: pushrm-dockerhub
|
||||
image: chko/docker-pushrm:1
|
||||
environment:
|
||||
DOCKER_PASS:
|
||||
from_secret: docker_password
|
||||
DOCKER_USER:
|
||||
from_secret: docker_username
|
||||
PUSHRM_FILE: README.md
|
||||
PUSHRM_SHORT: GitHub Comment - Drone plugin to add comments to GitHub Issues/PRs
|
||||
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
|
||||
- name: pushrm-quay
|
||||
image: chko/docker-pushrm:1
|
||||
environment:
|
||||
APIKEY__QUAY_IO:
|
||||
from_secret: quay_token
|
||||
PUSHRM_FILE: README.md
|
||||
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
@ -326,6 +411,10 @@ steps:
|
||||
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}"
|
||||
username:
|
||||
from_secret: matrix_username
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
@ -336,13 +425,13 @@ trigger:
|
||||
- failure
|
||||
|
||||
depends_on:
|
||||
- build-container-amd64
|
||||
- build-container-arm64
|
||||
- build-container-arm
|
||||
- build-binaries
|
||||
- build-container-amd64
|
||||
- build-container-arm
|
||||
- build-container-arm64
|
||||
|
||||
---
|
||||
kind: signature
|
||||
hmac: 982d7a70f6cd3914794b3d085b7f949e72445698d9d4af06323239f98cf83058
|
||||
hmac: 7fd3a4a3d079dd575030424aa90c99900def6bd2a7af88449933143009e28d99
|
||||
|
||||
...
|
||||
|
@ -1,5 +0,0 @@
|
||||
# This file is only used for local development
|
||||
GITHUB_TOKEN=XXX
|
||||
INTERVAL=1m
|
||||
LOG_LEVEL=debug
|
||||
SLACK_HOOK=https://hooks.slack.com/services/T02MTEVH7/BASDAHYRZ/XXX...
|
55
.github/settings.yml
vendored
Normal file
55
.github/settings.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
repository:
|
||||
name: github-releases-notifier
|
||||
description: GitHub release notification bot
|
||||
topics: drone, drone-plugin
|
||||
|
||||
private: false
|
||||
has_issues: true
|
||||
has_wiki: false
|
||||
has_downloads: true
|
||||
|
||||
default_branch: master
|
||||
|
||||
allow_squash_merge: true
|
||||
allow_merge_commit: true
|
||||
allow_rebase_merge: true
|
||||
|
||||
labels:
|
||||
- name: bug
|
||||
color: d73a4a
|
||||
description: Something isn't working
|
||||
- name: documentation
|
||||
color: 0075ca
|
||||
description: Improvements or additions to documentation
|
||||
- name: duplicate
|
||||
color: cfd3d7
|
||||
description: This issue or pull request already exists
|
||||
- name: enhancement
|
||||
color: a2eeef
|
||||
description: New feature or request
|
||||
- name: good first issue
|
||||
color: 7057ff
|
||||
description: Good for newcomers
|
||||
- name: help wanted
|
||||
color: 008672
|
||||
description: Extra attention is needed
|
||||
- name: invalid
|
||||
color: e4e669
|
||||
description: This doesn't seem right
|
||||
- name: question
|
||||
color: d876e3
|
||||
description: Further information is requested
|
||||
- name: wontfix
|
||||
color: ffffff
|
||||
description: This will not be worked on
|
||||
|
||||
branches:
|
||||
- name: master
|
||||
protection:
|
||||
required_pull_request_reviews: null
|
||||
required_status_checks:
|
||||
strict: true
|
||||
contexts:
|
||||
- continuous-integration/drone/pr
|
||||
enforce_admins: null
|
||||
restrictions: null
|
@ -1,8 +1,3 @@
|
||||
- FEATURE
|
||||
- add env variable `GITHUB_REPOS`
|
||||
- add env variable `IGNORE_PRE`
|
||||
- BUGFIX
|
||||
- add `required` flag for GitHub token and Slack hook
|
||||
- INTERNAL
|
||||
- provide also binary releases
|
||||
- switch to gomod instead of vendor folder
|
||||
- publish to dockerhub and quay
|
||||
- refactor project structure
|
||||
|
22
LICENSE
22
LICENSE
@ -1,21 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 xoxys
|
||||
Copyright (c) 2020 Robert Kaussow <mail@thegeeklab.de>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
52
README.md
52
README.md
@ -1,46 +1,28 @@
|
||||
# github-releases-notifier
|
||||
|
||||
GitHub release notification bot
|
||||
|
||||
[![Build Status](https://cloud.drone.io/api/badges/xoxys/github-releases-notifier/status.svg)](https://cloud.drone.io/xoxys/github-releases-notifier)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/xoxys/github-releases-notifier)](https://goreportcard.com/report/github.com/xoxyscom/github-releases-notifier)
|
||||
[![Docker Pulls](https://img.shields.io/docker/pulls/xoxys/github-releases-notifier.svg?maxAge=604800)](https://hub.docker.com/r/xoxys/github-releases-notifier)
|
||||
[![Build Status](https://img.shields.io/drone/build/thegeeklab/github-releases-notifier?logo=drone)](https://cloud.drone.io/thegeeklab/github-releases-notifier)
|
||||
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/github-releases-notifier)
|
||||
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/github-releases-notifier)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/thegeeklab/github-releases-notifier)](https://goreportcard.com/report/github.com/thegeeklabcom/github-releases-notifier)
|
||||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/github-releases-notifier)
|
||||
[![License: MIT](https://img.shields.io/github/license/thegeeklab/github-releases-notifier)](<[LICENSE](https://github.com/thegeeklab/github-releases-notifier/blob/master/LICENSE)>)
|
||||
|
||||
Receive Slack notifications if a new release of your favorite software is available on GitHub.
|
||||
|
||||
![screenshot.png](screenshot.png)
|
||||
## Setup
|
||||
|
||||
### Watching repositories
|
||||
1. Get a URL to send WebHooks to your Slack.
|
||||
2. Get a token for scraping GitHub: [https://help.github.com/](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
|
||||
|
||||
To watch repositories simply add them to the list of arguments `-r=kubernetes/kubernetes -r=prometheus/prometheus` and so on.
|
||||
To watch repositories simply add them to the list of arguments e.g. `-r=kubernetes/kubernetes -r=prometheus/prometheus`.
|
||||
|
||||
### Deploying
|
||||
|
||||
1. Get a URL to send WebHooks to your Slack from https://api.slack.com/incoming-webhooks.
|
||||
2. Get a token for scraping GitHub: [https://help.github.com/](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line).
|
||||
|
||||
#### Docker
|
||||
### Docker
|
||||
|
||||
```Shell
|
||||
docker run --rm \
|
||||
-e GITHUB_TOKEN=XXX \
|
||||
-e SLACK_HOOK=https://hooks.slack.com/... \
|
||||
thegeeklab/github-releases-notifier -r=kubernetes/kubernetes
|
||||
```
|
||||
docker run --rm -e GITHUB_TOKEN=XXX -e SLACK_HOOK=https://hooks.slack.com/... xoxys/github-releases-notifier -r=kubernetes/kubernetes
|
||||
```
|
||||
|
||||
#### docker-compose
|
||||
|
||||
1. Change into the `deployments/` folder.
|
||||
2. Open `docker-compose.yml`
|
||||
3. Change the token in the environment section to the ones obtained above.
|
||||
4. `docker-compose up`
|
||||
|
||||
#### Kubernetes
|
||||
|
||||
```bash
|
||||
kubectl create secret generic github-releases-notifier \
|
||||
--from-literal=github=XXX` \
|
||||
--from-literal=slack=XXX
|
||||
```
|
||||
|
||||
After creating the secret with your credentials you can apply the deployment:
|
||||
|
||||
`kubectl apply -f deployments/kubernetes.yml`
|
||||
|
||||
That's it.
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
"github.com/go-kit/kit/log/level"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/shurcooL/githubv4"
|
||||
"github.com/thegeeklab/github-releases-notifier/internal/handler"
|
||||
"github.com/thegeeklab/github-releases-notifier/internal/model"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
@ -70,10 +72,10 @@ func main() {
|
||||
client: githubv4.NewClient(client),
|
||||
}
|
||||
|
||||
releases := make(chan Repository)
|
||||
releases := make(chan model.Repository)
|
||||
go checker.Run(c.Interval, c.Repositories, c.IgnorePre, releases)
|
||||
|
||||
slack := SlackSender{Hook: c.SlackHook}
|
||||
slack := handler.SlackSender{Hook: c.SlackHook}
|
||||
|
||||
level.Info(logger).Log("msg", "waiting for new releases")
|
||||
for repository := range releases {
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
"github.com/shurcooL/githubv4"
|
||||
"github.com/thegeeklab/github-releases-notifier/internal/model"
|
||||
)
|
||||
|
||||
// Checker has a githubv4 client to run queries and also knows about
|
||||
@ -16,14 +17,14 @@ import (
|
||||
type Checker struct {
|
||||
logger log.Logger
|
||||
client *githubv4.Client
|
||||
releases map[string]Repository
|
||||
releases map[string]model.Repository
|
||||
}
|
||||
|
||||
// Run the queries and comparisons for the given repositories in a given interval.
|
||||
func (c *Checker) Run(interval time.Duration, repositories []string,
|
||||
ignorePre bool, releases chan<- Repository) {
|
||||
ignorePre bool, releases chan<- model.Repository) {
|
||||
if c.releases == nil {
|
||||
c.releases = make(map[string]Repository)
|
||||
c.releases = make(map[string]model.Repository)
|
||||
}
|
||||
|
||||
for {
|
||||
@ -78,7 +79,7 @@ func (c *Checker) Run(interval time.Duration, repositories []string,
|
||||
// This should be improved in the future to make batch requests for all watched repositories at once
|
||||
// TODO: https://github.com/shurcooL/githubv4/issues/17
|
||||
|
||||
func (c *Checker) query(owner, name string) (Repository, error) {
|
||||
func (c *Checker) query(owner, name string) (model.Repository, error) {
|
||||
var query struct {
|
||||
Repository struct {
|
||||
ID githubv4.ID
|
||||
@ -109,32 +110,32 @@ func (c *Checker) query(owner, name string) (Repository, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := c.client.Query(ctx, &query, variables); err != nil {
|
||||
return Repository{}, err
|
||||
return model.Repository{}, err
|
||||
}
|
||||
|
||||
repositoryID, ok := query.Repository.ID.(string)
|
||||
if !ok {
|
||||
return Repository{}, fmt.Errorf("can't convert repository id to string: %v", query.Repository.ID)
|
||||
return model.Repository{}, fmt.Errorf("can't convert repository id to string: %v", query.Repository.ID)
|
||||
}
|
||||
|
||||
if len(query.Repository.Releases.Edges) == 0 {
|
||||
return Repository{}, fmt.Errorf("can't find any releases for %s/%s", owner, name)
|
||||
return model.Repository{}, fmt.Errorf("can't find any releases for %s/%s", owner, name)
|
||||
}
|
||||
latestRelease := query.Repository.Releases.Edges[0].Node
|
||||
|
||||
releaseID, ok := latestRelease.ID.(string)
|
||||
if !ok {
|
||||
return Repository{}, fmt.Errorf("can't convert release id to string: %v", query.Repository.ID)
|
||||
return model.Repository{}, fmt.Errorf("can't convert release id to string: %v", query.Repository.ID)
|
||||
}
|
||||
|
||||
return Repository{
|
||||
return model.Repository{
|
||||
ID: repositoryID,
|
||||
Name: string(query.Repository.Name),
|
||||
Owner: owner,
|
||||
Description: string(query.Repository.Description),
|
||||
URL: *query.Repository.URL.URL,
|
||||
|
||||
Release: Release{
|
||||
Release: model.Release{
|
||||
ID: releaseID,
|
||||
Name: string(latestRelease.Name),
|
||||
Description: string(latestRelease.Description),
|
@ -1,17 +0,0 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
github-releases-notifier:
|
||||
restart: always
|
||||
image: justwatch/github-releases-notifier
|
||||
environment:
|
||||
- GITHUB_TOKEN=XXX
|
||||
- SLACK_HOOK=https://hooks.slack.com/services/T02MASDF7/B6WERHYRZ/XXX
|
||||
command:
|
||||
- '-r=golang/go'
|
||||
- '-r=justwatchcom/elasticsearch_exporter'
|
||||
- '-r=justwatchcom/gopass'
|
||||
- '-r=justwatchcom/sql_exporter'
|
||||
- '-r=kubernetes/minikube'
|
||||
- '-r=prometheus/prometheus'
|
||||
- '-r=shurcooL/githubql'
|
@ -1,52 +0,0 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: github-releases-notifier
|
||||
spec:
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 10
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 0
|
||||
maxUnavailable: 1
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: github-releases-notifier
|
||||
spec:
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
containers:
|
||||
- name: github-releases-notifier
|
||||
image: justwatch/github-releases-notifier
|
||||
env:
|
||||
- name: GITHUB_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: github-releases-notifier
|
||||
key: github
|
||||
- name: SLACK_HOOK
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: github-releases-notifier
|
||||
key: slack
|
||||
command:
|
||||
- '/bin/github-releases-notifier'
|
||||
args:
|
||||
- '-r=golang/go'
|
||||
- '-r=justwatchcom/elasticsearch_exporter'
|
||||
- '-r=justwatchcom/gopass'
|
||||
- '-r=justwatchcom/sql_exporter'
|
||||
- '-r=kubernetes/minikube'
|
||||
- '-r=prometheus/prometheus'
|
||||
- '-r=shurcooL/githubql'
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
requests:
|
||||
cpu: 25m
|
||||
memory: 64Mi
|
||||
restartPolicy: Always
|
@ -1,4 +1,10 @@
|
||||
FROM alpine:3.10
|
||||
FROM alpine:3.12
|
||||
|
||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>" \
|
||||
org.label-schema.name="GitHub Release Notifier" \
|
||||
org.label-schema.vendor="Robert Kaussow" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
ADD release/amd64/github-releases-notifier /bin/
|
||||
|
@ -1,4 +1,10 @@
|
||||
FROM alpine:3.10
|
||||
FROM alpine:3.12
|
||||
|
||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>" \
|
||||
org.label-schema.name="GitHub Release Notifier" \
|
||||
org.label-schema.vendor="Robert Kaussow" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
ADD release/arm/github-releases-notifier /bin/
|
||||
|
@ -1,4 +1,10 @@
|
||||
FROM alpine:3.10
|
||||
FROM alpine:3.12
|
||||
|
||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>" \
|
||||
org.label-schema.name="GitHub Release Notifier" \
|
||||
org.label-schema.vendor="Robert Kaussow" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
ADD release/arm64/github-releases-notifier /bin/
|
||||
|
@ -1,4 +1,4 @@
|
||||
image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
image: thegeeklab/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
@ -6,18 +6,18 @@ tags:
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
- image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
||||
- image: thegeeklab/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
|
||||
- image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
||||
- image: thegeeklab/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
|
||||
- image: xoxys/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
||||
- image: thegeeklab/github-releases-notifier:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module github.com/xoxys/github-releases-notifier
|
||||
module github.com/thegeeklab/github-releases-notifier
|
||||
|
||||
go 1.13
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -8,6 +8,8 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/thegeeklab/github-releases-notifier/internal/model"
|
||||
)
|
||||
|
||||
// SlackSender has the hook to send slack notifications.
|
||||
@ -22,7 +24,7 @@ type slackPayload struct {
|
||||
}
|
||||
|
||||
// Send a notification with a formatted message build from the repository.
|
||||
func (s *SlackSender) Send(repository Repository) error {
|
||||
func (s *SlackSender) Send(repository model.Repository) error {
|
||||
payload := slackPayload{
|
||||
Username: "GitHub Releases",
|
||||
IconEmoji: ":github:",
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package model
|
||||
|
||||
import (
|
||||
"net/url"
|
@ -1,4 +1,4 @@
|
||||
package main
|
||||
package model
|
||||
|
||||
import "net/url"
|
||||
|
Loading…
Reference in New Issue
Block a user