-
-
Notifications
You must be signed in to change notification settings - Fork 6
149 lines (134 loc) · 5.38 KB
/
release-docker.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Nightly and release build
on:
push:
branches:
- "feat/*"
- "develop"
pull_request:
types: [closed]
branches:
- main
env:
GHCR: ghcr.io
GHCR_IMAGE_NAME: ${{ github.repository }}
DH_REGISTRY_NAME: jqtype/doh-auth-proxy
jobs:
docker_build_and_push:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }} || ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
strategy:
fail-fast: false
matrix:
include:
- target: "default"
dockerfile: ./docker/Dockerfile
platforms: linux/amd64
# Aliases must be used only for release builds
aliases: |
jqtype/doh-auth-proxy:latest
ghcr.io/junkurihara/doh-auth-proxy:latest
- target: "slim"
dockerfile: ./docker/Dockerfile-slim
platforms: linux/amd64
tags-suffix: "-slim"
# Aliases must be used only for release builds
aliases: |
jqtype/doh-auth-proxy:slim
ghcr.io/junkurihara/doh-auth-proxy:slim
steps:
- name: checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Release Build and push x86_64
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:latest${{ matrix.tags-suffix }}
${{ env.DH_REGISTRY_NAME }}:latest${{ matrix.tags-suffix }}
${{ matrix.aliases }}
file: ${{ matrix.dockerfile }}
cache-from: type=gha,scope=doh-auth-proxy-latest
cache-to: type=gha,mode=max,scope=doh-auth-proxy-latest
platforms: ${{ matrix.platforms }}
labels: ${{ steps.meta.outputs.labels }}
- name: Nightly build and push x86_64
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }}
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:nightly${{ matrix.tags-suffix }}
${{ env.DH_REGISTRY_NAME }}:nightly${{ matrix.tags-suffix }}
file: ${{ matrix.dockerfile }}
cache-from: type=gha,scope=doh-auth-proxy-nightly
cache-to: type=gha,mode=max,scope=doh-auth-proxy-nightly
platforms: ${{ matrix.platforms }}
labels: ${{ steps.meta.outputs.labels }}
- name: Unstable build and push x86_64 for 'feat/*' branches (for development purposes)
if: ${{ startsWith(github.ref_name, 'feat/') && (github.event_name == 'push') }}
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:unstable${{ matrix.tags-suffix }}
${{ env.DH_REGISTRY_NAME }}:unstable${{ matrix.tags-suffix }}
file: ${{ matrix.dockerfile }}
cache-from: type=gha,scope=doh-auth-proxy-unstable
cache-to: type=gha,mode=max,scope=doh-auth-proxy-unstable
platforms: ${{ matrix.platforms }}
labels: ${{ steps.meta.outputs.labels }}
dispatch_release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'develop' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged == true }}
needs: docker_build_and_push
steps:
- name: check pull_request title
uses: kaisugi/[email protected]
id: regex-match
with:
text: ${{ github.event.pull_request.title }}
regex: "^(\\d+\\.\\d+\\.\\d+)$"
- name: checkout
if: ${{ steps.regex-match.outputs.match != '' }}
uses: actions/checkout@v4
- name: build release binary
if: ${{ steps.regex-match.outputs.match != '' }}
id: "build"
run: |
cargo build --release --package doh-auth-proxy
cp ./target/release/doh-auth-proxy /tmp/doh-auth-proxy
cd /tmp
tar zcvf doh-auth-proxy-x86_64-unknown-linux-gnu.tar.gz doh-auth-proxy
- name: release
if: ${{ steps.regex-match.outputs.match != ''}}
uses: softprops/action-gh-release@v2
with:
files: /tmp/doh-auth-proxy-x86_64-unknown-linux-gnu.tar.gz
name: ${{ github.event.pull_request.title }}
tag_name: ${{ github.event.pull_request.title }}
body: ${{ github.event.pull_request.body }}
draft: true
prerelease: false
generate_release_notes: true