-
Notifications
You must be signed in to change notification settings - Fork 5
142 lines (125 loc) · 4.01 KB
/
image-release.yaml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build
on:
pull_request:
branches:
- 'main'
push:
branches:
- 'main'
env:
DOCKER_CONTEXT_DIR: "{{defaultContext}}:images/release"
DOCKER_IMAGE: "ghcr.io/${{ github.repository }}-release"
DOCKER_PLATFORMS: "linux/amd64,linux/arm64"
PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
jobs:
docker:
name: Docker build
runs-on: ubuntu-latest
steps:
- name: Checkout Current
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
type=ref,event=branch
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ env.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.DOCKER_CONTEXT_DIR }}
platforms: ${{ inputs.docker_platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha
cache-from: type=gha
version:
name: Semantic release
needs: docker
runs-on: ubuntu-latest
outputs:
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
id: semantic
with:
semantic_version: 16
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ env.PAT }}
docker_release:
name: Docker release
needs: version
if: ${{ needs.version.outputs.new_release_published == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Current
uses: actions/checkout@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: ${{ env.DOCKER_IMAGE }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=semver,pattern={{version}},value=${{ needs.version.outputs.new_release_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.version.outputs.new_release_version }}
type=semver,pattern={{major}},value=${{ needs.version.outputs.new_release_version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ env.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ env.DOCKER_CONTEXT_DIR }}
platforms: ${{ env.DOCKER_PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha