-
Notifications
You must be signed in to change notification settings - Fork 27
79 lines (72 loc) · 3.19 KB
/
spack-deployment-workflow.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
# Release pipeline:
#
# This pipeline performs the deployment of a new gchp spack
# package upon the release of a new version
#
# This pipeline is triggered by tagged versions excluding
# pre-releases.
#
# Notes:
# - This workflow requires a personal access token for pushing to the
# pr-source-repo. The PAT needs repo + read:org permissions. The PAT
# needs to be added to the GCHP repo as an action secret
# called GH_PUSH_PAT.
name: spack_deployment
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
make_spack_pr:
runs-on: ubuntu-latest
container: continuumio/miniconda3
steps:
- uses: actions/checkout@v2
- name: Get release tag
id: vars
run: |
GEOSCHEM_VERSION=${GITHUB_REF#refs/*/}
echo ::set-output name=release_tag::${GEOSCHEM_VERSION}
cd ${GITHUB_WORKSPACE}
git checkout $GEOSCHEM_VERSION
echo ::set-output name=release_sha::$(git rev-list -n 1 $GEOSCHEM_VERSION)
- name: Install dependencies
run: |
set -x
conda install -y -c conda-forge gh flake8 mypy isort curl
- name: Login with PAT
run: |
git config --global user.email "[email protected]"
git config --global user.name "laestrada"
git config --global credential.helper store
echo "https://laestrada:${{ secrets.GH_PUSH_PAT }}@github.com/geoschem/spack.git" > ~/.git-credentials
echo ${{ secrets.GH_PUSH_PAT }} | gh auth login --with-token
- name: Update spack package and submit PR
env:
GEOSCHEM_VERSION: ${{ steps.vars.outputs.release_tag }}
VERSION_STRING: version('${{ steps.vars.outputs.release_tag }}', commit='${{ steps.vars.outputs.release_sha }}', submodules=True)
TAR_URL_PREFIX: https://github.com/geoschem/GCHP/archive
run: |
set -x
TEMP_DIR=$(mktemp -d)
SPACK_DIR=$TEMP_DIR/spack
# Checkout spack/spack:develop
git clone -c feature.manyFiles=true https://github.com/spack/spack.git $SPACK_DIR
cd $SPACK_DIR
git checkout develop
. share/spack/setup-env.sh
# Add geoschem/spack as a remote (PR will come from this repo)
git remote add pr-source-repo https://github.com/geoschem/spack.git
# Create a new branch for current release
git checkout -b gchp-${GEOSCHEM_VERSION}
# replace the tarball link to new version
sed -i "s|https://github.com/geoschem/GCHP/archive/.*.gz|${TAR_URL_PREFIX}/${GEOSCHEM_VERSION}.tar.gz|" var/spack/repos/builtin/packages/gchp/package.py
# add new line to version history
sed -i "0,/\( *\)version(.*/s##\1${VERSION_STRING}\n&#" var/spack/repos/builtin/packages/gchp/package.py
# test that style is up to snuff
spack style
# commit and create pull request from forked repo
git add .
git commit -m "gchp: added version ${GEOSCHEM_VERSION}"
git push pr-source-repo gchp-${GEOSCHEM_VERSION}
gh pr create --title "gchp: added version ${GEOSCHEM_VERSION}" --base develop --body "Pull request for ${GEOSCHEM_VERSION}" --repo spack/spack