Skip to content

Commit f64ec1a

Browse files
committed
.github/workflows/01-make-dist.yml, NEWS.adoc: introduce a CI job to maintain dist tarballs of recent iterations [#1400, #2829]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent a27e826 commit f64ec1a

File tree

2 files changed

+192
-0
lines changed

2 files changed

+192
-0
lines changed

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

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
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" ]
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+
# and our own docs/config-prereqs.txt
38+
# NOTE: Currently installing the MAX prerequisite footprint,
39+
# which for building just the docs may be a bit of an overkill.
40+
- name: NUT CI Prerequisite packages (Ubuntu, GCC)
41+
run: |
42+
echo "set man-db/auto-update false" | sudo debconf-communicate
43+
sudo dpkg-reconfigure man-db
44+
sudo apt update
45+
sudo apt install \
46+
gcc g++ clang \
47+
ccache time \
48+
git perl curl \
49+
make autoconf automake libltdl-dev libtool binutils \
50+
valgrind \
51+
cppcheck \
52+
pkg-config \
53+
libtool-bin \
54+
python3 gettext python3-pyqt6 pyqt6-dev-tools \
55+
aspell aspell-en \
56+
asciidoc source-highlight python3-pygments dblatex \
57+
libgd-dev \
58+
systemd-dev \
59+
libsystemd-dev \
60+
libcppunit-dev \
61+
libssl-dev libnss3-dev \
62+
augeas-tools libaugeas-dev augeas-lenses \
63+
libusb-dev libusb-1.0-0-dev \
64+
libi2c-dev \
65+
libmodbus-dev \
66+
libsnmp-dev \
67+
libpowerman0-dev \
68+
libfreeipmi-dev libipmimonitoring-dev \
69+
libavahi-common-dev libavahi-core-dev libavahi-client-dev \
70+
libgpiod-dev \
71+
bash dash ksh busybox \
72+
libneon27-gnutls-dev \
73+
build-essential git-core libi2c-dev i2c-tools lm-sensors \
74+
|| exit
75+
date > .timestamp-init
76+
77+
- name: Prepare ccache
78+
# Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example
79+
id: cache-ccache
80+
uses: actions/cache@v4
81+
env:
82+
compiler: 'CC=gcc CXX=g++'
83+
cache-name: cache-ccache-${{ env.compiler }}
84+
with:
85+
path: |
86+
~/.ccache
87+
~/.cache/ccache
88+
~/.config/ccache/ccache.conf
89+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }}
90+
restore-keys: |
91+
${{ runner.os }}-build-${{ env.cache-name }}-
92+
${{ runner.os }}-build-
93+
${{ runner.os }}-
94+
95+
- name: CCache stats before build
96+
run: |
97+
ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well"
98+
rm -f .timestamp-init
99+
100+
# Make build identification more useful (no fallbacks)
101+
- name: Try to get more Git metadata
102+
run: |
103+
git remote -v || true
104+
git branch -a || true
105+
for R in `git remote` ; do git fetch $R master ; done || true
106+
git fetch --tags
107+
108+
- name: Debug gitlog2version processing
109+
run: bash -x ./tools/gitlog2version.sh || true
110+
111+
- name: NUT CI Build Configuration
112+
env:
113+
compiler: 'CC=gcc CXX=g++'
114+
run: |
115+
PATH="/usr/lib/ccache:$PATH" ; export PATH
116+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
117+
ccache --version || true
118+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
119+
./autogen.sh && \
120+
./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all --with-dev --with-docs --enable-docs-changelog ${{env.compiler}}
121+
122+
# NOTE: In this scenario we do not build actually NUT in the main
123+
# checkout directory, at least not explicitly (recipe may generate
124+
# some files like man pages to fulfill the "dist" requirements;
125+
# for now this may generate some libs to figure out their IDs).
126+
# We may `make docs` to provide them as a separate tarball just
127+
# in case, later.
128+
- name: NUT CI Build to create "dist" tarball and related files
129+
env:
130+
compiler: 'CC=gcc CXX=g++'
131+
run: |
132+
PATH="/usr/lib/ccache:$PATH" ; export PATH
133+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
134+
ccache --version || true
135+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
136+
make -s -j 8 dist-files
137+
138+
- name: NUT CI Build to verify "dist" tarball build
139+
env:
140+
compiler: 'CC=gcc CXX=g++'
141+
run: |
142+
PATH="/usr/lib/ccache:$PATH" ; export PATH
143+
CCACHE_COMPRESS=true; export CCACHE_COMPRESS
144+
ccache --version || true
145+
( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true
146+
make -s -j 8 distcheck
147+
148+
- name: CCache stats after distcheck
149+
run: ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well"
150+
151+
- name: NUT CI Build to package complex docs (not part of dist tarball)
152+
run: |
153+
make -s -j 8 dist-docs
154+
155+
# Inspired by https://javahelps.com/manage-github-artifact-storage-quota
156+
# Note that the code below wipes everything matched by the filter!
157+
# We may want another script block (after this cleanup of obsolete data)
158+
# to iterate clearing the way build by build until there's X MB available.
159+
- if: env.GITHUB_REF_TYPE != 'tag' && env.GITHUB_HEAD_REF != 'master'
160+
name: Delete Old Artifacts for this feature branch/PR
161+
uses: actions/github-script@v6
162+
id: artifact
163+
with:
164+
script: |
165+
const res = await github.rest.actions.listArtifactsForRepo({
166+
owner: context.repo.owner,
167+
repo: context.repo.repo,
168+
})
169+
170+
res.data.artifacts
171+
.filter(({ name }) => name === 'tarballs-{{ env.GITHUB_HEAD_REF }}')
172+
.forEach(({ id }) => {
173+
github.rest.actions.deleteArtifact({
174+
owner: context.repo.owner,
175+
repo: context.repo.repo,
176+
artifact_id: id,
177+
})
178+
})
179+
180+
- name: Upload tarball and its checksum artifacts
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: tarballs-{{ env.GITHUB_HEAD_REF }}
184+
path: |
185+
nut-*.tar*
186+
compression-level: 0
187+
overwrite: true

NEWS.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ several `FSD` notifications into one executed action. [PR #3097]
260260
types (man, html-single, html-chunked, pdf) that we may have enabled for the
261261
current build configuration and available tooling. [#1400]
262262

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+
263268
- Source directory `data/html` was renamed to `data/htmlcgi` in order to
264269
better reflect its contents and purpose, compared to documentation-oriented
265270
`html*` directories (and recipe variable names). This may impact some

0 commit comments

Comments
 (0)