Skip to content

Commit 5f23cf9

Browse files
authored
Merge 5628353 into e495246
2 parents e495246 + 5628353 commit 5f23cf9

File tree

8 files changed

+402
-24
lines changed

8 files changed

+402
-24
lines changed

.github/workflows/01-make-dist.yml

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
# Adapted from NUT codeql.yml with inspiration taken from
2+
# https://javahelps.com/manage-github-artifact-storage-quota
3+
# regarding uploads of artifacts and clearing the way for them.
4+
# See also:
5+
# https://github.com/actions/upload-artifact
6+
# https://docs.github.com/en/actions/reference/workflows-and-actions/variables
7+
name: "GHA-01: Make dist and docs tarballs"
8+
9+
on:
10+
push:
11+
branches: [ "master", "FTY", "fightwarn", "FTY-obs" ]
12+
tags:
13+
- v*
14+
pull_request:
15+
# The branches below must be a subset of the branches above
16+
branches: [ "master", "FTY", "fightwarn", "FTY-obs" ]
17+
schedule:
18+
- cron: '15 12 * * 0'
19+
workflow_dispatch:
20+
# Allow manually running the action, e.g. if disabled after some quietness in the source
21+
22+
permissions:
23+
contents: read
24+
issues: write
25+
pull-requests: write
26+
27+
jobs:
28+
make-dist-tarballs:
29+
name: Make Dist and Docs Tarballs
30+
# FIXME: Prepare/maintain a container image with pre-installed
31+
# NUT build/tooling prereqs (save about 3 minutes per run!)
32+
runs-on: ubuntu-latest
33+
permissions:
34+
#actions: read
35+
actions: write
36+
#contents: read
37+
contents: write
38+
repository-projects: write
39+
security-events: write
40+
pull-requests: write
41+
issues: write
42+
43+
strategy:
44+
fail-fast: false
45+
46+
steps:
47+
# Post early so this would be about the top comment in the PR trail
48+
# (easy to see, contents replaced later)
49+
- name: "GHA-01: Make dist and docs tarballs - report download URL - t1"
50+
uses: thollander/actions-comment-pull-request@v3
51+
# if: startsWith(github.ref, 'refs/pull/')
52+
continue-on-error: true
53+
with:
54+
comment-tag: latest-tarball
55+
message: Dist and Docs will be linked here after the "make dist" job completes.
56+
#github-token: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: "GHA-01: Make dist and docs tarballs - report download URL - s1"
59+
uses: marocchino/sticky-pull-request-comment@v2
60+
# if: startsWith(github.ref, 'refs/pull/')
61+
continue-on-error: true
62+
with:
63+
header: latest-tarball-sticky
64+
only_create: true
65+
message: Dist and Docs will be linked here after the "make dist" job completes.
66+
#github-token: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Checkout repository
69+
uses: actions/checkout@v5
70+
with:
71+
fetch-depth: 0
72+
fetch-tags: true
73+
74+
# https://github.com/marketplace/actions/substitute-string
75+
# Note it warns about "unexpected input(s)" with replacement tokens below,
76+
# as they are by design not predefined, as far as actions API is concened.
77+
# They still work for substitutions though.
78+
- uses: bluwy/substitute-string-action@v3
79+
id: subst-github-ref-name
80+
with:
81+
_input-text: "${{ github.ref_name }}"
82+
" ": _
83+
"/": _
84+
- run: echo "${{ steps.subst-github-ref-name.outputs.result }}"
85+
86+
# Make build identification more useful (so we use no fallbacks in script)
87+
- name: Try to get more Git metadata
88+
run: |
89+
git describe || {
90+
git remote -v || true
91+
git branch -a || true
92+
for R in `git remote` ; do git fetch $R master ; done || true
93+
git fetch --tags
94+
pwd ; ls -la
95+
echo "=== Known commits in history:"
96+
git log --oneline | wc -l
97+
echo "=== Recent commits in history:"
98+
git log -2 || true
99+
echo "=== Known tags:"
100+
git tag || true
101+
echo "=== Try to ensure 'git describe' works:"
102+
git describe || {
103+
git fetch --all && for R in `git remote` ; do for T in `git tag` ; do git fetch $R $T ; done ; done
104+
git describe || {
105+
TEST_REF="`git symbolic-ref --short HEAD 2>/dev/null || cat .git/HEAD`" && [ -n "${TEST_REF}" ] && git checkout master && git pull --all && git checkout "${TEST_REF}"
106+
git describe || true
107+
}
108+
}
109+
}
110+
111+
# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
112+
# and our own docs/config-prereqs.txt
113+
# NOTE: Currently installing the MAX prerequisite footprint,
114+
# which for building just the docs may be a bit of an overkill.
115+
- name: NUT CI Prerequisite packages (Ubuntu, GCC)
116+
run: |
117+
echo "set man-db/auto-update false" | sudo debconf-communicate
118+
sudo dpkg-reconfigure man-db
119+
sudo apt update
120+
sudo apt install \
121+
gcc g++ clang \
122+
ccache time \
123+
git perl curl \
124+
make autoconf automake libltdl-dev libtool binutils \
125+
valgrind \
126+
cppcheck \
127+
pkg-config \
128+
libtool-bin \
129+
python3 gettext python3-pyqt6 pyqt6-dev-tools \
130+
aspell aspell-en \
131+
asciidoc source-highlight python3-pygments dblatex \
132+
libgd-dev \
133+
systemd-dev \
134+
libsystemd-dev \
135+
libcppunit-dev \
136+
libssl-dev libnss3-dev \
137+
augeas-tools libaugeas-dev augeas-lenses \
138+
libusb-dev libusb-1.0-0-dev \
139+
libi2c-dev \
140+
libmodbus-dev \
141+
libsnmp-dev \
142+
libpowerman0-dev \
143+
libfreeipmi-dev libipmimonitoring-dev \
144+
libavahi-common-dev libavahi-core-dev libavahi-client-dev \
145+
libgpiod-dev \
146+
bash dash ksh busybox \
147+
libneon27-gnutls-dev \
148+
build-essential git-core libi2c-dev i2c-tools lm-sensors \
149+
|| exit
150+
date > .timestamp-init
151+
152+
- name: Prepare ccache
153+
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
154+
id: cache-ccache
155+
uses: actions/cache@v4
156+
env:
157+
compiler: 'CC=gcc CXX=g++'
158+
cache-name: cache-ccache-${{ env.compiler }}
159+
with:
160+
path: |
161+
~/.ccache
162+
~/.cache/ccache
163+
~/.config/ccache/ccache.conf
164+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
165+
restore-keys: |
166+
${{ runner.os }}-build-${{ env.cache-name }}-
167+
${{ runner.os }}-build-
168+
${{ runner.os }}-
169+
170+
- name: CCache stats before build
171+
run: |
172+
ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well"
173+
rm -f .timestamp-init
174+
175+
- name: Debug gitlog2version processing
176+
run: bash -x ./tools/gitlog2version.sh || true
177+
178+
- name: NUT CI Build Configuration
179+
env:
180+
compiler: 'CC=gcc CXX=g++'
181+
run: |
182+
PATH="/usr/lib/ccache:$PATH" ; export PATH
183+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
184+
ccache --version || true
185+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
186+
./autogen.sh && \
187+
./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all --with-dev --with-docs --enable-docs-changelog ${{env.compiler}}
188+
189+
# NOTE: In this scenario we do not build actually NUT in the main
190+
# checkout directory, at least not explicitly (recipe may generate
191+
# some files like man pages to fulfill the "dist" requirements;
192+
# for now this may generate some libs to figure out their IDs).
193+
# We do `make docs` to provide them as a separate tarball just
194+
# in case, later.
195+
# DO NOT `make dist-files` here as it includes `dist-sig` and
196+
# needs a GPG keychain with maintainers' secrets deployed locally.
197+
- name: NUT CI Build to create "dist" tarball and related files
198+
env:
199+
compiler: 'CC=gcc CXX=g++'
200+
run: |
201+
PATH="/usr/lib/ccache:$PATH" ; export PATH
202+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
203+
ccache --version || true
204+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
205+
make -s -j 8 dist dist-hash
206+
207+
- name: NUT CI Build to verify "dist" tarball build
208+
env:
209+
compiler: 'CC=gcc CXX=g++'
210+
run: |
211+
PATH="/usr/lib/ccache:$PATH" ; export PATH
212+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
213+
ccache --version || true
214+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
215+
make -s -j 8 distcheck
216+
217+
- name: CCache stats after distcheck
218+
run: ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well"
219+
220+
- name: NUT CI Build to package complex docs (not part of dist tarball)
221+
run: |
222+
make -s -j 8 dist-docs
223+
224+
# Inspired by https://javahelps.com/manage-github-artifact-storage-quota
225+
# Note that the code below wipes everything matched by the filter!
226+
# We may want another script block (after this cleanup of obsolete data)
227+
# to iterate clearing the way build by build until there's X MB available
228+
# (at least 12MB as of Nov 2025).
229+
- if: env.GITHUB_REF_TYPE != 'tag' && steps.subst-github-ref-name.outputs.result != 'master'
230+
name: Delete Old Artifacts for this feature branch/PR
231+
uses: actions/github-script@v6
232+
id: delete_old_artifact_for_pr
233+
continue-on-error: true
234+
with:
235+
script: |
236+
const res = await github.rest.actions.listArtifactsForRepo({
237+
owner: context.repo.owner,
238+
repo: context.repo.repo,
239+
})
240+
241+
res.data.artifacts
242+
.filter(({ name }) => name === 'NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}')
243+
.forEach(({ id }) => {
244+
github.rest.actions.deleteArtifact({
245+
owner: context.repo.owner,
246+
repo: context.repo.repo,
247+
artifact_id: id,
248+
})
249+
})
250+
251+
- name: Upload tarball and its checksum artifacts
252+
uses: actions/upload-artifact@v4
253+
id: upload_artifact
254+
with:
255+
name: NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}
256+
path: |
257+
nut-*.tar*
258+
compression-level: 0
259+
overwrite: true
260+
261+
# https://github.com/thollander/actions-comment-pull-request
262+
# FIXME: Something that adds/updates Github Checks would be better
263+
# as it would be seen in the list attached to a status icon of any
264+
# build (e.g. history of master branch)
265+
- name: "GHA-01: Make dist and docs tarballs - report download URL - t2"
266+
uses: thollander/actions-comment-pull-request@v3
267+
# if: startsWith(github.ref, 'refs/pull/')
268+
continue-on-error: true
269+
with:
270+
comment-tag: latest-tarball
271+
message: Dist and Docs [NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}.zip}](${{ steps.upload_artifact.outputs.artifact-url }}) are available for commit ${{ github.sha }}
272+
#github-token: ${{ secrets.GITHUB_TOKEN }}
273+
274+
# https://github.com/marocchino/sticky-pull-request-comment
275+
- name: "GHA-01: Make dist and docs tarballs - report download URL - s2"
276+
uses: marocchino/sticky-pull-request-comment@v2
277+
# if: startsWith(github.ref, 'refs/pull/')
278+
continue-on-error: true
279+
with:
280+
header: latest-tarball-sticky
281+
only_create: true
282+
message: Dist and Docs [NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}.zip}](${{ steps.upload_artifact.outputs.artifact-url }}) are available for commit ${{ github.sha }}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# the `language` matrix defined below to confirm you have the correct set of
1010
# supported CodeQL languages.
1111
#
12-
name: "CodeQL"
12+
name: "GHA-05: CodeQL"
1313

