|
| 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 |
0 commit comments