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
|
|
|
|
|
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:
|
2023-10-19 08:13:32 +00:00
|
|
|
- 1.20.9
|
|
|
|
- 1.21.2
|
2022-05-05 16:09:57 +00:00
|
|
|
steps:
|
|
|
|
-
|
|
|
|
name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
-
|
|
|
|
name: Set up Go
|
|
|
|
uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version: ${{ matrix.go }}
|
|
|
|
-
|
|
|
|
name: Test
|
|
|
|
run: |
|
|
|
|
make coverage
|
|
|
|
-
|
|
|
|
name: Codecov
|
|
|
|
uses: codecov/codecov-action@v3
|
|
|
|
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)
|
|
|
|
|
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
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
-
|
|
|
|
name: Docker meta
|
|
|
|
id: meta
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: docker/metadata-action@v4
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
${{ env.DOCKERHUB_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
|
|
|
|
org.opencontainers.image.description=The toolkit to pack, ship, store, and deliver container content
|
|
|
|
-
|
|
|
|
name: Set up Docker Buildx
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2022-01-11 15:41:07 +00:00
|
|
|
-
|
|
|
|
name: Login to DockerHub
|
|
|
|
if: github.event_name != 'pull_request'
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: docker/login-action@v2
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
-
|
|
|
|
name: Build artifacts
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: docker/bake-action@v2
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
targets: artifact-all
|
|
|
|
-
|
|
|
|
name: Move artifacts
|
|
|
|
run: |
|
|
|
|
mv ./bin/**/* ./bin/
|
|
|
|
-
|
|
|
|
name: Upload artifacts
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-01-11 15:41:07 +00:00
|
|
|
with:
|
|
|
|
name: registry
|
|
|
|
path: ./bin/*
|
|
|
|
if-no-files-found: error
|
|
|
|
-
|
|
|
|
name: Build image
|
2022-11-26 13:05:57 +00:00
|
|
|
uses: docker/bake-action@v2
|
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
|
2022-01-21 19:07:08 +00:00
|
|
|
bin/*.sha256
|
2022-01-11 15:41:07 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|