1414
on:
1515
push:
@@ -96,7 +96,7 @@ jobs:
9696
id: cache-ccache
9797
uses: actions/cache@v4
9898
env:
99-
cache-name: cache-ccache-${{ matrix.compiler }}-${{ matrix.NUT_SSL_VARIANTS }}-${{ matrix.NUT_SSL_VARIANTS }}
99+
cache-name: cache-ccache-${{ matrix.compiler }}-${{ matrix.NUT_SSL_VARIANTS }}-${{ matrix.NUT_USB_VARIANTS }}
100100
with:
101101
path: |
102102
~/.ccache
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish PyNUT client bindings for NUT 🐍 distributions 📦 to PyPI
1+
name: "GHA-08: Publish PyNUT client bindings for NUT 🐍 distributions 📦 to PyPI"
22
# based on https://medium.com/@VersuS_/automate-pypi-releases-with-github-actions-4c5a9cfe947d
33
# and https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
44

Makefile.am

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,13 @@ EXTRA_DIST += VERSION_DEFAULT
823823

824824
# Best-effort delivery for (overly?) customized distros, e.g. via
825825
# echo NUT_VERSION_FORCED_SEMVER=1.1.1 > VERSION_FORCED_SEMVER
826+
# ONLY populated into dist tarball if present in the build area!
827+
# (Note we do tarball the VERSION_DEFAULT generated just above)
826828
dist-hook:
827829
for D in "$(abs_top_srcdir)" "$(abs_top_builddir)" ; do \
828830
for F in VERSION_FORCED VERSION_FORCED_SEMVER ; do \
829831
if [ -s "$$D/$$F" ] ; then \
832+
echo " DIST $$D/$$F => $(top_distdir)/$$F"; \
830833
cat "$$D/$$F" > "$(top_distdir)/$$F" || true ; \
831834
fi ; \
832835
done ; \
@@ -1019,6 +1022,9 @@ nut-@PACKAGE_VERSION@.tar.gz: dist
10191022
nut-@PACKAGE_VERSION@.tar.gz.sig: dist-sig
10201023
nut-@PACKAGE_VERSION@.tar.gz.md5 nut-@PACKAGE_VERSION@.tar.gz.sha256: dist-hash
10211024

