-
Notifications
You must be signed in to change notification settings - Fork 2.4k
129 lines (123 loc) · 3.97 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: release
on:
schedule:
- cron: '0 0 1 * *' # run release monthly
workflow_dispatch: # allow a release to be triggered manually
env:
GHCR_SLUG: ghcr.io/${{ github.repository_owner }}/distribution
DOCKERHUB_SLUG: distribution/distribution
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go:
- 1.20.7
- 1.21.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Test
run: |
make coverage
- name: Codecov
uses: codecov/codecov-action@v3
with:
directory: ./
build:
permissions:
contents: write # to create GitHub release (cycjimmy/semantic-release-action)
id-token: write # to write to GHCR
packages: write # to write to GHCR
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic_release
with:
dry_run: true
semantic_version: 22.0.5
extra_plugins: |
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
if: ${{ steps.semantic_release.outputs.new_release_published }}
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_SLUG }}
${{ env.GHCR_SLUG }}
### versioning strategy
### push semver tag v3.2.1 on main (default branch)
# distribution/distribution:3.2.1
# distribution/distribution:3.2
# distribution/distribution:3
# ghcr.io/distribution/distribution:3.2.1
# ghcr.io/distribution/distribution:3.2
# ghcr.io/distribution/distribution:3
tags: |
type=semver,pattern={{version}},value=${{ steps.semantic_release.outputs.new_release_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic_release.outputs.new_release_version }}
type=semver,pattern={{major}},value=${{ steps.semantic_release.outputs.new_release_version }}
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
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build artifacts
uses: docker/bake-action@v4
with:
targets: artifact-all
provenance: false
- name: Move artifacts
run: |
mv ./bin/**/* ./bin/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: registry
path: ./bin/*
if-no-files-found: error
- name: Build image
uses: docker/bake-action@v4
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: image-all
push: true
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 22.0.5
extra_plugins: |
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}