Skip to content

Spack Package Update #15

Spack Package Update

Spack Package Update #15

name: Spack Package Update
on:
workflow_dispatch:
inputs:
dryrun:
description: 'Do a dry run of the package update process, without making the commit/PR'
required: false
type: boolean
workflow_call:
inputs:
dryrun:
required: true
type: boolean
jobs:
update-spack-package:
name: Update Spack Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout GMLC-TDC/spack
uses: actions/checkout@v4
with:
repository: 'GMLC-TDC/spack'
token: ${{ secrets.HELICS_PACKAGING_TOKEN }}
path: 'spack'
- name: Sync Spack fork with upstream
working-directory: 'spack'
env:
GH_TOKEN: ${{ secrets.HELICS_PACKAGING_TOKEN }}
run: gh api repos/{owner}/{repo}/merge-upstream --field branch='{branch}'
- name: Set git config for commits
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Update HELICS Spack package
env:
GH_TOKEN: ${{ secrets.HELICS_PACKAGING_TOKEN }}
run: |
# Get HELICS version update info
HELICS_VERSION="$(cat HELICS_VERSION)"
# Get the spack checksum and update line for the new HELICS version
echo "::group::git pull"
cd "spack" && git pull
echo "::endgroup::"
spack_checksum_output=$(bin/spack checksum helics "$HELICS_VERSION")
spack_new_version_line=$(echo ${spack_checksum_output} | sed 's/^.*version(/version(/')
echo "::group::spack checksum output"
echo "$spack_checksum_output"
echo "::endgroup::"
echo "::group::spack new version line"
echo "$spack_new_version_line"
echo "::endgroup::"
# Add the new version to the spack package file
# Inserted below alias for main branch; 4 spaces ('\ ') to get matching indentation
sed -i "/^ version(\"master\", branch=\"main\", submodules=True)/a \ \ \ \ $spack_new_version_line" var/spack/repos/builtin/packages/helics/package.py
# Commit the change and create a PR
git checkout -b "helics-${HELICS_VERSION}"
git add var/spack/repos/builtin/packages/helics/
echo "::group::git diff --staged"
git diff --staged
echo "::endgroup::"
git commit -m "helics: Add version ${HELICS_VERSION}"
echo "::group::git show"
git show
echo "::endgroup::"
if [ "${{ inputs.dryrun }}" = "false" ]; then
echo "Pushing changes and opening a PR"
git push --set-upstream origin "helics-${HELICS_VERSION}"
gh pr create --repo spack/spack --title "helics: Add version ${HELICS_VERSION}" --body "Adds HELICS ${HELICS_VERSION} to the HELICS package versions"
fi