-
-
Notifications
You must be signed in to change notification settings - Fork 11
160 lines (142 loc) · 4.41 KB
/
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Release
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
phar:
name: Compile PHAR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Check if tag is valid
- name: Check tag
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
exit 1
fi
# Prepare environment
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2,phive
# Compile PHAR
- name: Install box
run: phive install --trust-gpg-keys 2DF45277AEF09A2F humbug/box
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-dev"
- name: Compile PHAR
run: ./tools/box compile --with-docker
# Upload compiled PHAR as artifact
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: phar
path: |
.build/cache-warmup.phar
Dockerfile
docker:
name: Docker deploy
runs-on: ubuntu-latest
needs: phar
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Check if tag is valid
- name: Check tag
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
exit 1
fi
# Download PHAR and Dockerfile
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: phar
- name: Make PHAR executable
run: chmod +x .build/cache-warmup.phar
# Generate metadata
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
eliashaeussler/cache-warmup
ghcr.io/eliashaeussler/cache-warmup
tags: |
type=raw,value=latest,enable=${{ github.event_name != 'workflow_dispatch' }}
type=semver,pattern={{version}}
type=raw,value=${{ github.ref_name }},enable=${{ github.event_name == 'workflow_dispatch' }}
# Prepare build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login at Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Login at GitHub container registry
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push image
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Job: Create release
release:
name: Create release
if: ${{ github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
needs: phar
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Check if tag is valid
- name: Check tag
run: |
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
exit 1
fi
# Download PHAR
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: phar
- name: Make PHAR executable
run: chmod +x .build/cache-warmup.phar
# Sign PHAR file
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.PHAR_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PHAR_GPG_PASSPHRASE }}
- name: Sign PHAR file
run: gpg --armor --output .build/cache-warmup.phar.asc --yes --detach-sig .build/cache-warmup.phar
# Create release
- name: Create release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
artifacts: .build/cache-warmup.phar,.build/cache-warmup.phar.asc