name: Build Packages # this covers the following use cases: # # 1. build snapshot packages for every push to any branch # 2. publish packages as "ReaR Snapshot" for every push to master # 3. build official packages for every push of a tag named release/* and publish as "ReaR Release" on: push env: # Set RELEASE to the release tag or to snapshot RELEASE: ${{ startsWith(github.ref, 'refs/tags/release/') && github.ref_name || 'no-release' }} concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} cancel-in-progress: true jobs: build: runs-on: ubuntu-latest permissions: contents: write id-token: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Extract release version # Set release version and filename from the release tag # e.g. 2.8.0 -> RELEASE_VERSION=2.8.0 RELEASE_FILENAME=release-2.8.0 if: startsWith(env.RELEASE, 'release') run: | tee -a $GITHUB_ENV <<< "RELEASE_VERSION=${RELEASE#release/}" tee -a $GITHUB_ENV <<< "RELEASE_FILENAME=${RELEASE//\//-}" - name: Setup build environment run: sudo apt-get -qq update && sudo apt-get -qq install asciidoctor - name: Build Snapshot dist archive if: env.RELEASE == 'no-release' run: make dist # check if the release version matches the source version before building official release dist archive - name: Check and build Release dist archive if: startsWith(env.RELEASE, 'release') run: | if [ -z "$RELEASE_VERSION" ] ; then echo "::error::Release version not set in RELEASE_VERSION" exit 1 fi SOURCE_VERSION=$(make version OFFICIAL=1) if [ "$SOURCE_VERSION" != "$RELEASE_VERSION" ] ; then # Find the line where VERSION is set VERSION_LINE=$(grep -n "^readonly VERSION=" usr/sbin/rear | cut -d: -f1) echo "### Version Check Failed" >> $GITHUB_STEP_SUMMARY echo "* Expected version: $RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY echo "* Current version: $SOURCE_VERSION" >> $GITHUB_STEP_SUMMARY echo "::error file=usr/sbin/rear,line=$VERSION_LINE::Version mismatch: Source version in rear script ($SOURCE_VERSION) does not match release tag version ($RELEASE_VERSION)" exit 1 fi make dist OFFICIAL=1 - name: Prepare Docker images run: tools/run-in-docker -- --patch --continue-and-record-successful images - name: List available Docker images if: always() run: | test -r images && cat images || : - name: Build snapshot packages via Docker if: env.RELEASE == 'no-release' # make package only for images that we patched successfully - continue despite errors run: tools/run-in-docker $(