-
Notifications
You must be signed in to change notification settings - Fork 3
/
publish.sh
executable file
·94 lines (75 loc) · 3.84 KB
/
publish.sh
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# shellcheck disable=SC2002 # My cats are not useless, thank you.
set -e
BASE_DIR="$(pwd)"
# Config
declare -i CLEAN_APT_REPO=${CLEAN_APT_REPO:-0}
declare -i PUSH_APT_REPO=${PUSH_APT_REPO:-0}
declare -i UPLOAD_LAUNCHPAD=${UPLOAD_LAUNCHPAD:-1}
GH_PAGES_BRANCH="${GH_PAGES_BRANCH:-repo-adoptium}"
GH_PAGES_REPO_URL="${GH_PAGES_REPO_URL:[email protected]:rpardini/adoptium-deb-installer.git}"
export PACKAGE_SIGNER_KEYID=${PACKAGE_SIGNER_KEYID:-63FF2EEC3156A973} # For reprepro
echo "::group::Testing signing..."
echo "Testing signing" | gpg --sign --armor
echo "::endgroup::"
if [[ ! -d repo ]]; then
echo "'repo' dir is not there, cloning..."
echo "Cloning gh-pages repo at ${PWD}/repo ..."
git clone --branch "${GH_PAGES_BRANCH}" --single-branch "${GH_PAGES_REPO_URL}" repo
fi
if [[ ${CLEAN_APT_REPO} -gt 0 ]]; then
echo "Cleaning repo contents..."
rm -rf repo/conf repo/db repo/dists repo/pool
fi
if [[ ${UPLOAD_LAUNCHPAD} -gt 0 ]]; then
echo "::group::Uploading Ubuntu (source) packages to Launchpad..."
cd packages/sourcepkg
# Let's not overwhelm launchpad with uploads for unchanged packages.
# We'll keep a list of the uploaded file names in the apt repo (otherwise unrelated)
declare -i NUMBER_PACKAGES_TO_UPLOAD
PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE="${BASE_DIR}/repo/launchpad.list"
CURRENTLY_GENERATED_LAUNCHPAD_PACKAGES_FILE="${BASE_DIR}/repo/currently_generated_launchpad.list"
TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE="${BASE_DIR}/repo/to_upload_launchpad.list"
# Write this-run filenames to the new file...
find . -type f -name \*.changes | sort -u >"${CURRENTLY_GENERATED_LAUNCHPAD_PACKAGES_FILE}"
# If the old file does not exist, just do them all.
if [[ ! -f "${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}" ]]; then
echo "No previous uploaded packages list, uploading all newly built packages."
cat "${CURRENTLY_GENERATED_LAUNCHPAD_PACKAGES_FILE}" | sort -u >"${TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE}"
else
# We have a list of previously-uploaded, compare with new one and do only new packages.
# 'comm' is nice, but it wants sorted inputs.
comm -13 "${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}" "${CURRENTLY_GENERATED_LAUNCHPAD_PACKAGES_FILE}" >"${TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE}"
fi
NUMBER_PACKAGES_TO_UPLOAD="$(cat "${TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE}" | wc -l)"
echo "::notice file=publish.sh::Will upload ${NUMBER_PACKAGES_TO_UPLOAD} to Launchpad."
if [[ ${NUMBER_PACKAGES_TO_UPLOAD} -gt 0 ]]; then
echo "- Actually Uploading ${NUMBER_PACKAGES_TO_UPLOAD} to Launchpad..."
cat "${TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE}" | xargs dput --unchecked ppa:rpardini/adoptium-installers
echo "- dput done, marking ${NUMBER_PACKAGES_TO_UPLOAD} packages as uploaded..."
# This will be pushed together with the apt repo below
cat "${TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE}" >>"${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}"
cat "${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}" | sort -u >"${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}.sorted"
mv "${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}.sorted" "${PREVIOUSLY_UPLOADED_LAUNCHPAD_PACKAGES_FILE}"
else
echo "- Zero packages to upload. Doing nothing."
fi
# Cleanup work files
rm -f "${CURRENTLY_GENERATED_LAUNCHPAD_PACKAGES_FILE}" "${TO_UPLOAD_LAUNCHPAD_PACKAGES_FILE}"
cd "${BASE_DIR}"
echo "::endgroup::"
fi
echo "::group::Creating repo for debian packages..."
./apt_repo.sh
echo "::endgroup::"
# go in there, add everything to git, commit and push it
if [[ ${PUSH_APT_REPO} -gt 0 ]]; then
echo "::group::Publish repo for debian packages via git/github pages..."
cd repo
git add .
git commit -m "Updating adoptium repo" || true # commit fails if there's nothing to commit
git push origin "${GH_PAGES_BRANCH}" || true # push fails if there's nothing to push
cd "${BASE_DIR}"
echo "::endgroup::"
fi
echo "Done publishing."