Skip to content

Commit

Permalink
fix: public release
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxd committed Apr 4, 2024
0 parents commit a4db12a
Show file tree
Hide file tree
Showing 20 changed files with 3,331 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
docs/
README.md
Dockerfile
.git
.gitattributes
.gitignore
.github
oxidized-exporter
.venv
119 changes: 119 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
on:
push:
branches:
- "*"
tags:
- "v*.*.*"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Setup
run: make setup

- name: Run pre-commit
run: make pre-commit-all
env:
SKIP: "no-commit-to-branch"

container:
runs-on: ubuntu-latest
needs:
- test
- pre-commit
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/akquinet/oxidized-exporter
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to GHCR
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/main')
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push master Docker image
uses: docker/[email protected]
with:
context: .
push: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/main') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

release-binary:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- pre-commit
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CICD_APP_ID }}
private-key: ${{ secrets.CICD_APP_PRIVATE_KEY }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: "${{ steps.generate_token.outputs.token }}"

semantic-release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- pre-commit
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CICD_APP_ID }}
private-key: ${{ secrets.CICD_APP_PRIVATE_KEY }}

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
env:
GITHUB_TOKEN: "${{ steps.generate_token.outputs.token }}"
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
oxidized-exporter
.venv/
venv/
bin/

# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

dist/
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
project_name: oxidized-exporter

before:
hooks:
- go mod tidy
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath
# ldflags:
# - -s
# - -w
goarch:
- amd64
- arm64
goos:
- linux
archives:
- format: binary
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
algorithm: sha256
release:
draft: false
changelog:
skip: true
nfpms:
- package_name: "oxidized-exporter"
maintainer: rwxd <[email protected]>
description: "Oxidzed Prometheus Exporter to expose metrics from oxidized"
formats:
- deb
- rpm
upx:
- enabled: true
# Valid options are from '1' (faster) to '9' (better), and 'best'.
compress: best
# Whether to try LZMA (slower).
lzma: true
# Whether to try all methods and filters (slow).
brute: false
goos:
- linux
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-added-large-files
- id: check-json
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: no-commit-to-branch
- id: requirements-txt-fixer
- id: trailing-whitespace
args: ["--markdown-linebreak-ext=md"]

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-vet
- id: go-mod-tidy
- id: go-build
11 changes: 11 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/github"

branches:
- "main"
- "+([0-9])?(.{+([0-9]),x}).x"
- name: "alpha"
prerelease: "alpha"
93 changes: 93 additions & 0 deletions .renovaterc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
":disableDependencyDashboard"
],
"reviewers": [],
"pre-commit": {
"enabled": true
},
"pip_requirements": {
"fileMatch": [
"(^|/)([\\w-]*)requirements\\.(txt|pip)$",
"(^|/)([\\w-]*)requirements-dev\\.(txt|pip)$"
]
},
"packageRules": [
{
"packagePatterns": [
".*"
],
"semanticCommitType": "fix"
},
{
"matchUpdateTypes": [
"patch",
"pin",
"digest"
],
"automerge": false
},
{
"matchDatasources": [
"pypi"
],
"matchFiles": [
"requirements-dev.txt"
],
"semanticCommitType": "chore"
},
{
"matchDatasources": [
"pypi"
],
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": false
},
{
"matchDatasources": [
"pypi"
],
"matchPackageNames": [
"pre-commit",
"flake8",
"pylint",
"mypy",
"pytest",
"pytest-cov",
"black"
],
"groupName": "python-dev-deps",
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": true,
"semanticCommitType": "chore"
},
{
"matchManagers": [
"pre-commit"
],
"matchPackageNames": [
"hadolint/hadolint",
"asottile/pyupgrade",
"pre-commit/pre-commit-hooks",
"pre-commit/mirrors-mypy",
"PyCQA/flake8",
"pycqa/isort"
],
"automerge": true,
"semanticCommitType": "chore",
"groupName": "pre-commit-hooks"
}
]
}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM docker.io/golang:1.22 as builder

# Set destination for COPY
WORKDIR /app

# Download Go modules
COPY go.mod go.sum ./
RUN go mod download -x

# Copy the source from the current directory to the Working Directory inside the container
COPY . ./

# Build
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./oxidized-exporter

FROM docker.io/alpine:3.18.0

# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/oxidized-exporter /oxidized-exporter

ENTRYPOINT ["/oxidized-exporter"]
Loading

0 comments on commit a4db12a

Please sign in to comment.