Skip to content

Commit 191debc

Browse files
authored
Merge bd012ab into e495246
2 parents e495246 + bd012ab commit 191debc

File tree

5 files changed

+218
-1
lines changed

5 files changed

+218
-1
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/make-dist.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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: "Make dist and docs tarballs"
8+
9+
on:
10+
push:
11+
branches: [ "master", "FTY", "fightwarn" ]
12+
pull_request:
13+
# The branches below must be a subset of the branches above
14+
branches: [ "master", "FTY", "fightwarn" ]
15+
schedule:
16+
- cron: '15 12 * * 0'
17+
workflow_dispatch:
18+
# Allow manually running the action, e.g. if disabled after some quietness in the source
19+
20+
jobs:
21+
make-dist-tarballs:
22+
name: Make Dist and Docs Tarballs
23+
runs-on: ubuntu-latest
24+
permissions:
25+
actions: read
26+
contents: read
27+
security-events: write
28+
29+
strategy:
30+
fail-fast: false
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
36+
# Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db
37+
- name: NUT CI Prerequisite packages (Ubuntu, GCC)
38+
run: |
39+
echo "set man-db/auto-update false" | sudo debconf-communicate
40+
sudo dpkg-reconfigure man-db
41+
sudo apt update
42+
sudo apt install gcc g++ libltdl-dev libtool libtool-bin cppcheck ccache libgd-dev libcppunit-dev libsystemd-dev libssl-dev libnss3-dev augeas-tools libaugeas-dev augeas-lenses libusb-dev libusb-1.0-0-dev libmodbus-dev libsnmp-dev libpowerman0-dev libfreeipmi-dev libipmimonitoring-dev libavahi-common-dev libavahi-core-dev libavahi-client-dev libgpiod-dev libneon27-dev libi2c-dev i2c-tools lm-sensors ccache
43+
date > .timestamp-init
44+
45+
- name: Prepare ccache
46+
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
47+
id: cache-ccache
48+
uses: actions/cache@v4
49+
env:
50+
compiler: 'CC=gcc CXX=g++'
51+
cache-name: cache-ccache-${{ env.compiler }}
52+
with:
53+
path: |
54+
~/.ccache
55+
~/.cache/ccache
56+
~/.config/ccache/ccache.conf
57+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
58+
restore-keys: |
59+
${{ runner.os }}-build-${{ env.cache-name }}-
60+
${{ runner.os }}-build-
61+
${{ runner.os }}-
62+
63+
- name: CCache stats before build
64+
run: |
65+
ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well"
66+
rm -f .timestamp-init
67+
68+
# Make build identification more useful (no fallbacks)
69+
- name: Try to get more Git metadata
70+
run: |
71+
git remote -v || true
72+
git branch -a || true
73+
for R in `git remote` ; do git fetch $R master ; done || true
74+
git fetch --tags
75+
76+
- name: Debug gitlog2version processing
77+
run: bash -x ./tools/gitlog2version.sh || true
78+
79+
- if: matrix.build-mode != 'autobuild' && matrix.language == 'cpp'
80+
name: NUT CI Build Configuration
81+
env:
82+
compiler: 'CC=gcc CXX=g++'
83+
run: |
84+
PATH="/usr/lib/ccache:$PATH" ; export PATH
85+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
86+
ccache --version || true
87+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
88+
./autogen.sh && \
89+
./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all --with-dev --with-docs --enable-docs-changelog ${{env.compiler}}
90+
91+
# NOTE: In this scenario we do not build actually NUT in the main
92+
# checkout directory, at least not explicitly (recipe may generate
93+
# some files like man pages to fulfill the "dist" requirements).
94+
# We may `make docs` to provide them as a separate tarball just
95+
# in case, later.
96+
- name: NUT CI Build to create "dist" tarball and related files
97+
env:
98+
compiler: 'CC=gcc CXX=g++'
99+
run: |
100+
PATH="/usr/lib/ccache:$PATH" ; export PATH
101+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
102+
ccache --version || true
103+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
104+
make -s -j 8 dist-files
105+
106+
- name: NUT CI Build to verify "dist" tarball build
107+
env:
108+
compiler: 'CC=gcc CXX=g++'
109+
run: |
110+
PATH="/usr/lib/ccache:$PATH" ; export PATH
111+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
112+
ccache --version || true
113+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
114+
make -s -j 8 distcheck
115+
116+
- name: CCache stats after distcheck
117+
run: ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well"
118+
119+
- name: NUT CI Build to package complex docs (not part of dist tarball)
120+
run: |
121+
make -s -j 8 dist-docs
122+
123+
# Inspired by https://javahelps.com/manage-github-artifact-storage-quota
124+
# Note that the code below wipes everything matched by the filter!
125+
# We may want another script block (after this cleanup of obsolete data)
126+
# to iterate clearing the way build by build until there's X MB available.
127+
- if: env.GITHUB_REF_TYPE != 'tag' && env.GITHUB_HEAD_REF != 'master'
128+
name: Delete Old Artifacts for this feature branch/PR
129+
uses: actions/github-script@v6
130+
id: artifact
131+
with:
132+
script: |
133+
const res = await github.rest.actions.listArtifactsForRepo({
134+
owner: context.repo.owner,
135+
repo: context.repo.repo,
136+
})
137+
138+
res.data.artifacts
139+
.filter(({ name }) => name === 'tarballs-{{ env.GITHUB_HEAD_REF }}')
140+
.forEach(({ id }) => {
141+
github.rest.actions.deleteArtifact({
142+
owner: context.repo.owner,
143+
repo: context.repo.repo,
144+
artifact_id: id,
145+
})
146+
})
147+
148+
- name: Upload tarball and its checksum artifacts
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: tarballs-{{ env.GITHUB_HEAD_REF }}
152+
path: |
153+
nut-*.tar*
154+
compression-level: 0
155+
overwrite: true

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

docs/maintainer-guide.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ VERSION_FORCED_SEMVER:NUT_VERSION_FORCED_SEMVER='2.8.3'
272272
* `make dist-files` (especially if you did not `make distcheck` above,
273273
or had some changes since then) to store the source tarball, checksum
274274
and signature files
275+
** Bonus feature: `make dist-docs` (if on a system configured to build all
276+
documentation types)
275277

276278
* post-release update of the "in-development" codebase:
277279
** start a feature branch to return the master branch into development state

0 commit comments

Comments
 (0)