From 756d668fc911809c628a35a9c6c4240fdb098db9 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Tue, 13 May 2025 20:28:50 +0200 Subject: [PATCH] fix(ci): replace drone with gitea actions --- .drone.yml | 670 ------------------ .gitea/workflows/golang-tests.yaml | 21 + .gitea/workflows/markdown-linters.yaml | 20 + .gitea/workflows/release.yaml | 52 ++ .../update-docker-hub-description.yaml | 19 + .gitignore | 3 +- .goreleaser.yaml | 154 ++++ Dockerfile | 28 +- Makefile | 15 + manifest.tmpl | 20 - 10 files changed, 285 insertions(+), 717 deletions(-) delete mode 100644 .drone.yml create mode 100644 .gitea/workflows/golang-tests.yaml create mode 100644 .gitea/workflows/markdown-linters.yaml create mode 100644 .gitea/workflows/release.yaml create mode 100644 .gitea/workflows/update-docker-hub-description.yaml create mode 100644 .goreleaser.yaml delete mode 100644 manifest.tmpl diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index ac3ba73..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/getpsrc - 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/getpsrc - ---- -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/getpsrc - 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/getpsrc - ---- -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/getpsrc - 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/getpsrc - ---- -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/getpsrc - 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/getpsrc - ---- -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/getpsrc - ---- -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/getpsrc 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/getpsrc - ---- -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/getpsrc - 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/getpsrc - ---- -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/getpsrc - 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/getpsrc - ---- -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/getpsrc - ---- -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/getpsrc 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/getpsrc diff --git a/.gitea/workflows/golang-tests.yaml b/.gitea/workflows/golang-tests.yaml new file mode 100644 index 0000000..c46ec77 --- /dev/null +++ b/.gitea/workflows/golang-tests.yaml @@ -0,0 +1,21 @@ +name: Golang Tests + +on: + pull_request: + types: [ "opened", "reopened", "synchronize" ] + push: + branches: [ '**' ] + tags-ignore: [ '**' ] + +jobs: + unittest: + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - uses: actions/setup-go@v5.5.0 + with: + go-version: stable + - 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..e5883f9 --- /dev/null +++ b/.gitea/workflows/markdown-linters.yaml @@ -0,0 +1,20 @@ +name: Markdown linter + +on: + pull_request: + types: [ "opened", "reopened", "synchronize" ] + push: + branches: [ '**' ] + tags-ignore: [ '**' ] + workflow_dispatch: {} + +jobs: + markdown-lint: + container: + image: git.cryptic.systems/volker.raschek/markdownlint:0.44.0 + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - name: Lint Markdown files + run: markdownlint --config .markdownlint.yaml . \ No newline at end of file diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..1a270b4 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,52 @@ +name: Release + +on: + push: + tags: [ '**' ] + +permissions: + contents: write + +jobs: + release: + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - uses: docker/setup-qemu-action@v3.6.0 + - uses: actions/setup-go@v5.5.0 + with: + go-version: stable + - uses: docker/login-action@v3.4.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" + args: release --clean + + sync-to-hub-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/getpsrc:${TAG} \ + docker://docker.io/volkerraschek/getpsrc:${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..f090114 --- /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' ] + +jobs: + update-description-on-hub-docker-io: + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - uses: peter-evans/dockerhub-description@v4.0.2 + with: + username: ${{ secrets.DOCKER_IO_USERNAME }} + password: ${{ secrets.DOCKER_IO_PASSWORD }} + repository: volkerraschek/getpsrc + readme-filepath: README.md \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5802e17..ca0f79e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ **/container.log **/.env **/coverage* -getpsrc* \ No newline at end of file +getpsrc* +dist \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..22b4853 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,154 @@ +project_name: getpsrc + +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 + 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 + +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' + +gitea_urls: + api: https://git.cryptic.systems/api/v1 + download: https://git.cryptic.systems + +version: 2 diff --git a/Dockerfile b/Dockerfile index a477df5..db0b2ff 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 the ip address of the router to forward traffic to an external ip address" \ - org.opencontainers.image.documentation="https://git.cryptic.systems/volker.raschek/getpsrc#getpsrc" \ - org.opencontainers.image.title="getpsrc" \ - org.opencontainers.image.vendor="Markus Pesch" \ - org.opencontainers.image.version="${VERSION}" - -COPY --from=build /workspace/getpsrc /usr/bin/getpsrc +COPY getpsrc-* /usr/bin/getpsrc ENTRYPOINT [ "/usr/bin/getpsrc" ] diff --git a/Makefile b/Makefile index 1503443..0045624 100644 --- a/Makefile +++ b/Makefile @@ -20,12 +20,27 @@ all: clean ${EXECUTABLE_TARGETS} getpsrc: go build -tags netgo -ldflags "-X main.version=${VERSION}" -o ${@} main.go + # CLEAN # ============================================================================== PHONY+=clean clean: rm -f -r $(shell pwd)/getpsrc* +# 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 ./... + +PHONY+=test/coverage +test/coverage: test/unit + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go tool cover -html=coverage.txt + # GOLANGCI-LINT # ============================================================================== PHONY+=golangci-lint diff --git a/manifest.tmpl b/manifest.tmpl deleted file mode 100644 index 5c7313c..0000000 --- a/manifest.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -image: git.cryptic.systems/volker.raschek/db-wait:{{#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/db-wait:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{else}}latest{{/if}}-amd64 - platform: - architecture: amd64 - os: linux - - - image: git.cryptic.systems/volker.raschek/db-wait:{{#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