-
-
Notifications
You must be signed in to change notification settings - Fork 127
214 lines (181 loc) · 8.21 KB
/
release.yml
File metadata and controls
214 lines (181 loc) · 8.21 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
name: Release
on:
release:
types: [published]
concurrency: build
# Sets global environment variables for releases
env:
SWAGGER_UI_VERSION: "5.17.10"
PYTHON_VERSION: "3.10"
DEFAULT_PFSENSE_VERSION: "2.8.0"
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
jobs:
release_pkg:
runs-on: self-hosted
strategy:
matrix:
include:
# Note: The first item in this matrix must use env.DEFAULT_PFSENSE_VERSION as the PFSENSE_VERSION!
- FREEBSD_VERSION: FreeBSD-15.0-CURRENT
PFSENSE_VERSION: "2.8.0"
- FREEBSD_VERSION: FreeBSD-15.0-CURRENT
PFSENSE_VERSION: "2.8.1"
- FREEBSD_VERSION: FreeBSD-15.0-CURRENT
PFSENSE_VERSION: "24.11"
- FREEBSD_VERSION: FreeBSD-15.0-CURRENT
PFSENSE_VERSION: "25.07"
- FREEBSD_VERSION: FreeBSD-15.0-CURRENT
PFSENSE_VERSION: "25.07.1"
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
PFSENSE_VERSION: "25.11"
- FREEBSD_VERSION: FreeBSD-16.0-CURRENT
PFSENSE_VERSION: "25.11.1"
steps:
- uses: actions/checkout@v6
- name: Setup FreeBSD build VM
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.FREEBSD_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{ matrix.FREEBSD_VERSION }} restore initial
/usr/local/bin/VBoxManage startvm ${{ matrix.FREEBSD_VERSION }} --type headless
sleep 5
- name: Build pfSense-pkg-RESTAPI on FreeBSD
run: |
/usr/bin/ssh -o StrictHostKeyChecking=no ${{ matrix.FREEBSD_VERSION }}.actions.pfrest.org 'sudo pkill ntpd || true && sudo ntpdate pool.ntp.org || true'
/usr/local/bin/python3 tools/make_package.py --host ${{ matrix.FREEBSD_VERSION }}.actions.pfrest.org --branch ${{ github.sha }} --tag ${{ github.ref_name }} --filename pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg --notests
- name: Teardown FreeBSD build VM
if: "${{ always() }}"
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.FREEBSD_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{matrix.FREEBSD_VERSION}} restore initial
- uses: actions/upload-artifact@v6
with:
name: pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg
path: pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg
- name: Release
uses: softprops/action-gh-release@v2
with:
files: pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg
build_schemas:
runs-on: self-hosted
needs: [release_pkg]
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v7
with:
name: pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg
path: pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg
- name: Setup pfSense VM
run: |
/usr/local/bin/VBoxManage controlvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE poweroff || true
/usr/local/bin/VBoxManage snapshot pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE restore initial
/usr/local/bin/VBoxManage startvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE --type headless
sleep 5
# This is only necessary until GitHub Actions allows an easier way to get a URL to download the artifact within pfSense
- name: Copy pfSense-pkg-RESTAPI build to pfSense
run: |
pfsense-vshell --host pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.actions.pfrest.org -u admin -p pfsense -c 'pfSsh.php playback enablesshd' -k
pfsense-vshell --host pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.actions.pfrest.org -u admin -p pfsense -c "mkdir /root/.ssh/ && echo $(cat ~/.ssh/id_rsa.pub) > /root/.ssh/authorized_keys" -k
scp -o StrictHostKeyChecking=no pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg/pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg admin@pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.actions.pfrest.org:/tmp/
- name: Install pfSense-pkg-RESTAPI on pfSense
run: |
ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.actions.pfrest.org "pkg -C /dev/null add /tmp/pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg"
sleep 5
- name: Fetch schemas from pfSense
run: |
curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.actions.pfrest.org/api/v2/schema/openapi > openapi.json
curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.actions.pfrest.org/api/v2/schema/graphql > schema.graphql
- name: Teardown pfSense VM
if: "${{ always() }}"
run: |
/usr/local/bin/VBoxManage controlvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE poweroff || true
/usr/local/bin/VBoxManage snapshot pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE restore initial
- name: Upload OpenAPI schema
uses: actions/upload-artifact@v6
with:
name: openapi.json
path: openapi.json
- name: Upload GraphQL schema
uses: actions/upload-artifact@v6
with:
name: schema.graphql
path: schema.graphql
release_docs:
needs: [build_schemas]
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- name: Setup Pages
uses: actions/configure-pages@v5.0.0
- name: Make website directory
run: mkdir ./www
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build mkdocs site
run: |
python3 -m pip install -r ./requirements.txt
python3 -m mkdocs build
mv ./site/* ./www/
- name: Download OpenAPI schema
uses: actions/download-artifact@v7
with:
name: openapi.json
path: openapi.json
- name: Download GraphQL schema
uses: actions/download-artifact@v7
with:
name: schema.graphql
path: schema.graphql
- name: Build Swagger UI
run: |
mkdir -p ./www/api-docs/
wget -O /tmp/swagger.tar.gz https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${{ env.SWAGGER_UI_VERSION }}.tar.gz
tar -xzf /tmp/swagger.tar.gz -C /tmp/
cp -r /tmp/swagger-ui-${{ env.SWAGGER_UI_VERSION }}/dist/* ./www/api-docs/
cp pfSense-pkg-RESTAPI/files/usr/local/www/api/swagger/index.css ./www/api-docs/index.css
cp openapi.json/openapi.json ./www/api-docs/openapi.json
echo 'window.onload = function() {
document.title = "pfSense REST API Documentation";
window.ui = SwaggerUIBundle({
url: "/api-docs/openapi.json",
dom_id: "#swagger-ui",
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
supportedSubmitMethods: [],
validatorUrl: null
});
};' > ./www/api-docs/swagger-initializer.js
- name: Write GraphQL schema
run: |
mkdir -p ./www/graphql-docs/
cp schema.graphql/schema.graphql ./www/graphql-docs/schema.graphql
- name: Build PHP reference documentation
run: |
mkdir ./www/php-docs
wget https://phpdoc.org/phpDocumentor.phar
chmod +x phpDocumentor.phar
./phpDocumentor.phar
mv ./.phpdoc/build/* ./www/php-docs/
- name: Upload artifact
uses: actions/upload-pages-artifact@v4.0.0
with:
path: "./www"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4.0.5