-
Notifications
You must be signed in to change notification settings - Fork 48
172 lines (165 loc) Β· 6.27 KB
/
build_conda_recipes.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: deploy
on:
push:
branches:
- main
- vep113
env:
atoken: ${{ secrets.ANACONDA_UPLOAD_TOKEN }}
recipe_path: conda/recipe
env_yml_path: conda/env/yml
env_lock_path: conda/env/lock
VERSION: '2.1.2.9001' # versioned by bump2version
jobs:
build_pcgrr_conda_pkg:
# When merging to one of the branches above and the commit message matches
if: "startsWith(github.event.head_commit.message, 'Bump version:')"
name: Build pcgrr conda pkg
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Micromamba setup
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ env.env_yml_path }}/condabuild.yml
- name: π Conda pkg build and upload
run: |
conda mambabuild ${recipe_path}/pcgrr -c conda-forge -c bioconda --token ${atoken}
build_pcgr_conda_pkg:
# When merging to one of the branches above and the commit message matches
if: "startsWith(github.event.head_commit.message, 'Bump version:')"
name: Build pcgr conda pkg
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Micromamba setup
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ env.env_yml_path }}/condabuild.yml
- name: π Conda pkg build and upload
run: |
conda mambabuild ${recipe_path}/pcgr -c conda-forge -c bioconda --token ${atoken} --quiet
# spin up fresh instance since conda-lock takes ages when run on previous one
conda_lock:
name: Conda lock
runs-on: ubuntu-latest
needs: [build_pcgr_conda_pkg, build_pcgrr_conda_pkg]
defaults:
run:
shell: bash -l {0}
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Micromamba setup
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ env.env_yml_path }}/condabuild.yml
- name: π Conda lock
run: |
# 1. generate a combined lock file
# 2. render platform-specific locks
conda-lock lock --file ${env_yml_path}/pcgr.yml -p osx-64 -p linux-64
conda-lock render --kind explicit -p osx-64 -p linux-64 conda-lock.yml --filename-template 'pcgr-{platform}.lock' && rm conda-lock.yml
conda-lock lock --file ${env_yml_path}/pcgrr.yml -p osx-64 -p linux-64
conda-lock render --kind explicit -p osx-64 -p linux-64 conda-lock.yml --filename-template 'pcgrr-{platform}.lock' && rm conda-lock.yml
mv pcgrr-*.lock ${env_lock_path}
mv pcgr-*.lock ${env_lock_path}
- name: Commit changes
run: |
git status
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
MSG="[bot] Updating conda-lock files (v${VERSION})"
git add .
git commit -m "${MSG}"
git push
- name: π Website publish
if: github.ref_name == 'main'
run: |
micromamba env create -n pkgdownenv -f ${env_yml_path}/pkgdown.yml
micromamba activate pkgdownenv
cp pcgrr/DESCRIPTION . # hack for pkgdown to work
printf "pcgrr version:\n"
Rscript -e "packageVersion('pcgrr')"
Rscript -e "pkgdown::deploy_to_branch(pkg = 'pcgrr', commit_message = 'Built PCGR website: https://sigven.github.io/pcgr/', branch = 'gh-pages', new_process = FALSE)"
docker_deploy:
name: Build and deploy Docker
runs-on: ubuntu-latest
needs: conda_lock
defaults:
run:
shell: bash -l {0}
steps:
- name: Code checkout
uses: actions/checkout@v4
- id: pull_lock_commit
name: π₯ Pull lock commit
run: |
git pull --no-rebase # for pulling in the changed locks
git --no-pager log --decorate=short --pretty=oneline -n3
LATEST_COMMIT_HASH="$(git --no-pager log -1 --format='%H')"
echo "latest_commit_hash=${LATEST_COMMIT_HASH}" >> $GITHUB_OUTPUT
- name: π Tag creation
uses: actions/github-script@v7
env:
LATEST_COMMIT_HASH: ${{ steps.pull_lock_commit.outputs.latest_commit_hash }}
with:
script: |
const the_tag_name = 'refs/tags/v' + process.env.VERSION
const the_sha = process.env.LATEST_COMMIT_HASH
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: the_tag_name,
sha: the_sha
})
- name: π Free Disk Space
uses: jlumbroso/free-disk-space@main
# work with tag from above
- name: Code checkout
uses: actions/checkout@v4
with:
ref: v${{ env.VERSION }}
- name: π° QEMU setup
uses: docker/setup-qemu-action@v3
- name: π― Buildx setup
uses: docker/setup-buildx-action@v3
- name: DockerHub login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# use the outputs=docker with dest to directly save to tar for apptainer
- name: π³ Docker img build, tar and push to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
tags: |
sigven/pcgr:${{ env.VERSION }}
outputs: type=docker,dest=pcgr_${{ env.VERSION }}.tar
# Apptainer
- name: Apptainer setup
uses: eWaterCycle/setup-apptainer@v2
- name: πΉοΈ Apptainer build
run: |
ls -lSha
df -h
echo "Building Apptainer SIF"
echo "---------------------------------"
apptainer build pcgr_singularity_${VERSION}.sif docker-archive://pcgr_${VERSION}.tar
echo "---------------------------------"
ls -lSha
- name: Upload SIF to GHCR
run: |
echo ${{ secrets.GITHUB_TOKEN }} | apptainer registry login -u ${{ github.actor }} --password-stdin oras://ghcr.io
apptainer push pcgr_singularity_${VERSION}.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${VERSION}.singularity