diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 088c8ba..0000000 --- a/.drone.yml +++ /dev/null @@ -1,670 +0,0 @@ ---- -kind: pipeline -type: kubernetes -name: linter - -clone: - disable: true - -platform: - os: linux - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: markdown lint - commands: - - markdownlint *.md - image: git.cryptic.systems/volker.raschek/markdownlint:0.44.0 - resources: - limits: - cpu: 150 - memory: 150M - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - resources: - limits: - cpu: 150 - memory: 150M - when: - status: - - changed - - failure - -trigger: - event: - exclude: - - tag - ---- -kind: pipeline -type: docker -name: dry-run-amd64 - -clone: - disable: true - -depends_on: -- linter - -platform: - os: linux - arch: amd64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build - image: docker.io/plugins/docker:20.18.8 - settings: - auto_tag: false - dockerfile: Dockerfile - dry_run: true - force_tag: true - no_cache: true - purge: true - mirror: - from_secret: docker_io_mirror - registry: git.cryptic.systems - repo: git.cryptic.systems/volker.raschek/getidev - tags: latest-amd64 - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - when: - status: - - changed - - failure - -trigger: - branch: - exclude: - - master - event: - - pull_request - - push - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: docker -name: dry-run-arm64-v8 - -clone: - disable: true - -depends_on: -- linter - -platform: - os: linux - arch: arm64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build - image: docker.io/plugins/docker:20.18.8 - settings: - auto_tag: false - dockerfile: Dockerfile - dry_run: true - force_tag: true - no_cache: true - purge: true - mirror: - from_secret: docker_io_mirror - registry: git.cryptic.systems - repo: git.cryptic.systems/volker.raschek/getidev - tags: latest-arm64-v8 - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - when: - status: - - changed - - failure - -trigger: - branch: - exclude: - - master - event: - - pull_request - - push - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: docker -name: latest-amd64 - -clone: - disable: true - -depends_on: -- linter - -platform: - os: linux - arch: amd64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build - image: docker.io/plugins/docker:20.18.8 - settings: - auto_tag: false - dockerfile: Dockerfile - force_tag: true - no_cache: true - purge: true - mirror: - from_secret: docker_io_mirror - registry: git.cryptic.systems - repo: git.cryptic.systems/volker.raschek/getidev - tags: latest-amd64 - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - when: - status: - - changed - - failure - -trigger: - branch: - - master - event: - - cron - - push - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: docker -name: latest-arm64-v8 - -clone: - disable: true - -depends_on: -- linter - -platform: - os: linux - arch: arm64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build - image: docker.io/plugins/docker:20.18.8 - settings: - auto_tag: false - dockerfile: Dockerfile - force_tag: true - no_cache: true - purge: true - mirror: - from_secret: docker_io_mirror - registry: git.cryptic.systems - repo: git.cryptic.systems/volker.raschek/getidev - tags: latest-arm64-v8 - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - when: - status: - - changed - - failure - -trigger: - branch: - - master - event: - - cron - - push - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: kubernetes -name: latest-manifest - -clone: - disable: true - -depends_on: -- latest-amd64 -- latest-arm64-v8 - -# docker.io/plugins/manifest only for amd64 architectures available -node_selector: - kubernetes.io/os: linux - kubernetes.io/arch: amd64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build-manifest - image: docker.io/plugins/manifest:1.4.0 - settings: - auto_tag: false - ignore_missing: true - spec: manifest.tmpl - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - resources: - limits: - cpu: 150 - memory: 150M - when: - status: - - changed - - failure - -trigger: - branch: - - master - event: - - cron - - push - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: kubernetes -name: latest-sync - -clone: - disable: true - -depends_on: -- latest-manifest - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: latest-sync - commands: - - skopeo sync --all --src=docker --src-creds=$SRC_CRED_USERNAME:$SRC_CRED_PASSWORD --dest=docker --dest-creds=$DEST_CRED_USERNAME:$DEST_CRED_PASSWORD git.cryptic.systems/volker.raschek/getidev docker.io/volkerraschek - environment: - SRC_CRED_USERNAME: - from_secret: git_cryptic_systems_container_registry_user - SRC_CRED_PASSWORD: - from_secret: git_cryptic_systems_container_registry_password - DEST_CRED_USERNAME: - from_secret: container_image_registry_user - DEST_CRED_PASSWORD: - from_secret: container_image_registry_password - image: quay.io/skopeo/stable:v1.18.0 - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - resources: - limits: - cpu: 150 - memory: 150M - when: - status: - - changed - - failure - -trigger: - branch: - - master - event: - - cron - - push - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: docker -name: tagged-amd64 - -clone: - disable: true - -platform: - os: linux - arch: amd64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build - image: docker.io/plugins/docker:20.18.8 - settings: - auto_tag: true - auto_tag_suffix: amd64 - dockerfile: Dockerfile - force_tag: true - no_cache: true - purge: true - mirror: - from_secret: docker_io_mirror - registry: git.cryptic.systems - repo: git.cryptic.systems/volker.raschek/getidev - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - build_args: - - VERSION=${DRONE_TAG} - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - when: - status: - - changed - - failure - -trigger: - event: - - tag - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: docker -name: tagged-arm64-v8 - -clone: - disable: true - -platform: - os: linux - arch: arm64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build - image: docker.io/plugins/docker:20.18.8 - settings: - auto_tag: true - auto_tag_suffix: arm64-v8 - dockerfile: Dockerfile - force_tag: true - no_cache: true - purge: true - mirror: - from_secret: docker_io_mirror - registry: git.cryptic.systems - repo: git.cryptic.systems/volker.raschek/getidev - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - build_args: - - VERSION=${DRONE_TAG} - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - when: - status: - - changed - - failure - -trigger: - event: - - tag - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: kubernetes -name: tagged-manifest - -clone: - disable: true - -depends_on: -- tagged-amd64 -- tagged-arm64-v8 - -# docker.io/plugins/manifest only for amd64 architectures available -node_selector: - kubernetes.io/os: linux - kubernetes.io/arch: amd64 - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: build-manifest - image: docker.io/plugins/manifest:1.4.0 - settings: - auto_tag: true - ignore_missing: true - spec: manifest.tmpl - username: - from_secret: git_cryptic_systems_container_registry_user - password: - from_secret: git_cryptic_systems_container_registry_password - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - resources: - limits: - cpu: 150 - memory: 150M - when: - status: - - changed - - failure - -trigger: - event: - - tag - repo: - - volker.raschek/getidev - ---- -kind: pipeline -type: kubernetes -name: tagged-sync - -clone: - disable: true - -depends_on: -- tagged-manifest - -steps: -- name: clone - image: git.cryptic.systems/volker.raschek/git:1.4.0 - -- name: tagged-sync - commands: - - skopeo sync --all --src=docker --src-creds=$SRC_CRED_USERNAME:$SRC_CRED_PASSWORD --dest=docker --dest-creds=$DEST_CRED_USERNAME:$DEST_CRED_PASSWORD git.cryptic.systems/volker.raschek/getidev docker.io/volkerraschek - environment: - SRC_CRED_USERNAME: - from_secret: git_cryptic_systems_container_registry_user - SRC_CRED_PASSWORD: - from_secret: git_cryptic_systems_container_registry_password - DEST_CRED_USERNAME: - from_secret: container_image_registry_user - DEST_CRED_PASSWORD: - from_secret: container_image_registry_password - image: quay.io/skopeo/stable:v1.18.0 - -- name: email-notification - environment: - SMTP_FROM_ADDRESS: - from_secret: smtp_from_address - SMTP_FROM_NAME: - from_secret: smtp_from_name - SMTP_HOST: - from_secret: smtp_host - SMTP_USERNAME: - from_secret: smtp_username - SMTP_PASSWORD: - from_secret: smtp_password - image: git.cryptic.systems/volker.raschek/drone-email:0.1.5 - resources: - limits: - cpu: 150 - memory: 150M - when: - status: - - changed - - failure - -trigger: - event: - - tag - repo: - - volker.raschek/getidev diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index eb22dd6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,10 +0,0 @@ -# checkout alls text files with end of line = line feed -* text eol=lf - -# Binary files should be checked in and out as binary -*.png binary -*.jpg binary -*.eot binary -*.ttf binary -*.pkcs8 binary -*.pkcs12 binary \ No newline at end of file diff --git a/.gitea/workflows/golang-linters.yaml b/.gitea/workflows/golang-linters.yaml new file mode 100644 index 0000000..af61dec --- /dev/null +++ b/.gitea/workflows/golang-linters.yaml @@ -0,0 +1,29 @@ +name: "Lint Golang files" + +on: + pull_request: + types: [ "opened", "reopened", "synchronize" ] + push: + branches: [ '**' ] + tags-ignore: [ '**' ] + workflow_dispatch: {} + +permissions: + contents: read + +jobs: + golangci: + name: "Run golang CI linter" + runs-on: ${{ matrix.os }} + strategy: + matrix: + go: [ stable ] + os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ] + steps: + - uses: actions/checkout@v4.3.0 + - uses: actions/setup-go@v5.5.0 + with: + go-version: ${{ matrix.go }} + - uses: golangci/golangci-lint-action@v8.0.0 + with: + version: v2.3.0 # renovate: datasource=github-releases depName=golangci/golangci-lint diff --git a/.gitea/workflows/golang-tests.yaml b/.gitea/workflows/golang-tests.yaml new file mode 100644 index 0000000..a689b4a --- /dev/null +++ b/.gitea/workflows/golang-tests.yaml @@ -0,0 +1,42 @@ +name: "Run Golang tests" + +on: + pull_request: + types: [ "opened", "reopened", "synchronize" ] + push: + branches: [ '**' ] + tags-ignore: [ '**' ] + workflow_dispatch: {} + +jobs: + # integration-test: + # name: "Run integration tests" + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # go: [ stable ] + # os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ] + # steps: + # - uses: actions/checkout@v4.3.0 + # - uses: actions/setup-go@v5.5.0 + # with: + # go-version: ${{ matrix.go }} + # - env: + # GOPROXY: ${{ vars.GOPROXY }} + # run: make test/integration + + unit-test: + name: "Run unit tests" + runs-on: ${{ matrix.os }} + strategy: + matrix: + go: [ stable ] + os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ] + steps: + - uses: actions/checkout@v4.3.0 + - uses: actions/setup-go@v5.5.0 + with: + go-version: ${{ matrix.go }} + - env: + GOPROXY: ${{ vars.GOPROXY }} + run: make test/unit diff --git a/.gitea/workflows/markdown-linters.yaml b/.gitea/workflows/markdown-linters.yaml new file mode 100644 index 0000000..7ce9fce --- /dev/null +++ b/.gitea/workflows/markdown-linters.yaml @@ -0,0 +1,19 @@ +name: "Lint Markdown files" + +on: + pull_request: + types: [ "opened", "reopened", "synchronize" ] + push: + branches: [ '*' ] + tags-ignore: [ '*' ] + workflow_dispatch: {} + +jobs: + markdown-lint: + name: "Run markdown linter" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.3.0 + - uses: DavidAnson/markdownlint-cli2-action@v20.0.0 + with: + globs: '**/*.md' diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..d120aea --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,52 @@ +name: "Release" + +on: + push: + tags: [ '**' ] + +permissions: + contents: write + +jobs: + release: + name: "Release application" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.3.0 + - uses: docker/setup-qemu-action@v3.6.0 + - uses: actions/setup-go@v5.5.0 + with: + go-version: stable + - uses: docker/login-action@v3.5.0 + with: + registry: git.cryptic.systems + username: ${{ github.repository_owner }} + password: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} + - env: + GITEA_TOKEN: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} + GONOSUMDB: ${{ vars.GONOSUMDB }} + GOPROXY: ${{ vars.GOPROXY }} + uses: goreleaser/goreleaser-action@v6.3.0 + with: + version: v2.11.2 # renovate: datasource=github-releases depName=goreleaser/goreleaser + args: release --clean + # sync-to-hub-docker-io: + # name: "Upload Images to docker.io" + # needs: + # - release + # runs-on: ubuntu-latest + # steps: + # - name: Copy images to docker.io + # run: | + # TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm') + + # apt-get update --yes + # apt-get install --yes skopeo + # skopeo copy \ + # --all \ + # --dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \ + # --dest-username ${{ secrets.DOCKER_IO_USERNAME }} \ + # --src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \ + # --src-username volker.raschek \ + # docker://git.cryptic.systems/volker.raschek/getidev:${TAG} \ + # docker://docker.io/volkerraschek/getidev:${TAG} diff --git a/.gitea/workflows/update-docker-hub-description.yaml b/.gitea/workflows/update-docker-hub-description.yaml new file mode 100644 index 0000000..e1cbbe6 --- /dev/null +++ b/.gitea/workflows/update-docker-hub-description.yaml @@ -0,0 +1,19 @@ +# name: "Update Docker Hub Description" + +# on: +# push: +# branches: [ 'master' ] +# paths: [ 'README.md' ] +# workflow_dispatch: {} + +# jobs: +# update-description-on-hub-docker-io: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4.3.0 +# - uses: peter-evans/dockerhub-description@v4.0.2 +# with: +# username: ${{ secrets.DOCKER_IO_USERNAME }} +# password: ${{ secrets.DOCKER_IO_PASSWORD }} +# repository: volkerraschek/getidev +# readme-filepath: README.md diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..9e02d10 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,13 @@ +version: "2" +linters: + default: standard + enable: + - errname + - gosec + + exclusions: + rules: [] + warn-unused: true + +run: + tests: true diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index 2720fb1..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,27 +0,0 @@ -run: - timeout: 10m - tests: true - -linters: - disable-all: true - enable: - # Default - - deadcode - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - structcheck - - typecheck - - unused - - varcheck - - # Additionally linters - - bodyclose - - misspell - - nilerr - - rowserrcheck - - sqlclosecheck - - unparam - - whitespace \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..696dc60 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,175 @@ +project_name: getidev + +archives: +- formats: [ "tar.xz" ] + files: + - README.md + - LICENSE + +before: + hooks: + - go mod tidy + +builds: +- main: main.go + binary: >- + {{ .ProjectName }}- + {{- .Version }}- + {{- .Os }}- + {{- if eq .Arch "amd64" }}amd64 + {{- else if eq .Arch "amd64_v1" }}amd64 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}-{{ .Arm }}{{ end }} + env: + - CGO_ENABLED=0 + - GONOSUMDB={{ .Env.GONOSUMDB }} + - GOPROXY={{ .Env.GOPROXY }} + goos: + - linux + goarch: + - amd64 + - arm + - arm64 + - riscv64 + goarm: + - "6" + - "7" + flags: + - -trimpath + ldflags: + - -s -w -X 'main.version={{ trimprefix .Tag "v" }}' + +changelog: + filters: + exclude: + - '^chore' + - '^docs' + - '^test' + - Merge pull request + - Merge branch + - go mod tidy + format: "{{.SHA}}: {{.Message}} (@{{.AuthorUsername}})" + groups: + - title: Features + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 0 + - title: "Bug fixes" + regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + order: 1 + - title: Others + order: 999 + sort: asc + use: git + +dockers: +- build_flag_templates: + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.documentation={{ .ProjectName }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.source={{ .GitURL }} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }} + - --platform=linux/amd64 + - --pull + dockerfile: Dockerfile + goarch: amd64 + goos: linux + image_templates: + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64' + skip_push: false + use: buildx + +- build_flag_templates: + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.documentation={{ .ProjectName }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.source={{ .GitURL }} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }} + - --platform=linux/arm/v6 + - --pull + dockerfile: Dockerfile + goarch: arm + goarm: "6" + goos: linux + image_templates: + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6' + skip_push: false + use: buildx + +- build_flag_templates: + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.documentation={{ .ProjectName }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.source={{ .GitURL }} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }} + - --platform=linux/arm/v7 + - --pull + dockerfile: Dockerfile + goarch: arm + goarm: "7" + goos: linux + image_templates: + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7' + skip_push: false + use: buildx + +- build_flag_templates: + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.documentation={{ .ProjectName }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.source={{ .GitURL }} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }} + - --platform=linux/arm64 + - --pull + dockerfile: Dockerfile + goarch: arm64 + goos: linux + image_templates: + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64' + skip_push: false + use: buildx + +- build_flag_templates: + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.documentation={{ .ProjectName }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.source={{ .GitURL }} + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }} + - --platform=linux/riscv64 + - --pull + dockerfile: Dockerfile + goarch: riscv64 + goos: linux + image_templates: + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-riscv64' + skip_push: false + use: buildx + +docker_manifests: +- name_template: 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}' + image_templates: + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64' + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6' + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7' + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64' + - 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-riscv64' + +gitea_urls: + api: https://git.cryptic.systems/api/v1 + download: https://git.cryptic.systems + +version: 2 diff --git a/.markdownlint.yaml b/.markdownlint.yaml index c067848..34c4081 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -45,11 +45,11 @@ MD012: # MD013/line-length - Line length MD013: # Number of characters - line_length: 80 + line_length: 120 # Number of characters for headings - heading_line_length: 80 + heading_line_length: 120 # Number of characters for code blocks - code_block_line_length: 80 + code_block_line_length: 120 # Include code blocks code_blocks: false # Include tables @@ -68,10 +68,6 @@ MD022: # Blank lines below heading lines_below: 1 -# MD024/no-duplicate-heading/no-duplicate-header - Multiple headings with the same content -MD024: - siblings_only: false - # MD025/single-title/single-h1 - Multiple top-level headings in the same document MD025: # Heading level @@ -125,8 +121,7 @@ MD041: # MD044/proper-names - Proper names should have the correct capitalization MD044: # List of proper names - names: - - oas-collector + names: [] # Include code blocks code_blocks: false @@ -138,4 +133,4 @@ MD046: # MD048/code-fence-style - Code fence style MD048: # Code fence syle - style: "backtick" \ No newline at end of file + style: "backtick" diff --git a/Dockerfile b/Dockerfile index 1715156..571690e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,5 @@ -FROM docker.io/library/golang:1.22.3-alpine3.18 as build +FROM scratch AS build -ARG VERSION - -COPY ./ /workspace - -WORKDIR /workspace - -RUN set -ex && \ - apk update && \ - apk add git make && \ - make all VERSION=${VERSION} - -# TARGET -# ===================================================================== -FROM docker.io/library/alpine:3.21 - -ARG VERSION=latest - -LABEL org.opencontainers.image.authors="Markus Pesch" \ - org.opencontainers.image.description="Return network interface names" \ - org.opencontainers.image.documentation="https://git.cryptic.systems/volker.raschek/getidev#getidev" \ - org.opencontainers.image.title="getidev" \ - org.opencontainers.image.vendor="Markus Pesch" \ - org.opencontainers.image.version="${VERSION}" - -COPY --from=build /workspace/getidev /usr/bin/getidev +COPY getidev-* /usr/bin/app ENTRYPOINT [ "/usr/bin/getidev" ] diff --git a/Makefile b/Makefile index f313601..076ac94 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,58 @@ -# VERSION +EXECUTABLE=getidev VERSION?=$(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD) +# Destination directory and prefix to place the compiled binaries, documentaions +# and other files. +DESTDIR?= +PREFIX?=/usr/local + # CONTAINER_RUNTIME +# The CONTAINER_RUNTIME variable will be used to specified the path to a +# container runtime. This is needed to start and run a container image. CONTAINER_RUNTIME?=$(shell which podman) -# CONTAINER_IMAGE -CONTAINER_IMAGE_REGISTRY_HOST?=git.cryptic.systems -CONTAINER_IMAGE_REPOSITORY=volker.raschek/getidev -CONTAINER_IMAGE_VERSION?=latest -CONTAINER_IMAGE_FULLY_QUALIFIED=${CONTAINER_IMAGE_REGISTRY_HOST}/${CONTAINER_IMAGE_REPOSITORY}:${CONTAINER_IMAGE_VERSION} +# GETIDEV_IMAGE_REGISTRY_NAME +# Defines the name of the new container to be built using several variables. +GETIDEV_IMAGE_REGISTRY_NAME:=git.cryptic.systems +GETIDEV_IMAGE_REGISTRY_USER:=volker.raschek -# EXECUTABLES +GETIDEV_IMAGE_NAMESPACE?=${GETIDEV_IMAGE_REGISTRY_USER} +GETIDEV_IMAGE_NAME:=${EXECUTABLE} +GETIDEV_IMAGE_VERSION?=latest +GETIDEV_IMAGE_FULLY_QUALIFIED=${GETIDEV_IMAGE_REGISTRY_NAME}/${GETIDEV_IMAGE_NAMESPACE}/${GETIDEV_IMAGE_NAME}:${GETIDEV_IMAGE_VERSION} + +# BIN # ============================================================================== -EXECUTABLE_TARGETS=getidev - -PHONY=all -all: clean ${EXECUTABLE_TARGETS} - getidev: - go build -tags netgo -ldflags "-X main.version=${VERSION}" -o ${@} main.go + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go build -ldflags "-X 'main.version=${VERSION}'" -o ${@} main.go # CLEAN # ============================================================================== PHONY+=clean clean: - rm -f -r $(shell pwd)/getidev* + rm --force --recursive getidev + +# TESTS +# ============================================================================== +PHONY+=test/unit +test/unit: + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go test -v -p 1 -coverprofile=coverage.txt -covermode=count -timeout 1200s ./pkg/... + +# PHONY+=test/integration +# test/integration: +# CGO_ENABLED=0 \ +# GOPROXY=$(shell go env GOPROXY) \ +# go test -v -p 1 -count=1 -timeout 1200s ./it/... + +PHONY+=test/coverage +test/coverage: test/unit + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go tool cover -html=coverage.txt # GOLANGCI-LINT # ============================================================================== @@ -32,61 +60,55 @@ PHONY+=golangci-lint golangci-lint: golangci-lint run --concurrency=$(shell nproc) -# GOSEC +# INSTALL # ============================================================================== -PHONY+=gosec -gosec: - gosec $(shell pwd)/... +PHONY+=uninstall +install: getidev + install --directory ${DESTDIR}/etc/bash_completion.d + ./getidev completion bash > ${DESTDIR}/etc/bash_completion.d/${EXECUTABLE} -# CONTAINER-IMAGE + install --directory ${DESTDIR}${PREFIX}/bin + install --mode 0755 ${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE} + + install --directory ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE} + install --mode 0644 LICENSE ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE}/LICENSE + +# UNINSTALL +# ============================================================================== +PHONY+=uninstall +uninstall: + -rm --force --recursive \ + ${DESTDIR}/etc/bash_completion.d/${EXECUTABLE} \ + ${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \ + ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE} + +# BUILD CONTAINER IMAGE # ============================================================================== PHONY+=container-image/build container-image/build: ${CONTAINER_RUNTIME} build \ --build-arg VERSION=${VERSION} \ - --file ./Dockerfile \ + --file Dockerfile \ --no-cache \ - --tag ${CONTAINER_IMAGE_FULLY_QUALIFIED} \ + --pull \ + --tag ${GETIDEV_IMAGE_FULLY_QUALIFIED} \ . +# DELETE CONTAINER IMAGE +# ============================================================================== +PHONY:=container-image/delete +container-image/delete: + - ${CONTAINER_RUNTIME} image rm ${GETIDEV_IMAGE_FULLY_QUALIFIED} + +# PUSH CONTAINER IMAGE +# ============================================================================== PHONY+=container-image/push -container-image/push: container-image/build - ${CONTAINER_RUNTIME} push ${CONTAINER_IMAGE_FULLY_QUALIFIED} - -# CONTAINER STEPS - EXECUTABLE -# ============================================================================== -PHONY+=container-run/all -container-run/all: - $(MAKE) container-run COMMAND=${@:container-run/%=%} - -PHONY+=${EXECUTABLE_TARGETS:%=container-run/%} -${EXECUTABLE_TARGETS:%=container-run/%}: - $(MAKE) container-run COMMAND=${@:container-run/%=%} - -# CONTAINER STEPS - CLEAN -# ============================================================================== -PHONY+=container-run/clean -container-run/clean: - $(MAKE) container-run COMMAND=${@:container-run/%=%} - -# GENERAL CONTAINER COMMAND -# ============================================================================== -PHONY+=container-run -container-run: - ${CONTAINER_RUNTIME} run \ - --env CONTAINER_IMAGE_VERSION=${CONTAINER_IMAGE_VERSION} \ - --env VERSION=${VERSION} \ - --net=host \ - --rm \ - --volume /tmp:/tmp \ - --volume "${HOME}/go:/root/go" \ - --volume "$(shell pwd):$(shell pwd)" \ - --workdir "$(shell pwd)" \ - ${BUILD_IMAGE_FULLY_QUALIFIED} \ - make ${COMMAND} +container-image/push: + echo ${GETIDEV_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${GETIDEV_IMAGE_REGISTRY_NAME} --username ${GETIDEV_IMAGE_REGISTRY_USER} --password-stdin + ${CONTAINER_RUNTIME} push ${GETIDEV_IMAGE_FULLY_QUALIFIED} # PHONY # ============================================================================== -# Declare the contents of the PHONY variable as phony. We keep that information +# Declare the contents of the PHONY variable as phony. We keep that information # in a variable so we can use it in if_changed. .PHONY: ${PHONY} diff --git a/manifest.tmpl b/manifest.tmpl deleted file mode 100644 index 1878e4f..0000000 --- a/manifest.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -image: git.cryptic.systems/volker.raschek/getidev:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} -{{#if build.tags}} -tags: -{{#each build.tags}} - - {{this}} -{{/each}} - - "latest" -{{/if}} -manifests: - - - image: git.cryptic.systems/volker.raschek/getidev:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{else}}latest{{/if}}-amd64 - platform: - architecture: amd64 - os: linux - - - image: git.cryptic.systems/volker.raschek/getidev:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-arm64-v8 - platform: - architecture: arm64 - os: linux - variant: v8 \ No newline at end of file diff --git a/renovate.json b/renovate.json index 633c691..26f83bd 100644 --- a/renovate.json +++ b/renovate.json @@ -1,54 +1,10 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "assigneesFromCodeOwners": true, - "labels": [ "renovate" ], - "packageRules": [ - { - "description": "Automatically update minor and patch versions of container images", - "addLabels": [ "renovate/container-images", "renovate/automerge" ], - "automerge": true, - "matchDatasources":[ "docker" ], - "matchUpdateTypes": [ "minor", "patch"] - }, - { - "description": "Prepare MR for major update of container images", - "addLabels": [ "renovate/container-images", "renovate/automerge" ], - "automerge": false, - "matchDatasources":[ "docker" ], - "matchUpdateTypes": [ "major"] - }, - { - "description": "Automatically update minor and patch versions of used drone-ci images", - "addLabels": [ "renovate/droneci", "renovate/automerge" ], - "automerge": true, - "matchManagers": "droneci", - "matchUpdateTypes": [ "minor", "patch"] - }, - { - "description": "Prepare MR for major update of used drone-ci images", - "addLabels": [ "renovate/droneci", "renovate/automerge" ], - "automerge": false, - "matchManagers": "droneci", - "matchUpdateTypes": [ "major"] - }, - { - "description": "Automatically update minor and patch versions of go modules", - "addLabels": [ "renovate/gomod", "renovate/automerge" ], - "automerge": true, - "matchManagers": [ "gomod" ], - "matchUpdateTypes": [ "minor", "patch" ] - }, - { - "description": "Prepare MR for major update of go modules", - "addLabels": [ "renovate/gomod" ], - "automerge": false, - "matchManagers": [ "gomod" ], - "matchUpdateTypes": [ "major" ] - } - ], - "postUpdateOptions": [ - "gomodTidy" - ], - "rebaseLabel": "renovate/rebase", - "rebaseWhen": "behind-base-branch" + "extends": [ + "local>volker.raschek/renovate-config:default#master", + "local>volker.raschek/renovate-config:container#master", + "local>volker.raschek/renovate-config:actions#master", + "local>volker.raschek/renovate-config:golang#master", + "local>volker.raschek/renovate-config:regexp#master" + ] }