Skip to content

Commit 78c67a7

Browse files
authored
Merge pull request #70 from csiro-coasts/prerelease-workflow-fixes
Make prerelease checks run manually
2 parents 725ab24 + 02f1b49 commit 78c67a7

File tree

3 files changed

+79
-4
lines changed

3 files changed

+79
-4
lines changed

.github/workflows/release-branch.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Prerelease checks
22
on:
3-
pull_request:
4-
branches:
5-
- "release-*"
6-
73
workflow_dispatch:
84

95
env:

docs/internal/releasing.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Push this branch and make a pull request on Github.
2525
2626
$ ./scripts/release.py pre 1.2.0
2727
28+
Manually run the 'Prerelease checks' workflow for this branch in the 'Actions' tab on Github.
29+
This will check that a conda package can be built from the Python package tarball.
30+
2831
Build and publish packages
2932
==========================
3033

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
# Build a conda package from the locally build python package.
4+
# This is used in CI to test that the conda package can be built successfully.
5+
#
6+
# Prerequisites:
7+
# - Python package builds at ./dist/emsarray-X.Y.Z.tar.gz
8+
# - conda-forge/emsarray-feedstock cloned at ./emsarray-feedstock
9+
10+
set -euo pipefail
11+
12+
HERE="$( cd -- "$( dirname -- "$( realpath -- "$0" )" )" && pwd )"
13+
PROJECT="$( dirname -- "$HERE" )"
14+
15+
dist_path="$PROJECT/dist"
16+
feedstock_path="$PROJECT/emsarray-feedstock"
17+
18+
files_to_clean=()
19+
20+
function main() {
21+
trap cleanup EXIT
22+
23+
local package_path="$( get_package_path )"
24+
local package_name="$( basename -- "$package_path")"
25+
local package_version=$( get_package_version "$package_name" )
26+
27+
tmp_dir="$( mktemp -d --tmpdir "emsarray-conda-build.XXXXXXX" )"
28+
files_to_clean+=( "$tmp_dir" )
29+
cd "$tmp_dir"
30+
31+
cp -R "$feedstock_path/recipe" "$tmp_dir/recipe"
32+
recipe_path="$tmp_dir/recipe/meta.yaml"
33+
update_recipe "$recipe_path" "$package_path" "$package_version"
34+
35+
cat "$recipe_path"
36+
37+
conda build \
38+
--override-channels \
39+
--channel conda-forge \
40+
"$tmp_dir"
41+
}
42+
43+
function get_package_path() {
44+
find "$dist_path" -name 'emsarray-*.tar.gz' -print -quit
45+
}
46+
47+
function get_package_version() {
48+
local package_name="$1"
49+
local package_version=$(
50+
echo "$package_name" \
51+
| sed 's/^emsarray-\(.*\)\.tar\.gz/\1/'
52+
)
53+
if [[ "$package_name" == "$package_version" ]] ; then
54+
echo "Could not extract version from package name!"
55+
exit 1
56+
fi
57+
echo "$package_version"
58+
}
59+
60+
function update_recipe() {
61+
local recipe_path="$1"
62+
local package_path="$2"
63+
local package_version="$3"
64+
65+
sed \
66+
-e 's!set version = ".*"!set version = "'"$package_version"'"!' \
67+
-e 's!url: https://pypi.io/.*!url: "file://'"$package_path"'"!' \
68+
-e '/sha256:/d' \
69+
-i "$recipe_path"
70+
}
71+
72+
function cleanup() {
73+
rm -rf "${files_to_clean[@]}"
74+
}
75+
76+
main

0 commit comments

Comments
 (0)