Skip to content

Commit b87ab64

Browse files
committed
update workflows and add goreleaser
1 parent 516c0e0 commit b87ab64

File tree

9 files changed

+226
-44
lines changed

9 files changed

+226
-44
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: weekly

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ jobs:
99
name: CI
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-go@v2
12+
- uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 # v3.0.0
13+
- uses: actions/setup-go@f6164bd8c8acb4a71fb2791a8b6c4024ff038dab # v3.0.0
1414
with:
15-
go-version: '^1.15.2'
15+
go-version: 1.18
16+
check-latest: true
1617

1718
- name: Check Style
1819
run: make lint
@@ -21,4 +22,4 @@ jobs:
2122
run: make test
2223

2324
- name: Build
24-
run: make build
25+
run: go build .

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
id-token: write
14+
packages: write
15+
contents: write
16+
17+
env:
18+
GOPATH: ${{ github.workspace }}
19+
GO111MODULE: on
20+
COSIGN_EXPERIMENTAL: "true"
21+
22+
steps:
23+
- uses: actions/setup-go@f6164bd8c8acb4a71fb2791a8b6c4024ff038dab # v3.0.0
24+
with:
25+
go-version: 1.18
26+
check-latest: true
27+
28+
- name: Install cosign
29+
uses: sigstore/cosign-installer@bb61838e7ee5bf314f85f2e219b3706835fa6306 # v2.2.1
30+
31+
- name: Install GoReleaser
32+
uses: goreleaser/goreleaser-action@b953231f81b8dfd023c58e0854a721e35037f28b # v2.9.1
33+
with:
34+
install-only: true
35+
36+
- name: Log into ghcr.io
37+
uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # v1.14.1
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.repository_owner }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Check out code onto GOPATH
44+
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 # v3.0.0
45+
with:
46+
fetch-depth: 1
47+
path: ./src/github.com/${{ github.repository }}
48+
49+
- name: Get TAG
50+
id: get_tag
51+
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
52+
53+
- name: Run goreleaser
54+
working-directory: ./src/github.com/${{ github.repository }}
55+
run: goreleaser release --rm-dist
56+
env:
57+
GIT_TAG: ${{ steps.get_tag.outputs.TAG }}
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ github_actions_exporter
1717

1818
# VSCode
1919
.vscode/
20+
dist/

.goreleaser.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
project_name: github_actions_exporter
2+
3+
env:
4+
- DOCKER_CLI_EXPERIMENTAL=enabled
5+
- COSIGN_EXPERIMENTAL=true
6+
7+
gomod:
8+
proxy: true
9+
10+
snapshot:
11+
name_template: '{{ .Tag }}-SNAPSHOT'
12+
13+
builds:
14+
- binary: github-actions-exporter
15+
goos:
16+
- linux
17+
- darwin
18+
goarch:
19+
- amd64
20+
- arm64
21+
- arm
22+
- s390x
23+
- ppc64le
24+
goarm:
25+
- 7
26+
ldflags: |
27+
-X github.com/prometheus/common/version.Version={{.Version}}
28+
-X github.com/prometheus/common/version.Revision={{.Commit}}
29+
-X github.com/prometheus/common/version.Branch={{.Branch}}
30+
-X github.com/prometheus/common/version.BuildUser=cpanato
31+
-X github.com/prometheus/common/version.BuildDate={{.Date}}
32+
33+
archives:
34+
- format: binary
35+
allow_different_binary_count: true
36+
37+
checksum:
38+
name_template: checksums.txt
39+
40+
signs:
41+
- signature: "${artifact}.sig"
42+
certificate: "${artifact}.pem"
43+
cmd: cosign
44+
args: ["sign-blob", "--output-signature", "${artifact}.sig", "--output-certificate", "${artifact}.pem", "${artifact}"]
45+
artifacts: binary
46+
47+
dockers:
48+
- image_templates:
49+
- "ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-amd64"
50+
use: buildx
51+
dockerfile: Dockerfile
52+
build_flag_templates:
53+
- "--platform=linux/amd64"
54+
- --label=org.opencontainers.image.version={{ .Version }}
55+
- --label=org.opencontainers.image.title={{ .ProjectName }}
56+
- --label=org.opencontainers.image.source=https://github.com/cpanato/{{ .ProjectName }}
57+
- image_templates:
58+
- "ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-arm64"
59+
use: buildx
60+
goarch: arm64
61+
dockerfile: Dockerfile
62+
build_flag_templates:
63+
- "--platform=linux/arm64"
64+
- --label=org.opencontainers.image.version={{ .Version }}
65+
- --label=org.opencontainers.image.title={{ .ProjectName }}
66+
- --label=org.opencontainers.image.source=https://github.com/cpanato/{{ .ProjectName }}
67+
- image_templates:
68+
- "ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-arm"
69+
use: buildx
70+
goarch: arm
71+
goarm: 7
72+
dockerfile: Dockerfile
73+
build_flag_templates:
74+
- "--platform=linux/arm/v7"
75+
- --label=org.opencontainers.image.version={{ .Version }}
76+
- --label=org.opencontainers.image.title={{ .ProjectName }}
77+
- --label=org.opencontainers.image.source=https://github.com/cpanato/{{ .ProjectName }}
78+
- image_templates:
79+
- "ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-s390x"
80+
use: buildx
81+
goarch: s390x
82+
dockerfile: Dockerfile
83+
build_flag_templates:
84+
- "--platform=linux/s390x"
85+
- --label=org.opencontainers.image.version={{ .Version }}
86+
- --label=org.opencontainers.image.title={{ .ProjectName }}
87+
- --label=org.opencontainers.image.source=https://github.com/cpanato/{{ .ProjectName }}
88+
- image_templates:
89+
- "ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-ppc64le"
90+
use: buildx
91+
goarch: ppc64le
92+
dockerfile: Dockerfile
93+
build_flag_templates:
94+
- "--platform=linux/ppc64le"
95+
- --label=org.opencontainers.image.version={{ .Version }}
96+
- --label=org.opencontainers.image.title={{ .ProjectName }}
97+
- --label=org.opencontainers.image.source=https://github.com/cpanato/{{ .ProjectName }}
98+
99+
docker_manifests:
100+
- name_template: ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}
101+
image_templates:
102+
- ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-amd64
103+
- ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-arm64
104+
- ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-arm
105+
- ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-s390x
106+
- ghcr.io/cpanato/{{ .ProjectName }}:{{ .Version }}-ppc64le
107+
108+
docker_signs:
109+
- artifacts: all
110+
args: [ "sign", "${artifact}" ]
111+
112+
release:
113+
github:
114+
owner: cpanato
115+
name: github_actions_exporter
116+
draft: false
117+
prerelease: true

