-
-
Notifications
You must be signed in to change notification settings - Fork 264
155 lines (154 loc) · 5.3 KB
/
static.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
---
name: Build binary releases
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- v*.*.*
workflow_dispatch:
inputs: {}
schedule:
- cron: '0 0 * * *'
jobs:
release:
if: github.ref_type == 'tag'
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Create release
uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
prepare:
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.ref.outputs.ref }}
steps:
-
name: Get latest release
id: ref
if: github.event_name == 'schedule'
run: echo ref="$(gh release view --repo dunglas/frankenphp --json tagName --jq '.tagName')" >> "${GITHUB_OUTPUT}"
build-linux:
name: Build Linux x86_64 binary
runs-on: ubuntu-latest
needs: [ prepare ]
steps:
-
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.ref }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
-
name: Login to DockerHub
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
uses: docker/login-action@v3
with:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_PASSWORD}}
-
name: Build
id: build
uses: docker/bake-action@v4
with:
pull: true
load: ${{toJson(github.event_name != 'schedule' && !startsWith(github.ref, 'refs/tags/') && (github.ref != 'refs/heads/main' || github.event_name == 'pull_request'))}}
push: ${{toJson(github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request'))}}
targets: static-builder
set: |
*.cache-from=type=gha,scope=${{github.ref}}-static-builder
*.cache-from=type=gha,scope=refs/heads/main-static-builder
*.cache-to=type=gha,scope=${{github.ref}}-static-builder
env:
LATEST: '1' # TODO: unset this variable when releasing the first stable version
SHA: ${{github.sha}}
VERSION: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref || github.sha}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Pull Docker image
if: github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
run: docker pull dunglas/frankenphp:static-builder
-
name: Copy binary
run: docker cp "$(docker create --name static-builder dunglas/frankenphp:static-builder):/go/src/app/dist/frankenphp-linux-x86_64" frankenphp-linux-x86_64 ; docker rm static-builder
-
name: Upload asset
if: github.event_name == 'schedule' || github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
tag: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}
generateReleaseNotes: true
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifacts: frankenphp-linux-x86_64
replacesArtifacts: true
-
name: Upload artifact
if: github.ref_type == 'branch'
uses: actions/upload-artifact@v3
with:
path: frankenphp-linux-x86_64
build-mac:
name: Build macOS x86_64 binaries
runs-on: macos-latest
needs: [ prepare ]
env:
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
-
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.ref }}
-
uses: actions/setup-go@v5
with:
go-version: '1.21'
cache-dependency-path: |
go.sum
caddy/go.sum
-
name: Set FRANKENPHP_VERSION
run: |
if [ "${GITHUB_REF_TYPE}" == "tag" ]; then
export FRANKENPHP_VERSION=${GITHUB_REF_NAME:1}
elif [ "${GITHUB_EVENT_NAME}" == "schedule" ]; then
export FRANKENPHP_VERSION="${{ needs.prepare.outputs.ref }}"
else
export FRANKENPHP_VERSION=${GITHUB_SHA}
fi
echo "FRANKENPHP_VERSION=${FRANKENPHP_VERSION}" >> "${GITHUB_ENV}"
-
name: Build FrankenPHP
run: ./build-static.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Upload asset
if: github.event_name == 'schedule' || github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
tag: ${{ (github.ref_type == 'tag' && github.ref_name) || needs.prepare.outputs.ref }}
generateReleaseNotes: true
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifacts: dist/frankenphp-mac-x86_64
replacesArtifacts: true
-
name: Upload artifact
if: github.ref_type == 'branch'
uses: actions/upload-artifact@v3
with:
path: dist/frankenphp-mac-x86_64