-
Notifications
You must be signed in to change notification settings - Fork 102
100 lines (91 loc) · 4.12 KB
/
Copy pathrelease-draft.yml
File metadata and controls
100 lines (91 loc) · 4.12 KB
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
name: Create Draft Release
on:
push:
tags:
- '*'
permissions:
contents: write # create the GitHub Release
actions: read # read other workflow runs and download their artifacts
jobs:
draft-release:
name: Create draft release with binaries
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
steps:
- name: Wait for builds and download artifacts
run: |
set -uo pipefail
sha='${{ github.sha }}'
# The Windows/Linux build (ResInsightWithCache.yml) and the macOS
# build (ResInsightMac.yml) are triggered by this same tag push.
# Poll until each run for this commit has completed, echoing its
# run id on success. Note: a build may conclude as 'failure' yet
# still have usable artifacts (e.g. the macOS unit tests, uploaded
# with if: always(); or the pypi-publish job failing on a fork), so
# we wait on completion regardless of conclusion.
wait_run() {
wf="$1"
echo "Waiting for $wf @ $sha" >&2
for i in $(seq 1 240); do # up to ~2h (240 * 30s)
row=$(gh run list --workflow "$wf" \
--json headSha,status,databaseId --limit 50 \
| jq -r --arg sha "$sha" \
'map(select(.headSha==$sha)) | .[0]
| "\(.status // "none") \(.databaseId // "none")"')
st=${row%% *}; id=${row##* }
echo " $wf [$i]: status=$st id=$id" >&2
if [ "$st" = "completed" ]; then echo "$id"; return 0; fi
sleep 30
done
echo "Timed out waiting for $wf" >&2
return 1
}
cache_id=$(wait_run ResInsightWithCache.yml)
mac_id=$(wait_run ResInsightMac.yml)
rhel8_id=$(wait_run rhel8-package.yml)
mkdir -p artifacts
# Windows, Ubuntu-gcc and Ubuntu-clang-19 (excludes python-distribution).
gh run download "$cache_id" --pattern 'ResInsight-*' --dir artifacts
# Use --pattern (not --name) so each artifact is placed in its own
# ResInsight-macOS-*/ subdirectory, matching the cache download above.
# With --name the contents are extracted flat into artifacts/, which
# the 'for d in ResInsight-*/' packaging loop would then skip.
# The glob matches both macOS architectures (arm64 and x64), each
# uploaded as a separate artifact by ResInsightMac.yml (issue #1009).
gh run download "$mac_id" --pattern 'ResInsight-macOS-*' --dir artifacts
ls -R artifacts
# The RHEL8 artifact is already a CPack *.tar.gz, so keep it out of
# the 'artifacts/' zip loop below and attach it to the release as-is.
mkdir -p rhel8-package
gh run download "$rhel8_id" --pattern 'ResInsight-RHEL8' --dir rhel8-package
ls -R rhel8-package
- name: Package each platform into a zip
run: |
mkdir -p release-assets
cd artifacts
for d in ResInsight-*/; do
name="${d%/}"
# Spaces in artifact names (e.g. "ResInsight-Ubuntu 24.04 gcc")
# make awkward asset filenames, so collapse them to underscores.
safe="${name// /_}"
zip -r "../release-assets/${safe}-${{ github.ref_name }}.zip" "$name"
done
cd ..
# The RHEL8 CPack package is already compressed; attach it directly.
find rhel8-package -name '*.tar.gz' -exec cp {} release-assets/ \;
ls -l release-assets
- name: Create or update draft release
run: |
tag='${{ github.ref_name }}'
if gh release view "$tag" >/dev/null 2>&1; then
# Re-run: refresh the assets on the existing (draft) release.
gh release upload "$tag" release-assets/* --clobber
else
gh release create "$tag" \
--draft \
--title "ResInsight $tag" \
--notes "Automated draft release. Binaries are attached below." \
release-assets/*
fi