1025+
# Bonus feature, results depend on configure script options and available tools
1026+
nut-@PACKAGE_VERSION@-docs.tar.gz: dist-docs
1027+
10221028
dist-sig: nut-@PACKAGE_VERSION@.tar.gz
10231029
rm -f nut-@PACKAGE_VERSION@.tar.gz.sig
10241030
gpg --detach-sign nut-@PACKAGE_VERSION@.tar.gz
@@ -1027,6 +1033,51 @@ dist-hash: nut-@PACKAGE_VERSION@.tar.gz
10271033
md5sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.md5
10281034
sha256sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.sha256
10291035

1036+
# Helper to have all built docs (config-dependent) neatly aligned
1037+
# NOT part of standard tarball, though
1038+
EXTRA_DIST_DOCS = VERSION_* *.adoc-parsed
1039+
1040+
if WITH_CHANGELOG_TEXT
1041+
EXTRA_DIST_DOCS += ChangeLog
1042+
endif WITH_CHANGELOG_TEXT
1043+
1044+
if WITH_CHANGELOG_ADOC
1045+
EXTRA_DIST_DOCS += ChangeLog.adoc
1046+
endif WITH_CHANGELOG_ADOC
1047+
1048+
if KEEP_NUT_REPORT
1049+
EXTRA_DIST_DOCS += config.nut_report_feature.log
1050+
endif KEEP_NUT_REPORT
1051+
1052+
if WITH_HTML_SINGLE
1053+
EXTRA_DIST_DOCS += docs/man/*.html docs/*.html
1054+
endif WITH_HTML_SINGLE
1055+
1056+
if WITH_HTML_CHUNKED
1057+
EXTRA_DIST_DOCS += docs/*.chunked
1058+
endif WITH_HTML_CHUNKED
1059+
1060+
if WITH_PDFS
1061+
EXTRA_DIST_DOCS += docs/*.pdf
1062+
endif WITH_PDFS
1063+
1064+
if WITH_MANS
1065+
if !KNOWN_UNABLE_MANS
1066+
EXTRA_DIST_DOCS += \
1067+
docs/man/*.@MAN_SECTION_API_BASE@ \
1068+
docs/man/*.@MAN_SECTION_CFG_BASE@ \
1069+
docs/man/*.@MAN_SECTION_CMD_SYS_BASE@ \
1070+
docs/man/*.@MAN_SECTION_CMD_USR_BASE@ \
1071+
docs/man/*.@MAN_SECTION_MISC_BASE@
1072+
endif !KNOWN_UNABLE_MANS
1073+
endif WITH_MANS
1074+
1075+
# Modeled after automake generated mesh of rules for "distdir" handling with "am__tar"
1076+
dist-docs: all-docs
1077+
$${TAR-tar} cf - $(EXTRA_DIST_DOCS) | eval GZIP= gzip $(GZIP_ENV) -c > $(distdir)-docs.tar.gz
1078+
ls -la $(distdir)-docs.tar.gz
1079+
$${TAR-tar} tzvf $(distdir)-docs.tar.gz || true
1080+
10301081
# ----------------------------------------------------------------------
10311082
# targets from old build system (pre-automake).
10321083
# supported for a period of time for backward "compatibility".

NEWS.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ several `FSD` notifications into one executed action. [PR #3097]
256256
- Updated `docs/*.txt`: add asciidoc comments with links to nut-website
257257
rendered contents of most interesting pages. [#3095]
258258

259+
- Added a `make dist-docs` goal to generate, collect and tarball all document
260+
types (man, html-single, html-chunked, pdf) that we may have enabled for the
261+
current build configuration and available tooling. [#1400]
262+
263+
- Added a GitHub Actions CI job to generate, upload and recycle `make dist`
264+
and `make dist-docs` tarballs so they are easier to obtain for people and
265+
other CI systems (which might not want to follow a Git repository). [#1400,
266+
#2829]
267+
259268
- Source directory `data/html` was renamed to `data/htmlcgi` in order to
260269
better reflect its contents and purpose, compared to documentation-oriented
261270
`html*` directories (and recipe variable names). This may impact some

0 commit comments

Comments
 (0)