2022-01-11 15:41:07 +00:00
|
|
|
name: build
|
|
|
|
|
2022-11-26 13:09:19 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-01-11 15:41:07 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
- 'release/*'
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
env:
|
|
|
|
DOCKERHUB_SLUG: distribution/distribution
|
2023-10-25 10:37:01 +00:00
|
|
|
GHCR_SLUG: ghcr.io/${{ github.repository }}
|
2022-01-11 15:41:07 +00:00
|
|
|
|
2022-09-24 06:52:44 +00:00
|
|
|
permissions:
|
|
|
|
contents: read # to fetch code (actions/checkout)
|
|
|
|
|
2022-01-11 15:41:07 +00:00
|
|
|
jobs:
|
2022-05-05 16:09:57 +00:00
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
go:
|
2024-03-15 08:55:59 +00:00
|
|
|
- 1.21.8
|
2024-03-27 15:59:13 +00:00
|
|
|
- 1.22.1
|
2023-10-23 13:52:57 +00:00
|
|
|
target:
|
|
|
|
- test-coverage
|
|
|
|
- test-cloud-storage
|
2022-05-05 16:09:57 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2023-12-29 23:06:01 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-05-05 16:09:57 +00:00
|
|
|
-
|
|
|
|
name: Set up Go
|
2023-12-29 23:06:07 +00:00
|
|
|
uses: actions/setup-go@v5
|
2022-05-05 16:09:57 +00:00
|
|
|
with:
|
|
|
|
go-version: ${{ matrix.go }}
|
|
|
|
-
|
|
|
|
name: Test
|
|
|
|
run: |
|
2023-10-23 13:52:57 +00:00
|
|
|
make ${{ matrix.target }}
|
2022-05-05 16:09:57 +00:00
|
|
|
-
|
|
|
|
name: Codecov
|
2024-02-01 01:51:49 +00:00
|
|
|
uses: codecov/codecov-action@v4
|
2022-05-05 16:09:57 +00:00
|
|
|
with:
|
|
|
|
directory: ./
|
|
|
|
|
2022-01-11 15:41:07 +00:00
|
|
|
build:
|
2022-09-24 06:52:44 +00:00
|
|
|
permissions:
|
|
|
|
contents: write # to create GitHub release (softprops/action-gh-release)
|
2023-10-25 10:37:01 +00:00
|
|
|
packages: write # so we can push the image to GHCR
|
2022-09-24 06:52:44 +00:00
|
|
|
|
2022-01-11 15:41:07 +00:00
|
|
|
runs-on: ubuntu-latest
|
2022-05-05 16:09:57 +00:00
|
|
|
needs:
|
|
|
|
- test
|
2022-01-11 15:41:07 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
2023-12-29 23:06:01 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
-
|
|
|
|
name: Docker meta
|
|
|
|
id: meta
|
2024-01-04 01:55:09 +00:00
|
|
|
uses: docker/metadata-action@v5
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
${{ env.DOCKERHUB_SLUG }}
|
2023-10-25 10:37:01 +00:00
|
|
|
${{ env.GHCR_SLUG }}
|
2022-01-21 19:07:08 +00:00
|
|
|
### versioning strategy
|
|
|
|
### push semver tag v3.2.1 on main (default branch)
|
|
|
|
# distribution/distribution:3.2.1
|
|
|
|
# distribution/distribution:3.2
|
|
|
|
# distribution/distribution:3
|
|
|
|
# distribution/distribution:latest
|
|
|
|
### push semver prelease tag v3.0.0-beta.1 on main (default branch)
|
|
|
|
# distribution/distribution:3.0.0-beta.1
|
|
|
|
### push on main
|
|
|
|
# distribution/distribution:edge
|
2022-01-11 15:41:07 +00:00
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
2022-01-21 19:07:08 +00:00
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
2022-01-11 15:41:07 +00:00
|
|
|
type=ref,event=pr
|
|
|
|
type=edge
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.title=Distribution
|
2023-10-25 10:37:01 +00:00
|
|
|
org.opencontainers.image.description=The toolkit to pack, ship, store, and distribute container content
|
2022-01-11 15:41:07 +00:00
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2024-01-01 01:54:07 +00:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2022-01-11 15:41:07 +00:00
|
|
|
-
|
|
|
|
name: Login to DockerHub
|
|
|
|
if: github.event_name != 'pull_request'
|
2024-01-03 02:03:24 +00:00
|
|
|
uses: docker/login-action@v3
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2023-10-25 10:37:01 +00:00
|
|
|
-
|
|
|
|
name: Log in to GitHub Container registry
|
|
|
|
if: github.event_name != 'pull_request'
|
2024-01-03 02:03:24 +00:00
|
|
|
uses: docker/login-action@v3
|
2023-10-25 10:37:01 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
2022-01-11 15:41:07 +00:00
|
|
|
-
|
|
|
|
name: Build artifacts
|
2024-01-12 10:03:05 +00:00
|
|
|
uses: docker/bake-action@v4
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
targets: artifact-all
|
|
|
|
-
|
2024-01-12 10:30:32 +00:00
|
|
|
name: Rename provenance
|
|
|
|
run: |
|
|
|
|
for pdir in ./bin/*/; do
|
|
|
|
(
|
|
|
|
cd "$pdir"
|
|
|
|
binname=$(find . -name '*.tar.gz')
|
|
|
|
filename=$(basename "${binname%.tar.gz}")
|
|
|
|
mv "provenance.json" "${filename}.provenance.json"
|
|
|
|
)
|
|
|
|
done
|
|
|
|
-
|
|
|
|
name: Move and list artifacts
|
2022-01-11 15:41:07 +00:00
|
|
|
run: |
|
|
|
|
mv ./bin/**/* ./bin/
|
2024-01-12 10:30:32 +00:00
|
|
|
tree -nh ./bin
|
2022-01-11 15:41:07 +00:00
|
|
|
-
|
|
|
|
name: Upload artifacts
|
2024-01-24 01:42:26 +00:00
|
|
|
uses: actions/upload-artifact@v4.3.0
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
name: registry
|
|
|
|
path: ./bin/*
|
|
|
|
if-no-files-found: error
|
|
|
|
-
|
|
|
|
name: Build image
|
2024-01-12 10:03:05 +00:00
|
|
|
uses: docker/bake-action@v4
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
./docker-bake.hcl
|
|
|
|
${{ steps.meta.outputs.bake-file }}
|
|
|
|
targets: image-all
|
|
|
|
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
-
|
|
|
|
name: GitHub Release
|
|
|
|
uses: softprops/action-gh-release@v1
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
with:
|
|
|
|
draft: true
|
|
|
|
files: |
|
|
|
|
bin/*.tar.gz
|
2024-01-12 10:30:32 +00:00
|
|
|
bin/*.provenance.json
|
2022-01-21 19:07:08 +00:00
|
|
|
bin/*.sha256
|
2022-01-11 15:41:07 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|