2023-05-20 09:10:00 +00:00
|
|
|
|
|
|
|
name: Create and publish a Docker image
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
|
|
|
|
env:
|
|
|
|
REGISTRY: ghcr.io
|
|
|
|
IMAGE_NAME: ${{ github.repository }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build-and-push-image:
|
2023-05-20 10:12:50 +00:00
|
|
|
if: github.repository == 'restic/restic'
|
2023-05-20 09:10:00 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2023-10-01 01:24:05 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-05-20 09:10:00 +00:00
|
|
|
|
|
|
|
- name: Log in to the Container registry
|
2024-06-01 01:48:43 +00:00
|
|
|
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
|
2023-05-20 09:10:00 +00:00
|
|
|
with:
|
|
|
|
registry: ${{ env.REGISTRY }}
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
2024-03-28 16:56:13 +00:00
|
|
|
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
|
2023-05-20 09:10:00 +00:00
|
|
|
with:
|
|
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
|
|
|
|
- name: Set up QEMU
|
2023-10-01 01:24:01 +00:00
|
|
|
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3
|
2023-05-20 09:10:00 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2024-03-28 16:56:13 +00:00
|
|
|
uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20
|
2023-05-20 09:10:00 +00:00
|
|
|
|
2023-10-02 17:11:09 +00:00
|
|
|
- name: Ensure consistent binaries
|
|
|
|
run: |
|
|
|
|
echo "removing git directory for consistency with release binaries"
|
|
|
|
rm -rf .git
|
|
|
|
# remove VCS information from release builds, keep VCS for nightly builds on master
|
|
|
|
if: github.ref != 'refs/heads/master'
|
|
|
|
|
2023-05-20 09:10:00 +00:00
|
|
|
- name: Build and push Docker image
|
2024-03-28 16:56:13 +00:00
|
|
|
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0
|
2023-05-20 09:10:00 +00:00
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
context: .
|
|
|
|
file: docker/Dockerfile.release
|
|
|
|
platforms: linux/386,linux/amd64,linux/arm,linux/arm64
|
|
|
|
pull: true
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|