-
Notifications
You must be signed in to change notification settings - Fork 678
241 lines (221 loc) · 8.21 KB
/
publish.yml
File metadata and controls
241 lines (221 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Publish
on:
push:
tags: [v*]
permissions:
contents: read
jobs:
publish-docker:
runs-on: ubuntu-latest
timeout-minutes: 120
environment:
name: publish
url: https://hub.docker.com/r/newfuture/ddns
permissions:
packages: write
env:
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/riscv64,linux/s390x
steps:
- uses: actions/checkout@v4
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.platforms }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/newfuture/ddns
newfuture/ddns
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- uses: docker/build-push-action@v6
with:
context: .
file: .build/Dockerfile
platforms: ${{ env.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
publish-pypi:
runs-on: ubuntu-latest
timeout-minutes: 5
environment:
name: publish
url: https://pypi.org/project/ddns/
permissions:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- uses: actions/checkout@v4
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --sdist --wheel --outdir dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
publish-binary:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
arch: x64
- os: windows-latest
arch: x86
- os: windows-11-arm
arch: arm64
- os: ubuntu-latest
arch: x64
- os: ubuntu-24.04-arm
arch: arm64
- os: macos-13
arch: x64
- os: macos-latest
arch: arm64
runs-on: ${{ matrix.os }}
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
architecture: ${{ matrix.arch }}
- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
- name: remove python2 code
run: python3 .build/patch.py
- name: Set up on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update && sudo apt-get install -y patchelf
cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem
- name: Set up on macOS
if: runner.os == 'macOS'
run: python3 -m pip install imageio
- name: test run.py
run: python3 ./run.py -h
- name: Build Executable
uses: Nuitka/Nuitka-Action@v1.3
with:
nuitka-version: main
script-name: run.py
mode: onefile
output-dir: dist
output-file: ddns
no-deployment-flag: self-execution
include-module: |
dns.dnspod
dns.alidns
dns.dnspod_com
dns.dnscom
dns.cloudflare
dns.he
dns.huaweidns
dns.callback
file-description: "DDNS Client 更新域名解析本机IP"
product-name: DDNS
company-name: "New Future"
copyright: "https://ddns.newfuture.cc"
assume-yes-for-downloads: true
lto: auto
python-flag: no_site,no_asserts,no_docstrings,isolated,static_hashes
nofollow-import-to: tkinter,unittest,pydoc,doctest,distutils,setuptools,lib2to3,test,idlelib,lzma
onefile-tempdir-spec: "{CACHE_DIR}/{PRODUCT}_{VERSION}"
windows-icon-from-ico: ${{ runner.os == 'Windows' && 'favicon.ico' || '' }}
linux-icon: ${{ runner.os == 'Linux' && 'doc/img/ddns.svg' || '' }}
static-libpython: ${{ runner.os == 'Linux' && 'yes' || 'auto' }}
macos-app-name: ${{ runner.os == 'macOS' && 'DDNS' || '' }}
macos-app-icon: ${{ runner.os == 'macOS' && 'doc/img/ddns.svg' || '' }}
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h
- run: mv ./dist/ddns ./dist/ddns-ubuntu24.04-${{ matrix.arch }}
if: runner.os == 'Linux'
- run: mv ./dist/ddns ./dist/ddns-mac-${{ matrix.arch }}
if: runner.os == 'macOS'
- run: mv ./dist/ddns.exe ./dist/ddns-windows-${{ matrix.arch }}.exe
if: runner.os == 'Windows'
- name: Upload binary
run: gh release upload ${{ github.ref_name }} dist/ddns*
shell: bash
env:
GH_TOKEN: ${{ github.token }}
publish-linux-general:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, ubuntu-24.04-arm ]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/checkout@v4
# Prepare build
- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
# https://github.com/Nuitka/Nuitka/issues/2723#issuecomment-1960831891
- name: Run the build process with CentOS Docker
uses: addnab/docker-run-action@v3
with:
image: docker.io/centos:8
options: -v ${{ github.workspace }}:/DDNS
run: |
cd /etc/yum.repos.d/ && sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
dnf install -y epel-release \
&& dnf repolist \
&& dnf install -y gcc strace patchelf ccache gdb make python3-devel python3-zstandard python3-ordered-set
python3 -m pip install nuitka
cd /DDNS && python3 .build/patch.py && .build/nuitka.sh
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h
- run: sudo mv ./dist/ddns ./dist/ddns-linux-$(echo "${{ runner.arch }}" | tr '[:upper:]' '[:lower:]')
- name: Upload binary
run: gh release upload ${{ github.ref_name }} dist/ddns*
env:
GH_TOKEN: ${{ github.token }}
github-release:
runs-on: ubuntu-latest
timeout-minutes: 5
environment:
name: publish
url: https://github.com/NewFuture/DDNS/releases/tag/${{ github.ref_name }}
permissions:
contents: write
needs: [publish-docker, publish-pypi, publish-binary, publish-linux-general]
steps:
- uses: actions/checkout@v4
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" .github/release.md
- name: Upload files
run: gh release upload ${{ github.ref_name }} .release/*.sh .release/*.bat --clobber
env:
GH_TOKEN: ${{ github.token }}
- name: Generate release notes and append README.md
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release view ${{ github.ref_name }} --json body -q '.body' > release_notes.md
cat .github/release.md >> release_notes.md
gh release edit ${{ github.ref_name }} --notes-file release_notes.md