-
-
Notifications
You must be signed in to change notification settings - Fork 11
235 lines (204 loc) · 8.51 KB
/
publish-fork.yaml
File metadata and controls
235 lines (204 loc) · 8.51 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: publish-fork
# Build, test and publish Docker images to GitHub Container Registry (ghcr.io).
# - Triggers: Manual dispatch only (workflow_dispatch)
# - Runs on: Any fork (uses built-in GITHUB_TOKEN — no extra secrets required)
#
# Images are published to ghcr.io/<owner>/firebird
# Default scope: latest Firebird version + bookworm (fast, ~2 minutes)
# Default result: ONE package — ghcr.io/<owner>/firebird — with all expected tags.
#
# With include-arm64=true: publishes ghcr.io/<owner>/firebird as a multi-arch image
# (plus temporary staging packages firebird-amd64 / firebird-arm64 needed for manifest creation).
#
# Usage:
# Go to Actions → publish-fork → Run workflow
# Pull with: docker pull ghcr.io/<your-username>/firebird:<tag>
on:
workflow_dispatch:
inputs:
version-filter:
description: 'Version filter (e.g. 5, 5.0.3). Empty = latest only.'
required: false
type: string
distro-filter:
description: 'Distro filter (e.g. bookworm, jammy). Empty = default distro (bookworm).'
required: false
type: string
include-arm64:
description: 'Also build ARM64 images (takes ~2x longer; produces extra staging packages).'
required: false
type: boolean
default: false
include-snapshots:
description: 'Also build and publish snapshot images (6-snapshot, 5-snapshot).'
required: false
type: boolean
default: false
# Only one run at a time per fork.
concurrency:
group: ${{ github.workflow }}-${{ github.repository }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_NAME: firebird
jobs:
determine-scope:
runs-on: ubuntu-latest
outputs:
version-filter: ${{ steps.scope.outputs.version-filter }}
distro-filter: ${{ steps.scope.outputs.distro-filter }}
matrix: ${{ steps.scope.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Determine build scope
id: scope
shell: pwsh
run: |
$assets = Get-Content -Raw ./assets.json | ConvertFrom-Json
# Use input or default to latest version + default distro
$vf = '${{ inputs.version-filter }}'
$df = '${{ inputs.distro-filter }}'
if (-not $vf) { $vf = $assets.versions[0].version }
if (-not $df) { $df = $assets.config.defaultDistro }
"version-filter=$vf" >> $env:GITHUB_OUTPUT
"distro-filter=$df" >> $env:GITHUB_OUTPUT
# Build arch matrix based on input
$includeArm64 = '${{ inputs.include-arm64 }}' -eq 'true'
$matrix = if ($includeArm64) {
'{"arch":["amd64","arm64"],"include":[{"arch":"amd64","runner":"ubuntu-latest"},{"arch":"arm64","runner":"ubuntu-24.04-arm"}]}'
} else {
'{"arch":["amd64"],"include":[{"arch":"amd64","runner":"ubuntu-latest"}]}'
}
"matrix=$matrix" >> $env:GITHUB_OUTPUT
build-and-push:
needs: determine-scope
permissions:
packages: write
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.determine-scope.outputs.matrix) }}
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install tools
shell: pwsh
run: |
Install-Module InvokeBuild -Force
Install-Module PSFirebird -MinimumVersion '1.0.0' -Force
- name: Build
shell: pwsh
run: |
Invoke-Build Build `
-VersionFilter '${{ needs.determine-scope.outputs.version-filter }}' `
-DistributionFilter '${{ needs.determine-scope.outputs.distro-filter }}' `
-Registry '${{ env.REGISTRY }}'
- name: Test
shell: pwsh
run: |
Invoke-Build Test `
-VersionFilter '${{ needs.determine-scope.outputs.version-filter }}' `
-DistributionFilter '${{ needs.determine-scope.outputs.distro-filter }}' `
-Registry '${{ env.REGISTRY }}'
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# amd64-only: push as the final image name — produces exactly ONE package.
- name: Push (amd64 only — final name, no staging)
if: ${{ !inputs.include-arm64 }}
shell: pwsh
run: |
Invoke-Build Publish-Direct `
-VersionFilter '${{ needs.determine-scope.outputs.version-filter }}' `
-DistributionFilter '${{ needs.determine-scope.outputs.distro-filter }}' `
-Registry '${{ env.REGISTRY }}'
# multi-arch: push with -amd64/-arm64 staging suffixes for later manifest creation.
- name: Push (staging for multi-arch manifest)
if: ${{ inputs.include-arm64 }}
shell: pwsh
run: |
Invoke-Build Publish-Arch `
-VersionFilter '${{ needs.determine-scope.outputs.version-filter }}' `
-DistributionFilter '${{ needs.determine-scope.outputs.distro-filter }}' `
-Registry '${{ env.REGISTRY }}'
- name: Build and push snapshot images
if: ${{ inputs.include-snapshots && matrix.arch == 'amd64' }}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
foreach ($branch in @('master', 'v5.0-release')) {
Invoke-Build Build-Snapshot -Branch $branch -Registry '${{ env.REGISTRY }}'
$tag = if ($branch -eq 'master') { '6-snapshot' } else { '5-snapshot' }
docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$tag"
}
# Summary only for the amd64-only case (multi-arch summary is in create-manifests).
- name: Summary
if: ${{ !inputs.include-arm64 && matrix.arch == 'amd64' }}
shell: pwsh
run: |
$vf = '${{ needs.determine-scope.outputs.version-filter }}'
$df = '${{ needs.determine-scope.outputs.distro-filter }}'
$registry = '${{ env.REGISTRY }}'
$imageName = '${{ env.IMAGE_NAME }}'
$assets = Get-Content -Raw ./assets.json | ConvertFrom-Json
$filtered = $assets.versions | Where-Object { $_.version -like "$vf*" }
$tags = $filtered | ForEach-Object { $_.tags.$df } | Select-Object -First 5
@"
## Published to GitHub Container Registry
**Registry:** ``$registry/$imageName``
### Pull commands
``````
$(($tags | ForEach-Object { "docker pull $registry/${imageName}:$_" }) -join "`n")
``````
"@ >> $env:GITHUB_STEP_SUMMARY
# Only runs when include-arm64=true. Creates multi-arch OCI manifests from staging images.
create-manifests:
if: ${{ inputs.include-arm64 }}
needs: [determine-scope, build-and-push]
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install tools
shell: pwsh
run: |
Install-Module InvokeBuild -Force
Install-Module PSFirebird -MinimumVersion '1.0.0' -Force
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifests
shell: pwsh
run: |
Invoke-Build Publish-Manifests `
-VersionFilter '${{ needs.determine-scope.outputs.version-filter }}' `
-DistributionFilter '${{ needs.determine-scope.outputs.distro-filter }}' `
-Registry '${{ env.REGISTRY }}'
- name: Summary
shell: pwsh
run: |
$vf = '${{ needs.determine-scope.outputs.version-filter }}'
$df = '${{ needs.determine-scope.outputs.distro-filter }}'
$registry = '${{ env.REGISTRY }}'
$imageName = '${{ env.IMAGE_NAME }}'
$assets = Get-Content -Raw ./assets.json | ConvertFrom-Json
$filtered = $assets.versions | Where-Object { $_.version -like "$vf*" }
$tags = $filtered | ForEach-Object { $_.tags.$df } | Select-Object -First 5
@"
## Published to GitHub Container Registry (multi-arch)
**Registry:** ``$registry/$imageName``
### Pull commands
``````
$(($tags | ForEach-Object { "docker pull $registry/${imageName}:$_" }) -join "`n")
``````
"@ >> $env:GITHUB_STEP_SUMMARY