-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (70 loc) · 2.81 KB
/
update-spack-package.yml
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
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