Skip to content

Commit 65c67d6

Browse files
authored
Merge pull request #3158 from jimklimov/FTY-obs
CI: Generate downloadable tarballs as part of NUT CI farm builds; make default OBS recipes buildable
2 parents e495246 + 8c5f6c7 commit 65c67d6

File tree

8 files changed

+437
-27
lines changed

8 files changed

+437
-27
lines changed

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

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

0 commit comments

Comments
 (0)