Dockerfile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
ARG ARCH="amd64"
2-
ARG OS="linux"
3-
FROM quay.io/prometheus/busybox:latest
1+
FROM ghcr.io/distroless/busybox:latest
42

5-
ARG ARCH="amd64"
6-
ARG OS="linux"
7-
COPY .build/${OS}-${ARCH}/github_actions_exporter /bin/github_actions_exporter
3+
COPY github-actions-exporter /bin/github-actions-exporter
84

95
USER nobody
10-
ENTRYPOINT ["/bin/github_actions_exporter"]
6+
ENTRYPOINT ["/bin/github-actions-exporter"]
117
EXPOSE 9101

Makefile

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
# Copyright 2015 The Prometheus Authors
2-
# Licensed under the Apache License, Version 2.0 (the "License");
3-
# you may not use this file except in compliance with the License.
4-
# You may obtain a copy of the License at
5-
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7-
#
8-
# Unless required by applicable law or agreed to in writing, software
9-
# distributed under the License is distributed on an "AS IS" BASIS,
10-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
# See the License for the specific language governing permissions and
12-
# limitations under the License.
1+
all:: lint test
132

14-
# Needs to be defined before including Makefile.common to auto-generate targets
15-
DOCKER_ARCHS ?= amd64
16-
DOCKER_IMAGE_NAME ?= github_actions_exporter
3+
.PHONY: lint
4+
lint:
5+
@echo ">> running golangci-lint"
6+
golangci-lint run ./...
177

18-
all:: vet checkmetrics common-all
19-
20-
include Makefile.common
21-
22-
PROMTOOL_DOCKER_IMAGE ?= $(shell docker pull -q quay.io/prometheus/prometheus:latest || echo quay.io/prometheus/prometheus:latest)
23-
PROMTOOL ?= docker run -i --rm -w "$(PWD)" -v "$(PWD):$(PWD)" --entrypoint promtool $(PROMTOOL_DOCKER_IMAGE)
24-
25-
.PHONY: checkmetrics
26-
checkmetrics:
27-
@echo ">> checking metrics for correctness"
28-
for file in test/*.metrics; do $(PROMTOOL) check metrics < $$file || exit 1; done
8+
.PHONY: test
9+
test:
10+
@echo ">> running all tests"
11+
GO111MODULE=on go test -race ./...

go.mod

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/cpanato/github_actions_exporter
22

3-
go 1.15
3+
go 1.18
44

55
require (
66
github.com/go-kit/kit v0.10.0
@@ -9,8 +9,28 @@ require (
99
github.com/prometheus/common v0.15.0
1010
github.com/stretchr/testify v1.7.1
1111
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
12+
gopkg.in/alecthomas/kingpin.v2 v2.2.6
13+
)
14+
15+
require (
16+
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
17+
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
18+
github.com/beorn7/perks v1.0.1 // indirect
19+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
20+
github.com/davecgh/go-spew v1.1.1 // indirect
21+
github.com/go-logfmt/logfmt v0.5.0 // indirect
22+
github.com/golang/protobuf v1.4.3 // indirect
23+
github.com/google/go-querystring v1.1.0 // indirect
24+
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
25+
github.com/pkg/errors v0.9.1 // indirect
26+
github.com/pmezard/go-difflib v1.0.0 // indirect
27+
github.com/prometheus/client_model v0.2.0 // indirect
28+
github.com/prometheus/procfs v0.2.0 // indirect
29+
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
30+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
31+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
1232
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
33+
google.golang.org/appengine v1.6.7 // indirect
1334
google.golang.org/protobuf v1.25.0 // indirect
14-
gopkg.in/alecthomas/kingpin.v2 v2.2.6
1535
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
1636
)

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
2727
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
2828
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
2929
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
30-
github.com/bradleyfalzon/ghinstallation/v2 v2.0.4/go.mod h1:B40qPqJxWE0jDZgOR1JmaMy+4AY1eBP+IByOvqyAKp0=
3130
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
3231
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
3332
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
@@ -74,7 +73,6 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG
7473
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
7574
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
7675
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
77-
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
7876
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
7977
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
8078
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -100,10 +98,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
10098
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
10199
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
102100
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
103-
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
104101
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
105-
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
106-
github.com/google/go-github/v41 v41.0.0/go.mod h1:XgmCA5H323A9rtgExdTcnDkcqp6S30AVACCBDOonIxg=
107102
github.com/google/go-github/v43 v43.0.0 h1:y+GL7LIsAIF2NZlJ46ZoC/D1W1ivZasT0lnWHMYPZ+U=
108103
github.com/google/go-github/v43 v43.0.0/go.mod h1:ZkTvvmCXBvsfPpTHXnH/d2hP9Y0cTbvN9kr5xqyXOIc=
109104
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=

0 commit comments

Comments
 (0)