File indexing completed on 2026-10-20 08:43:05
0001
0002
0003
0004
0005
0006
0007 set -euo pipefail
0008
0009 BASE_BRANCH="${BASE_BRANCH:-master}"
0010 BRANCH="${BRANCH:-automation/update-eic-spack}"
0011 UPSTREAM_BRANCH="${UPSTREAM_BRANCH:-develop}"
0012 PIN_FILE="eic-spack.sh"
0013 MAX_LISTED=100
0014
0015
0016 source "${PIN_FILE}"
0017 OLD="${EICSPACK_VERSION}"
0018 REPO="${EICSPACK_ORGREPO}"
0019 NEW=$(gh api "repos/${REPO}/commits/${UPSTREAM_BRANCH}" --jq .sha)
0020 echo "eic-spack pin: ${OLD} -> ${NEW}"
0021
0022 existing_pr() {
0023 gh pr list --head "${BRANCH}" --base "${BASE_BRANCH}" --state open \
0024 --json number --jq '.[0].number // empty'
0025 }
0026
0027 if [ "${OLD}" = "${NEW}" ]; then
0028 echo "Already up to date."
0029 pr=$(existing_pr)
0030 if [ -n "${pr}" ]; then
0031 gh pr close "${pr}" --delete-branch \
0032 --comment "eic-spack pin on \`${BASE_BRANCH}\` is already at the head of \`${UPSTREAM_BRANCH}\`; closing."
0033 fi
0034 exit 0
0035 fi
0036
0037
0038 compare=$(gh api "repos/${REPO}/compare/${OLD}...${NEW}")
0039 total=$(jq .total_commits <<<"${compare}")
0040
0041 changelog=$(jq -r --arg repo "${REPO}" --argjson max "${MAX_LISTED}" '
0042 .commits | reverse | .[:$max][] |
0043 "- [`\(.sha[0:7])`](\(.html_url)) " +
0044 ((.commit.message | split("\n")[0]) | gsub("#(?<n>[0-9]+)"; "\($repo)#\(.n)")) +
0045 " (\(.author.login // .commit.author.name))"
0046 ' <<<"${compare}")
0047 if [ "${total}" -gt "${MAX_LISTED}" ]; then
0048 changelog+=$'\n'"- … and $((total - MAX_LISTED)) more, see the full comparison below."
0049 fi
0050
0051 body=$(cat <<BODY
0052 Bumps [${REPO}](https://github.com/${REPO}) from \`${OLD:0:7}\` to \`${NEW:0:7}\` (head of \`${UPSTREAM_BRANCH}\`).
0053
0054 <details>
0055 <summary>Commits (${total})</summary>
0056
0057 ${changelog}
0058
0059 </details>
0060
0061 Full comparison: https://github.com/${REPO}/compare/${OLD}...${NEW}
0062
0063 ---
0064
0065 This pull request is maintained automatically by \`.github/workflows/update-eic-spack.yml\`.
0066 It is rebuilt from \`${BASE_BRANCH}\` every night, so manual pushes to its branch will be overwritten.
0067 BODY
0068 )
0069 title="build(deps): bump eic-spack to ${NEW:0:7}"
0070
0071
0072 git config user.name "github-actions[bot]"
0073 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
0074 git checkout -B "${BRANCH}"
0075 sed -i "s/^EICSPACK_VERSION=.*/EICSPACK_VERSION=\"${NEW}\"/" "${PIN_FILE}"
0076 git add "${PIN_FILE}"
0077 git commit -m "${title}" -m "Bumps ${REPO} from ${OLD} to ${NEW}."
0078
0079
0080
0081 git fetch origin "${BRANCH}" 2>/dev/null || true
0082 if git rev-parse --verify -q "origin/${BRANCH}" >/dev/null \
0083 && git diff --quiet HEAD "origin/${BRANCH}" \
0084 && [ "$(git rev-parse HEAD~)" = "$(git rev-parse "origin/${BRANCH}~")" ]; then
0085 echo "Branch ${BRANCH} already contains this update."
0086 else
0087 git push --force origin "${BRANCH}"
0088 fi
0089
0090
0091 pr=$(existing_pr)
0092 if [ -n "${pr}" ]; then
0093 gh pr edit "${pr}" --title "${title}" --body "${body}"
0094 echo "Updated PR #${pr}"
0095 else
0096 gh pr create --base "${BASE_BRANCH}" --head "${BRANCH}" \
0097 --title "${title}" --body "${body}"
0098 fi