Skip to content

Commit

Permalink
rework: remplace promu by goreleaser, replace travis by github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
psycofdj authored and benjaminguttmann-avtq committed Oct 26, 2022
1 parent 5df5379 commit 3431224
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 144 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
68 changes: 68 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: goreleaser

on:
push:
# not not consider simplec commit
branches:
- '!*'
# consider only release and pre-release tags
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: set up go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: cache go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: tests modules
run: |
go mod vendor
if [ ! -z "$(git status --porcelain)" ]; then
echo "::error::vendor directory if not synched with go.mod, please run go mod vendor"
exit 1
fi
go mod tidy
if [ ! -z "$(git status --porcelain)" ]; then
echo "::error::modules are not tidy, please run go mod tidy"
exit 1
fi
- name: tests
run: |
go test -v ./...
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: run goreleaser
uses: goreleaser/goreleaser-action@v2
if: success() && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: github-actions

6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/.build
/.release
/.tarballs
/dist
/cf_exporter
*.tar.gz
*.test
*-stamp
97 changes: 97 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
project_name: cf_exporter

builds:
- id: binary
dir: .
main: ./main.go
binary: cf_exporter
env:
- CGO_ENABLED=0
ldflags:
- -s
- -w
- -X github.com/prometheus/common/version.Version={{.Version}}
- -X github.com/prometheus/common/version.Revision={{.FullCommit}}
- -X github.com/prometheus/common/version.Branch={{.Branch}}
- -X github.com/prometheus/common/version.BuildUser={{.Env.USER}}
- -X github.com/prometheus/common/version.BuildDate={{.Date}}
- -X code.cloudfoundry.org/cli/version/binaryVersion={{.Version}}
goos:
- linux
- darwin
- windows
goarch:
- amd64
- 386
- arm
- arm64
- ppc64
- ppc64le
goarm: [5,6,7]
ignore:
- goos: darwin
goarch: arm
- goos: darwin
goarch: arm64
- goos: darwin
goarch: ppc64
- goos: darwin
goarch: ppc64le
- goos: darwin
goarch: 386
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
- goos: windows
goarch: ppc64
- goos: windows
goarch: ppc64le

archives:
- id: archives
builds: [binary]
format: "tar.gz"
name_template: '{{ .ProjectName }}_{{ .Version }}.{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}'
wrap_in_directory: true
files:
- LICENSE
- NOTICE
- README*
- CHANGELOG*
- docs/*
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
use: github
filters:
exclude:
- 'docs'
- '\.md'

checksum:
name_template: checksums.txt
algorithm: sha256

dockers:
- goos: linux
goarch: amd64
dockerfile: ./packages/docker/Dockerfile
image_templates:
- "boshprometheus/cf-exporter:latest"
- "boshprometheus/cf-exporter:{{ .Tag }}"
- "boshprometheus/cf-exporter:v{{ .Major }}"
- "boshprometheus/cf-exporter:v{{ .Major }}.{{ .Minor }}"
build_flag_templates:
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"

release:
prerelease: auto
name_template: '{{.Tag}}'
29 changes: 0 additions & 29 deletions .promu.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

64 changes: 0 additions & 64 deletions Makefile

This file was deleted.

1 change: 0 additions & 1 deletion Procfile

This file was deleted.

1 change: 0 additions & 1 deletion VERSION

This file was deleted.

4 changes: 2 additions & 2 deletions packages/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM quay.io/prometheus/busybox:latest
MAINTAINER Ferran Rodenas <frodenas@gmail.com>

COPY cf_exporter /bin/cf_exporter
ADD cf_exporter /bin/cf_exporter

ENTRYPOINT ["/bin/cf_exporter"]
EXPOSE 9193
EXPOSE 9193

0 comments on commit 3431224

Please sign in to comment.