-
Notifications
You must be signed in to change notification settings - Fork 13
135 lines (118 loc) · 4.38 KB
/
update-tag-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
130
131
132
133
134
135
# Workflow to update all Dockerfiles when a new version of Caddy is available and create a new release and tag
name: Update Dockerfiles, tag and release
# Controls when the action will run
on:
workflow_dispatch: # allows to run the workflow manually from the Actions tab
push:
branches: main
paths:
- caddy-cloudflare/Dockerfile # file updated by Dependabot used as reference
# Environment variables available to all jobs and steps in this workflow
env:
CADDY_BUILDS: | # list of all Caddy Docker custom builds
caddy-cloudflare
caddy-cloudflare-crowdsec
caddy-cloudflare-ddns
caddy-cloudflare-ddns-crowdsec
caddy-cloudflare-ddns-crowdsec-geoip
caddy-cloudflare-ddns-crowdsec-geoip-security
caddy-cloudflare-ddns-crowdsec-geoip-security-dockerproxy
caddy-cloudflare-ddns-security
caddy-cloudns
caddy-crowdsec
caddy-crowdsec-geoip
caddy-crowdsec-geoip-ratelimit-security-dockerproxy
caddy-duckdns
caddy-duckdns-crowdsec
caddy-duckdns-ddns
caddy-duckdns-ddns-crowdsec
caddy-duckdns-ddns-crowdsec-geoip-security
caddy-duckdns-ddns-crowdsec-geoip-security-dockerproxy
caddy-eventsexec
caddy-gandi
caddy-netcup
caddy-netcup-ddns
caddy-netcup-ddns-geoip
caddy-ovh-crowdsec-geoip
caddy-porkbun-dockerproxy
caddy-ratelimit-dockerproxy-sablier
# Jobs to run once the workflow is triggered
jobs:
# Job to parse the Caddy version from the reference Dockerfile
metadata:
name: Get updated Caddy version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Parse Caddy version
id: version
run: echo "version=$(grep -Eo 'caddy:[0-9]+\.[0-9]+\.[0-9]+$' caddy-cloudflare/Dockerfile | cut -d ':' -f2)" | tee -a $GITHUB_OUTPUT
# Job to update the Caddy version in all Dockerfiles and create a tag
update:
name: Update Caddy and create tag
runs-on: ubuntu-latest
needs: metadata
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
ref: main
- name: Replace Caddy version in all Dockerfiles
run: |
for caddy_build in $CADDY_BUILDS; do
sed -i "s/caddy:[0-9]\+\.[0-9]\+\.[0-9]\+/caddy:${{ needs.metadata.outputs.version }}/g" ./$caddy_build/Dockerfile
done
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Commit and push changes
run: |
git add ./*/Dockerfile
if [ "$(git diff HEAD)" ]
then
git commit -S -m "Bump Caddy version to v${{ needs.metadata.outputs.version }} in all Dockerfiles"
git push
else
echo "No changes detected"
fi
- name: Create and push tag
run: |
git tag -fs v${{ needs.metadata.outputs.version }} -m "Docker images built with Caddy v${{ needs.metadata.outputs.version }}"
git push --tags -f
# Job to create a release
release:
name: Create release
runs-on: ubuntu-latest
needs: [metadata, update]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Generate release text
run: |
echo "RELEASE_TEXT<<EOF" >> $GITHUB_ENV
for caddy_build in $CADDY_BUILDS; do
echo "- $caddy_build: [Source](https://github.com/serfriz/caddy-custom-builds/tree/main/$caddy_build) / \
[GitHub Package](https://ghcr.io/serfriz/$caddy_build) / [Docker Hub](https://hub.docker.com/r/serfriz/$caddy_build) / \
[Quay Package](https://quay.io/serfriz/$caddy_build)" >> $GITHUB_ENV
done
echo "EOF" >> $GITHUB_ENV
- name: Push release to github repository
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.metadata.outputs.version }}
body: |
Caddy release notes: https://github.com/caddyserver/caddy/releases/tag/v${{ needs.metadata.outputs.version }}
Custom builds:
${{ env.RELEASE_TEXT }}