File: prepare-release

package info (click to toggle)
ccache 4.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,188 kB
  • sloc: cpp: 47,282; asm: 28,570; sh: 8,674; ansic: 5,357; python: 685; perl: 68; makefile: 23
file content (80 lines) | stat: -rwxr-xr-x 2,109 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash

set -euxo pipefail

if [[ ${GITHUB_REF} = refs/tags/v* ]]; then
    VERSION="${GITHUB_REF#refs/tags/v}"
else
    hash=$(git rev-parse --short=8 @)
    if [[ ${GITHUB_REF} =~ ^refs/pull/([^/]+)/merge$ ]]; then
        VERSION="${BASH_REMATCH[1]}.${hash}"
    else
        VERSION="${GITHUB_REF_NAME}.$(git rev-parse --short=8 @)"
    fi
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 GPL-3.0.txt README.md "${name}"
    cp docs/install/usr/local/share/doc/ccache/* "${name}"
    cp docs/install/usr/local/share/man/man1/ccache.1 "${name}"
    tar -caf "release/${name}.tar.${compression}" "${name}"
}

test_posix_binary_release() {
    local arch=$1
    local compression=$2

    local name="ccache-${VERSION}-${arch}"

    tmpdir=$(mktemp -d)
    tar -C "${tmpdir}" -xf "${PWD}/release/${name}.tar.${compression}"
    (
        cd "${tmpdir}/${name}"
        make install prefix=/foo/bar DESTDIR=destdir
        destdir/foo/bar/bin/ccache --version
    )
    rm -r "${tmpdir}"
}

prepare_windows_binary_release() {
    local arch=$1

    local name="ccache-${VERSION}-${arch}"
    mkdir "${name}"
    cp "${arch}-binary/ccache.exe" "${name}"
    cp "docs/install/usr/local/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

test_posix_binary_release linux-x86_64 xz

ls -l . release