]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
ci: Add jobs to build and create release
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 30 Aug 2025 10:39:55 +0000 (12:39 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 1 Sep 2025 18:01:47 +0000 (20:01 +0200)
This includes new binary releases for Linux aarch64 and Windows aarch64.

Closes #1579. See also discussion #1310.

.github/workflows/build.yaml
ci/generate-release-notes [new file with mode: 0755]
ci/prepare-release [new file with mode: 0755]
misc/Makefile.posix-binary-release [new file with mode: 0644]

index 827275d5edd6fdf0d04ce831a56974d2055ee953..c151e8870ab3f357649df84826332b874e52f1e5 100644 (file)
@@ -2,6 +2,11 @@ name: Build
 on:
   push:
   pull_request:
+  workflow_dispatch:
+    inputs:
+      test_tag:
+        description: 'Optional tag name to simulate release'
+        required: false
 
 env:
   CTEST_OUTPUT_ON_FAILURE: ON
@@ -623,6 +628,85 @@ jobs:
           name: ${{ matrix.name }} - testdir.tar.xz
           path: testdir.tar.xz
 
+  build_release:
+    name: Build release
+    needs:
+      - build_darwin_binary
+      - build_linux_aarch64_binary
+      - build_linux_x86_64_binary
+      - build_windows_binary
+    runs-on: ubuntu-24.04
+    steps:
+      - name: Prepare environment
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y minisign
+
+      - name: Get source
+        uses: actions/checkout@v4
+
+      - name: Download binaries
+        uses: actions/download-artifact@v5
+        with:
+          pattern: "*-binary"
+
+      - name: Download docs
+        uses: actions/download-artifact@v5
+        with:
+          pattern: docs
+          path: docs
+
+      - name: Build release
+        run: ci/prepare-release
+
+      - name: Sign release archives
+        if: env.MINISIGN_KEY != ''
+        env:
+          MINISIGN_KEY: ${{ secrets.MINISIGN_KEY }}
+        run: |
+          mkdir -p ~/.minisign
+          echo "${MINISIGN_KEY}" | base64 -d > ~/.minisign/minisign.key
+          minisign -Sm release/*
+
+      - name: Upload release
+        uses: actions/upload-artifact@v4
+        if: ${{ github.ref_type == 'tag' || github.event.inputs.test_tag != '' }}
+        with:
+          name: release
+          path: release
+          retention-days: 3
+
+  create_release:
+    name: Create release
+    needs:
+      - build_release
+    permissions:
+      contents: write
+    if: ${{ github.ref_type == 'tag' || github.event.inputs.test_tag != '' }}
+    runs-on: ubuntu-24.04
+    steps:
+      - name: Get source
+        uses: actions/checkout@v4
+      - name: Download release
+        uses: actions/download-artifact@v5
+        with:
+          name: release
+          path: release
+      - name: Create release notes
+        run: |
+          TAG_NAME="${{ github.event.inputs.test_tag || github.ref_name }}"
+          ci/generate-release-notes "${TAG_NAME}" >release-notes.md
+      - name: Create GitHub Release
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          TAG_NAME="${{ github.event.inputs.test_tag || github.ref_name }}"
+          gh release create "${TAG_NAME}" \
+            --draft \
+            --notes-file release-notes.md \
+            --title "${TAG_NAME}" \
+            release/*
+
   check_format:
     timeout-minutes: 30
     name: Code formatting
diff --git a/ci/generate-release-notes b/ci/generate-release-notes
new file mode 100755 (executable)
index 0000000..cf65acd
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+set -euo pipefail
+
+version=$(echo "$1" | sed 's/^v//')
+u_version=$(echo "${version}" | sed 's/\./_/g')
+url_prefix="https://github.com/ccache/ccache/releases/download/v${version}"
+
+source_extensions=(tar.gz tar.xz)
+linux_archs=(aarch64 x86_64)
+windows_archs=(aarch64 i686 x86_64)
+
+retcode=0
+
+add() {
+    local descr=$1
+    local file=$2
+
+    for f in "${file}" "${file}.minisig"; do
+        if [[ ! -f "${f}" ]]; then
+            echo "Error: ${f} does not exist" >&2
+            retcode=1
+        fi
+    done
+cat <<EOF
+* [${descr}](${url_prefix}/${file}) ([signature](${url_prefix}/${file}.minisig))
+EOF
+}
+
+cd release
+
+for ext in "${source_extensions[@]}"; do
+    add "Generic source code release (${ext})" "ccache-${version}.${ext}"
+done
+add "Darwin (macOS) universal binary release" "ccache-${version}-darwin.tar.gz"
+for arch in "${linux_archs[@]}"; do
+    add "Linux ${arch} binary release" "ccache-${version}-linux-${arch}.tar.xz"
+done
+for arch in "${windows_archs[@]}"; do
+    add "Windows ${arch} binary release" "ccache-${version}-windows-${arch}.zip"
+done
+
+cat <<EOF
+* [Release notes](https://ccache.dev/releasenotes.html#_ccache_${u_version})
+* [Manual](https://ccache.dev/manual/${version}.html)
+EOF
+
+exit "${retcode}"
diff --git a/ci/prepare-release b/ci/prepare-release
new file mode 100755 (executable)
index 0000000..9734b06
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+set -euxo pipefail
+
+if [[ ${GITHUB_REF} = refs/tags/v* ]]; then
+    VERSION=${GITHUB_REF#refs/tags/v}
+else
+    VERSION=${GITHUB_REF_NAME}.$(git rev-parse --short=8 @)
+fi
+
+prepare_source_release() {
+    local name="ccache-${VERSION}"
+    local tarfile="release/${name}.tar"
+    git archive --prefix="${name}/" -o "${tarfile}" HEAD
+    gzip --keep -9 "${tarfile}"
+    xz --keep -9 "${tarfile}"
+    rm "${tarfile}"
+}
+
+prepare_posix_binary_release() {
+    local arch=$1
+    local compression=$2
+
+    local name="ccache-${VERSION}-${arch}"
+    mkdir "${name}"
+    cp "${arch}-binary/ccache" "${name}"
+    chmod +x "${name}/ccache"
+    cp misc/Makefile.posix-binary-release "${name}/Makefile"
+    cp docs/install/share/doc/ccache/* "${name}"
+    cp docs/install/share/man/man1/ccache.1 "${name}"
+    tar -caf "release/${name}.tar.${compression}" "${name}"
+}
+
+prepare_windows_binary_release() {
+    local arch=$1
+
+    local name="ccache-${VERSION}-${arch}"
+    mkdir "${name}"
+    cp "${arch}-binary/ccache.exe" "${name}"
+    cp docs/install/share/doc/ccache/* "${name}"
+    zip -r "release/${name}.zip" "${name}"
+}
+
+mkdir release
+
+prepare_source_release
+
+prepare_posix_binary_release darwin gz
+prepare_posix_binary_release linux-aarch64 xz
+prepare_posix_binary_release linux-x86_64 xz
+
+prepare_windows_binary_release windows-aarch64
+prepare_windows_binary_release windows-i686
+prepare_windows_binary_release windows-x86_64
+
+ls -l . release
diff --git a/misc/Makefile.posix-binary-release b/misc/Makefile.posix-binary-release
new file mode 100644 (file)
index 0000000..da8c8c8
--- /dev/null
@@ -0,0 +1,40 @@
+prefix = /usr/local
+exec_prefix = $(prefix)
+bindir = $(exec_prefix)/bin
+datarootdir = $(prefix)/share
+docdir = $(datarootdir)/doc/ccache
+mandir = $(datarootdir)/man
+man1dir = $(mandir)/man1
+sysconfdir = $(prefix)/etc
+
+default_sysconfdir = /usr/local/etc
+doc_files = \
+    LICENSE.adoc \
+    LICENSE.html \
+    MANUAL.adoc \
+    MANUAL.html \
+    NEWS.adoc \
+    NEWS.html \
+    GPL-3.0.txt \
+    LICENSE.adoc \
+    README.md
+
+PYTHON = python3
+
+all:
+       @echo "Available make targets:"
+       @echo
+       @echo "  install [prefix=...] [DESTDIR=...]"
+       @echo
+       @echo "Default prefix: $(prefix)"
+
+install:
+       mkdir -p "$(DESTDIR)$(bindir)"
+       $(PYTHON) -c 'import sys; sysconfdir = b"$(sysconfdir)"; default_sysconfdir = b"$(default_sysconfdir)"; sys.stdout.buffer.write(sys.stdin.buffer.read().replace(default_sysconfdir + b"\x00" * (4096 - len(default_sysconfdir)), sysconfdir + b"\x00" * (4096 - len(sysconfdir))))' <ccache >"$(DESTDIR)$(bindir)/ccache"
+       chmod +x "$(DESTDIR)$(bindir)/ccache"
+
+       mkdir -p "$(DESTDIR)$(docdir)"
+       cp $(doc_files) "$(DESTDIR)$(docdir)"
+
+       mkdir -p "$(DESTDIR)$(man1dir)"
+       cp ccache.1 "$(DESTDIR)$(man1dir)"