-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (189 loc) · 7.05 KB
/
release-build.yml
File metadata and controls
218 lines (189 loc) · 7.05 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Build and Publish Images
on:
workflow_dispatch:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}
env:
PHP_STABLE_VERSION: '8.3'
NODE_STABLE_VERSION: '22'
REGISTRY: ghcr.io
OWNER: ndigitals
PACKAGE: wp-dev-container
ACTION_VERSION: 1
jobs:
build:
name: Build Images
strategy:
fail-fast: false
matrix:
PHP_VERSION:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
NODE_VERSION:
- '16'
- '18'
- '20'
- '22'
- '24'
builder:
- ubuntu-22.04
- self-hosted
platform:
- amd64
- arm64
exclude:
- builder: ubuntu-22.04
platform: arm64
- builder: self-hosted
platform: amd64
runs-on:
- ${{ matrix.builder }}
concurrency:
group: ${{ matrix.PHP_VERSION }}-${{ matrix.NODE_VERSION }}-${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/marketplace/actions/docker-login
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
# https://github.com/marketplace/actions/setup-node-js-environment
- name: Setup Node Environment
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
# https://github.com/marketplace/actions/dev-container-build-and-run-action
- name: Pre-build Dev Container Image
uses: devcontainers/ci@v0.3
if: matrix.platform == 'amd64'
env:
# see: https://github.com/devcontainers/ci/issues/191#issuecomment-1603857155
BUILDX_NO_DEFAULT_ATTESTATIONS: true
PHP_VERSION: ${{ matrix.PHP_VERSION }}
NODE_VERSION: ${{ matrix.NODE_VERSION }}
with:
platform: linux/${{ matrix.platform }}
imageName: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}
cacheFrom: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}
imageTag: php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }},php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-${{ matrix.platform }}
push: always
skipContainerUserIdUpdate: true
# https://github.com/marketplace/actions/dev-container-build-and-run-action
- name: Pre-build Dev Container Image
uses: devcontainers/ci@v0.3
if: matrix.platform == 'arm64'
env:
# see: https://github.com/devcontainers/ci/issues/191#issuecomment-1603857155
BUILDX_NO_DEFAULT_ATTESTATIONS: true
PHP_VERSION: ${{ matrix.PHP_VERSION }}
NODE_VERSION: ${{ matrix.NODE_VERSION }}
with:
platform: linux/${{ matrix.platform }}
imageName: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}
cacheFrom: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}
imageTag: php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-${{ matrix.platform }}
push: always
skipContainerUserIdUpdate: true
upload:
name: Upload Images
needs: build
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
PHP_VERSION:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
NODE_VERSION:
- '16'
- '18'
- '20'
- '22'
- '24'
runs-on: ubuntu-latest
concurrency:
group: ${{ matrix.PHP_VERSION }}-${{ matrix.NODE_VERSION }}
steps:
# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/marketplace/actions/docker-login
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
logout: false
# https://github.com/marketplace/actions/docker-metadata-action
- name: Docker Metadata
uses: docker/metadata-action@v5
id: metadata
with:
tags: type=raw,value=php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}
- name: Inspect Images
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64
- name: Create Manifest List and Push
run: |
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} \
--append ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64
- name: Inspect Manifest List
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}
release:
name: Publish Release
runs-on: ubuntu-latest
needs: upload
steps:
# https://github.com/marketplace/actions/semver-conventional-commits
- name: Get Versions
id: semver
uses: ietf-tools/semver-action@v1
if: github.event_name == 'push'
with:
token: ${{ github.token }}
branch: main
- name: Create Release Name
id: release-name
if: github.event_name == 'push'
run: |
RELEASE_NAME=$(echo ${{ steps.semver.outputs.nextStrict }} Release)
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_OUTPUT
# https://github.com/marketplace/actions/universal-changelog-generator
- name: Generate a Changelog
id: changelog
uses: mrchief/universal-changelog-action@v1.3.2
if: github.event_name == 'push'
with:
previousReleaseTagNameOrSha: ${{ steps.semver.outputs.current }}
nextReleaseTagName: 'main'
nextReleaseName: ${{ steps.release-name.outputs.RELEASE_NAME }}
# https://github.com/marketplace/actions/create-release
- name: Create Release
uses: ncipollo/release-action@v1.20.0
if: github.event_name == 'push'
with:
name: ${{ steps.release-name.outputs.RELEASE_NAME }}
tag: ${{ steps.semver.outputs.next }}
commit: ${{ github.sha }}
body: ${{ steps.changelog.outputs.changelog }}