Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/actions/docker-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build and push Docker image
description: >-
Cross-compile resticprofile (amd64 + arm64), download restic & rclone, and
build the multi-arch Docker image with buildx, optionally pushing it to
Docker Hub and the GitHub Container Registry.

inputs:
go-version:
description: Go version used to compile resticprofile
required: true
tags:
description: Newline-separated list of image tags to build (and push)
required: true
labels:
description: Newline-separated list of OCI image labels
required: false
default: ""
push:
description: Whether to push the image to the registries
required: false
default: "true"
dockerhub-username:
description: Docker Hub username
required: false
dockerhub-token:
description: Docker Hub token or password
required: false

runs:
using: composite
steps:
- name: Set up Go ${{ inputs.go-version }}
uses: actions/setup-go@v6
with:
go-version: ${{ inputs.go-version }}
check-latest: true
cache: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to DockerHub
if: ${{ inputs.push == 'true' }}
Comment thread
creativeprojects marked this conversation as resolved.
uses: docker/login-action@v4
with:
username: ${{ inputs.dockerhub-username }}
password: ${{ inputs.dockerhub-token }}

- name: Login to GitHub Container Registry
if: ${{ inputs.push == 'true' }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Download rclone & restic binaries and build resticprofile
shell: bash
run: |
go install github.com/zyedidia/eget@latest
eget rclone/rclone --system=linux/amd64 --to=build/rclone-amd64 --asset=zip
eget rclone/rclone --system=linux/arm64 --to=build/rclone-arm64 --asset=zip
eget restic/restic --system=linux/amd64 --to=build/restic-amd64
eget restic/restic --system=linux/arm64 --to=build/restic-arm64
make build-ci
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Build and push image
uses: docker/build-push-action@v7
with:
file: build/Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: ${{ inputs.push }}
tags: ${{ inputs.tags }}
labels: ${{ inputs.labels }}
51 changes: 17 additions & 34 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:


jobs:
goreleaser:
docker:
name: Rebuild docker image
runs-on: ubuntu-latest
steps:
Expand All @@ -25,46 +25,29 @@ jobs:
log-variables: true

- name: Checkout latest tag
id: version
run: |
export LATEST_TAG=$(git tag --list 'v*' --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$LATEST_TAG" ]; then
echo "No release tag found"
exit 1
fi
git checkout $LATEST_TAG
echo "version=${LATEST_TAG#v}" >> "$GITHUB_OUTPUT"
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"

- name: Set up Go ${{ steps.dotenv.outputs.go_version }}
uses: actions/setup-go@v6
- name: Build and push image
Comment thread
creativeprojects marked this conversation as resolved.
uses: ./.github/actions/docker-build
with:
go-version: ${{ steps.dotenv.outputs.go_version }}
check-latest: true
cache: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v4

- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install eget
run: go install github.com/zyedidia/eget@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: release --clean --config .goreleaser-docker-only.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
tags: |
creativeprojects/resticprofile:latest
creativeprojects/resticprofile:${{ steps.version.outputs.version }}
ghcr.io/creativeprojects/resticprofile:latest
ghcr.io/creativeprojects/resticprofile:${{ steps.version.outputs.version }}
labels: |
org.opencontainers.image.created=${{ steps.version.outputs.created }}
org.opencontainers.image.version=${{ steps.version.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
59 changes: 37 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,48 @@ jobs:
check-latest: true
cache: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v4

- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install eget
run: go install github.com/zyedidia/eget@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}

docker:
runs-on: ubuntu-latest
steps:
Comment thread
creativeprojects marked this conversation as resolved.
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true

- name: Dotenv Action
id: dotenv
uses: falti/dotenv-action@v1
with:
path: .github/workflows/env
log-variables: true

- name: Image metadata
id: meta
run: |
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"

- name: Build and push image
uses: ./.github/actions/docker-build
with:
go-version: ${{ steps.dotenv.outputs.go_version }}
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
tags: |
creativeprojects/resticprofile:latest
creativeprojects/resticprofile:${{ steps.meta.outputs.version }}
ghcr.io/creativeprojects/resticprofile:latest
ghcr.io/creativeprojects/resticprofile:${{ steps.meta.outputs.version }}
labels: |
org.opencontainers.image.created=${{ steps.meta.outputs.created }}
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
50 changes: 4 additions & 46 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,12 @@ jobs:
path: .github/workflows/env
log-variables: true

- name: Set up Go ${{ steps.dotenv.outputs.go_version }}
uses: actions/setup-go@v6
with:
go-version: ${{ steps.dotenv.outputs.go_version }}
check-latest: true
cache: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download rclone & restic binaries
shell: bash
run: |
go install github.com/zyedidia/eget@latest
eget rclone/rclone --system=linux/amd64 --to=build/rclone-amd64 --asset=zip
eget rclone/rclone --system=linux/arm64 --to=build/rclone-arm64 --asset=zip
eget restic/restic --system=linux/amd64 --to=build/restic-amd64
eget restic/restic --system=linux/arm64 --to=build/restic-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
shell: bash
run: make build

- name: Build and push image
uses: docker/build-push-action@v7
uses: ./.github/actions/docker-build
with:
file: build/Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
go-version: ${{ steps.dotenv.outputs.go_version }}
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
tags: |
creativeprojects/resticprofile:nightly
ghcr.io/creativeprojects/resticprofile:nightly
Expand Down
99 changes: 0 additions & 99 deletions .goreleaser-docker-only.yml

This file was deleted.

Loading
Loading