-
Notifications
You must be signed in to change notification settings - Fork 6
126 lines (115 loc) · 4.24 KB
/
ci-build-metapackage.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: ci-build-metapackage
on:
workflow_dispatch: {}
pull_request:
branches: [main]
paths:
- 20*.*/staged/**/*
jobs:
conf:
runs-on: ubuntu-latest # this job is always run on linux
outputs:
epochs: ${{ steps.set-vars.outputs.epochs }}
distros: ${{ steps.set-vars.outputs.distros }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: tj-actions/changed-files@v19
id: changed
- name: set-vars
id: set-vars
run: |
# Parse the git changes to figure out which epoch triggered this workflow.
CHANGED="${{ steps.changed.outputs.all_changed_files }}"
EPOCHS=$(python .github/workflows/bin/determine.py --epoch "$CHANGED")
echo "::set-output name=epochs::$EPOCHS"
DISTROS=$(python .github/workflows/bin/determine.py --distro "$CHANGED")
echo "::set-output name=distros::$DISTROS"
integrate:
runs-on: ${{ matrix.platform }}
needs: [conf]
strategy:
matrix:
epoch: ${{ fromJson(needs.conf.outputs.epochs) }}
distro: ${{ fromJson(needs.conf.outputs.distros) }}
platform:
- ubuntu-latest
- macos-latest
env:
BUILD_DIR: ./build/
TEMPLATE_PATH: ${{ matrix.epoch }}/staged/${{ matrix.distro }}/
Q2_CHANNEL: https://packages.qiime2.org/qiime2/${{ matrix.epoch }}/tested/
steps:
- name: set host helper env vars
run: |
case "${{ matrix.platform }}" in
'ubuntu-latest') echo 'CONDA_PLATFORM=linux' >> $GITHUB_ENV ;;
'macos-latest') echo 'CONDA_PLATFORM=osx' >> $GITHUB_ENV ;;
esac
- uses: actions/checkout@v3
- uses: ./.github/actions/configure-conda
- name: template recipe
run: |
source "$CONDA/etc/profile.d/conda.sh"
conda activate base
pip install 'jinja2' pyyaml
python .github/workflows/bin/template.py $TEMPLATE_PATH
- name: debug recipe
run: cat $TEMPLATE_PATH/meta.yaml
- name: build recipe
run: |
source "$CONDA/etc/profile.d/conda.sh"
conda activate base
sudo conda mambabuild \
-c $Q2_CHANNEL \
-c conda-forge \
-c bioconda \
-c defaults \
--override-channels \
--output-folder $BUILD_DIR \
--no-anaconda-upload \
$TEMPLATE_PATH
- name: upload build artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.distro }}-${{ env.CONDA_PLATFORM }}
path: ${{ env.BUILD_DIR }}/*/**
- name: phone home
env:
PACKAGE_NAME: qiime2-${{ matrix.distro }}
LIBRARY_TOKEN: ${{ secrets.LIBRARY_TOKEN }}
run: |
source "$CONDA/etc/profile.d/conda.sh"
conda activate base
phone_home=$(yq ".meta.phone_home" $TEMPLATE_PATH/data.yaml)
if [ "$phone_home" = "false" ]
then
echo "skipping library upload due to disabled phone_home"
exit 0
fi
metapackage_version=$(sudo conda search -c $BUILD_DIR $PACKAGE_NAME --json | \
jq --arg PKG "$PACKAGE_NAME" -r '.[$PKG][0].version')
package_versions=$(python .github/workflows/bin/integration_versions.py $TEMPLATE_PATH)
resp=$(curl \
--silent \
--include \
--data-urlencode "token=$LIBRARY_TOKEN" \
--data-urlencode "version=$metapackage_version" \
--data-urlencode "package_versions=$package_versions" \
--data "run_id=$GITHUB_RUN_ID" \
--data "distro=${{ matrix.distro }}" \
--data "epoch=${{ matrix.epoch }}" \
--data "artifact_name=${{ matrix.distro }}-${{ env.CONDA_PLATFORM }}" \
--data "pr_number=${{ github.event.pull_request.number }}" \
--header "Content-Type: application/x-www-form-urlencoded" \
--request POST \
https://library.qiime2.org/api/v1/packages/stage/
)
code=$(echo $resp | grep HTTP | awk '{print $2}')
if [[ $code -ne 200 ]]
then
echo "whoops"
echo $resp
exit 1
fi