From 138d3cbbce0f34875e57ad45fea74cb2b27614e9 Mon Sep 17 00:00:00 2001 From: "A. Karl Kornel" Date: Wed, 17 Apr 2024 16:31:24 -0700 Subject: [PATCH] Start a workflow to run on pushes This workflow attempts to build a Debian changelog from the history since the last tag (one 'version' per commit), and then does a `debuild` without signing. The (unsigned) results are uploaded as an artifact of the workflow run. On the changelog: The Debian package version number is taken from the changelog. We need to make at least one changelog entry, as the package version will be taken from that. We use version 99, plus the commit date and tag. That ensures version numbers continue to increase as we move forward in time, while also containing the commit ID in the version number. If we ever do a proper release of a version above 99, this will break! NOTE: `--force-bad-version` is included to allow `debchange` to continue, even if time does not appear to be moving foward. This can happen sometimes, when rebases are performed: You'll have a series of commits that have the same commit timestamp (the timestamp of the rebase). --- .github/workflows/package.yml | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/package.yml diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..1d040e7 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,63 @@ +name: 'Build Packages' + +on: push + +permissions: + contents: read + +jobs: + Package: + name: Create Package for Branch + runs-on: ubuntu-latest + steps: + - id: sysprep + name: Prep system for dev work + run: | + sudo apt-get update + sudo apt-get install -y build-essential debhelper devscripts python3 + + - id: checkout + name: Checkout Repo + uses: actions/checkout@v4 + with: + path: "source" + fetch-depth: 0 + continue-on-error: false + + - id: get_tag + name: Get most recent tag + run: | + cd source; + echo "tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" + continue-on-error: false + + - id: make_changelogs + name: Make changelog entries + env: + start: ${{ steps.get_tag.outputs.tag }} + run: | + cd source; + echo "Listing commits starting from ${start}"; + for commit in $(git log --reverse --format="%h" ${start}..); do + echo "Adding changelog entry for commit ${commit}: $(git log -1 --pretty=%s ${commit})"; + EMAIL=$(git log -1 --pretty=%ae ${commit}) \ + NAME=$(git log -1 --pretty=%an ${commit}) \ + dch --force-bad-version --newversion \ + "$(git log -1 --date=format:%Y%m%d%H%M%S --pretty=99~git%cd.%h ${commit})" \ + "$(git log -1 --pretty=%s ${commit})"; + done + continue-on-error: false + + - name: Build package (without signing) + run: | + cd source && \ + debuild -us -uc + continue-on-error: false + + - name: Upload Build Result as artifact + uses: actions/upload-artifact@v4.3.1 + with: + name: package + path: docker-image-cleanup* + if-no-files-found: error + continue-on-error: false