diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 8770d3d..c3f14b9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -14,33 +14,33 @@ jobs: steps: # https://github.com/actions/checkout - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 # https://github.com/actions/setup-go - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: '>=1.20' + go-version-file: "go.mod" # https://github.com/pre-commit/action - name: run pre-commit uses: pre-commit/action@v3.0.1 env: - SKIP: no-commit-to-branch + SKIP: no-commit-to-branch,golangci-lint golangci-lint: runs-on: ubuntu-latest steps: # https://github.com/actions/checkout - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 # https://github.com/actions/setup-go - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: '>=1.20' + go-version-file: "go.mod" # https://github.com/golangci/golangci-lint-action - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v9 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43aeb26..200ff81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,15 +13,15 @@ jobs: steps: # https://github.com/actions/checkout - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 # https://github.com/actions/setup-go - name: Set up Go - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: - go-version: ">=1.22" + go-version-file: "go.mod" # https://github.com/goreleaser/goreleaser-action - name: Run GoReleaser (Tag) @@ -45,7 +45,7 @@ jobs: # https://github.com/actions/upload-artifact - name: Upload binaries as artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: binaries path: dist/cli* @@ -56,11 +56,11 @@ jobs: steps: # https://github.com/actions/checkout - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 # https://github.com/actions/download-artifact - name: Download binaries - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: binaries path: dist @@ -83,7 +83,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.DOCKER_HUB_TOKEN }} # https://github.com/docker/login-action @@ -97,7 +97,7 @@ jobs: # https://github.com/actions/github-script - name: Fetch repository info id: repo_info - uses: actions/github-script@v7 + uses: actions/github-script@v8 with: result-encoding: string script: | @@ -143,8 +143,8 @@ jobs: # https://github.com/peter-evans/dockerhub-description - name: Update Docker Hub Description - uses: peter-evans/dockerhub-description@v4 + uses: peter-evans/dockerhub-description@v5 with: username: ${{ github.actor }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} + password: ${{ secrets.DOCKER_HUB_TOKEN_DOCKERHUB_DESCRIPTION }} repository: ${{ github.repository }} diff --git a/.gitignore b/.gitignore index 5eaa1bc..29fb237 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ config.yml +dist/ restic-runner testrepo diff --git a/.goreleaser.yml b/.goreleaser.yml index 545893b..0f51637 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -21,6 +21,8 @@ builds: ignore: - goos: freebsd goarch: arm64 + - goos: windows + goarch: arm universal_binaries: - id: cli replace: false @@ -28,24 +30,21 @@ archives: - id: cli format_overrides: - goos: windows - format: zip + formats: + - zip files: - README.md - LICENSE.txt name_template: >- {{- .ProjectName -}}_ {{- .Version -}}_ - {{- if eq .Os "darwin" -}} - macos - {{- else -}} - {{ .Os }} - {{- end -}}_ + {{- if eq .Os "darwin" -}}macos{{- else -}}{{ .Os }}{{- end -}}_ {{- .Arch -}} checksum: - name_template: 'checksums.txt' + name_template: "checksums.txt" changelog: sort: asc filters: exclude: - - '^docs:' - - '^test:' + - "^docs:" + - "^test:" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c530c4..34dce14 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -18,11 +18,15 @@ repos: - --branch - main - repo: https://github.com/golangci/golangci-lint - rev: v1.59.1 + rev: v2.8.0 hooks: - id: golangci-lint - repo: https://github.com/rhysd/actionlint - rev: v1.7.1 + rev: v1.7.10 hooks: - id: actionlint-docker name: check github workflows with actionlint + - repo: https://github.com/hadolint/hadolint + rev: v2.14.0 + hooks: + - id: hadolint-docker diff --git a/Dockerfile b/Dockerfile index 6146668..9e3488a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,23 @@ -FROM alpine:edge as dist +FROM alpine:edge AS dist ARG TARGETPLATFORM -# this is only there if goreleaser has created it +# dist is only there if goreleaser has created it before this build COPY dist /dist/ RUN set -eux; \ - platform_dirname=$(printf '%s' "${TARGETPLATFORM}" | tr / _ | tr A-Z a-z | sed 's/amd64/amd64_v1/g'); \ - subdir=$(printf '/dist/cli_%s' $platform_dirname); \ - cp ${subdir}/restic-runner /restic-runner; \ + case "${TARGETPLATFORM:-}" in \ + linux/amd64) f="dist/cli_linux_amd64_v1/restic-runner"; ;; \ + linux/arm) f="dist/cli_linux_arm_7/restic-runner"; ;; \ + linux/arm64) f="dist/cli_linux_arm64_v8.0/restic-runner"; ;; \ + *) echo "unknown TARGETPLATFORM: '${TARGETPLATFORM:-}'"; exit 1; ;; \ + esac; \ + cp "${f}" /; \ chmod +x /restic-runner; FROM alpine:edge -RUN apk add --no-cache ca-certificates +RUN apk add --no-cache \ + 'ca-certificates>=20251003-r0' \ + 'restic>=0.18.1' \ + ; COPY --from=dist /restic-runner / ENTRYPOINT [ "/restic-runner" ] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..896e9a5 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +restic-runner: + go build -o "$@" + +dist: + goreleaser build --auto-snapshot --clean + +.PHONY: docker-build +docker-build: dist + docker build -t backplane/restic-runner . + +.PHONY: docker-run +docker-run: docker-build + docker run --rm -it backplane/restic-runner + +.PHONY: clean +clean: + go clean + rm -rf dist diff --git a/README.md b/README.md index 6d61669..4962f96 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ COMMANDS: help, h Shows a list of commands or help for one command GLOBAL OPTIONS: - --config value path to config file (default: "/Users/user/.restic-runner.yml") + --config value path to config file (default: "~/.restic-runner.yml") --loglevel value how verbosely to log, one of: DEBUG, INFO, WARN, ERROR (default: "INFO") - --pidfile value path to pid lock file; this file prevents issues concurrent jobs (default: "/Users/user/.restic-runner.pid") + --pidfile value path to pid lock file; this file prevents issues concurrent jobs (default: "~/.restic-runner.pid") --help, -h show help --version, -v print the version ``` diff --git a/go.mod b/go.mod index e8fde4d..f9f0d48 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.22.5 require ( github.com/jinzhu/configor v1.2.2 - github.com/urfave/cli/v2 v2.27.2 + github.com/urfave/cli/v2 v2.27.7 ) require ( - github.com/BurntSushi/toml v1.4.0 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect + github.com/BurntSushi/toml v1.6.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect + github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 38e9f14..211a2fb 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,16 @@ github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= +github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/jinzhu/configor v1.2.2 h1:sLgh6KMzpCmaQB4e+9Fu/29VErtBUqsS2t8C9BNIVsA= github.com/jinzhu/configor v1.2.2/go.mod h1:iFFSfOBKP3kC2Dku0ZGB3t3aulfQgTGJknodhFavsU8= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI= -github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM= -github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= -github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= +github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= +github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg= +github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=