Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hsn723 committed Oct 31, 2023
0 parents commit f35061a
Show file tree
Hide file tree
Showing 27 changed files with 1,477 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION @hsn723
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
reviewers:
- "Hsn723"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
reviewers:
- "Hsn723"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
reviewers:
- "Hsn723"
19 changes: 19 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pull_request_rules:
- name: Automatic merge
conditions:
- "#approved-reviews-by>=1"
- "#review-requested=0"
- "#changes-requested-reviews-by=0"
actions:
merge:
method: squash
- name: Automatic merge for dependabot
conditions:
- author~=^dependabot\[bot\]$
- title~=^Bump [^\s]+ from ([\d]+)\.([\d]+)\..+ to \1\.\2\.
- label!=github_actions
actions:
review:
type: APPROVE
merge:
method: squash
17 changes: 17 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
changelog:
categories:
- title: Breaking Changes
labels:
- breaking-change
- title: New Features
labels:
- feature
- title: Bug Fixes
labels:
- bug
- title: Dependencies and Chore
labels:
- dependencies
- title: Other Changes
labels:
- "*"
98 changes: 98 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: main
on:
push:
branches:
- '**'
tags-ignore:
- '*'
env:
go-version: stable
python-version: 3.x
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
- name: Lint
uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
check-goreleaser-config:
name: Check goreleaser.yml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: check -f .goreleaser.yml
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
- name: Verify
run: make verify
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
- name: Test
run: make test
dry-run:
name: Dry-run release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: anchore/sbom-action/download-syft@v0.14.3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}
- name: GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --snapshot --skip=sign,publish,sbom --clean
- name: Test built containers
run: make container-structure-test
tag:
name: Tag release
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: [lint, verify, check-goreleaser-config, test, dry-run]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Tag release
run: |
TAG="v$(cat VERSION)"
git tag ${TAG}
git push origin ${TAG} || true
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: release
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: sigstore/cosign-installer@v3.1.2
- uses: anchore/sbom-action/download-syft@v0.14.3
- name: GHCR Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.PAT }}
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: stable
- name: GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode
artifacts/
bin/
dist/
rdap-exporter
*.out
18 changes: 18 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
linters:
enable:
- dupl
- ginkgolinter
- gocheckcompilerdirectives
- gocognit
- goconst
- gocyclo
- godot
- gofmt
- revive
- typecheck
- unparam
run:
timeout: 5m
build-tags:
- test
- e2e
90 changes: 90 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
project_name: rdap-exporter
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s
- -w
- -X github.com/hsn723/rdap-exporter/cmd.version={{.Version}}
- -X github.com/hsn723/rdap-exporter/cmd.commit={{.Commit}}
- -X github.com/hsn723/rdap-exporter/cmd.date={{.Date}}
- -X github.com/hsn723/rdap-exporter/cmd.builtBy=goreleaser
dockers:
- image_templates:
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-amd64"
use: buildx
dockerfile: Dockerfile
extra_files:
- LICENSE
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- image_templates:
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-arm64"
use: buildx
goarch: arm64
dockerfile: Dockerfile
extra_files:
- LICENSE
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
docker_manifests:
- name_template: "ghcr.io/hsn723/{{.ProjectName}}:latest"
image_templates:
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-amd64"
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-arm64"
- name_template: "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}"
image_templates:
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-amd64"
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-arm64"
- name_template: "ghcr.io/hsn723/{{.ProjectName}}:{{ .Major }}.{{ .Minor }}"
image_templates:
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-amd64"
- "ghcr.io/hsn723/{{.ProjectName}}:{{ .Version }}-arm64"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
use: github-native
source:
enabled: true
sboms:
- id: archive
artifacts: archive
- id: source
artifacts: source
signs:
- cmd: cosign
certificate: '${artifact}.pem'
args:
- sign-blob
- --yes
- '--output-certificate=${certificate}'
- '--output-signature=${signature}'
- '${artifact}'
artifacts: all
output: true
docker_signs:
- cmd: cosign
artifacts: all
output: true
args:
- 'sign'
- --yes
- '${artifact}'
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
default_stages: [commit]
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.51.0
hooks:
- id: golangci-lint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: end-of-file-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ghcr.io/cybozu/ubuntu:22.04.20231031 as certs

FROM scratch
LABEL org.opencontainers.image.authors="Hsn723" \
org.opencontainers.image.title="rdap-exporter" \
org.opencontainers.image.source="https://github.com/hsn723/rdap-exporter"
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY LICENSE /LICENSE
COPY rdap-exporter /

USER 65534:65534

ENTRYPOINT [ "/rdap-exporter" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Hsn723

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:

The above copyright notice and this permission notice 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.
Loading

0 comments on commit f35061a

Please sign in to comment.