forked from Sigmapitech/glados
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (66 loc) · 2.49 KB
/
Copy pathrelease.yml
File metadata and controls
84 lines (66 loc) · 2.49 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
name: Create Release
on:
workflow_run:
workflows: ["Bump Cabal Versions"]
types:
- completed
workflow_dispatch:
jobs:
release:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
# Checkout the base branch (where the version bump commit is)
ref: ${{ github.event.workflow_run.pull_requests[0].base.ref }}
fetch-depth: 2
- name: Setup Haskell
uses: haskell-actions/setup@v2
with:
ghc-version: '9.8.4'
cabal-version: 'latest'
- name: Detect Changes, Build, and Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cabal update
changed_files=$(git diff-tree --no-commit-id --name-only -r HEAD)
echo "Files changed in last commit:"
echo "$changed_files"
for file in $changed_files; do
if [[ "$file" == *".cabal" ]]; then
version=$(grep -i "^version:" "$file" | awk '{print $2}')
pkg_name=$(basename "$file" .cabal)
tag="${pkg_name}-v${version}"
echo "----------------------------------------"
echo "Processing package: $pkg_name"
echo "Version: $version"
echo "Tag: $tag"
if gh release view "$tag" > /dev/null 2>&1; then
echo "Release $tag already exists."
else
echo "Creating release $tag..."
gh release create "$tag" \
--title "$pkg_name v$version" \
--generate-notes
fi
# Looks for lines starting with 'executable <name>'
executables=$(grep "^executable" "$file" | awk '{print $2}')
if [ -z "$executables" ]; then
echo "No executables found in $file. Skipping build."
continue
fi
for exe_name in $executables; do
echo "Building executable: $exe_name..."
cabal build "exe:$exe_name" --enable-executable-static
bin_path=$(cabal list-bin "exe:$exe_name")
echo "Found binary at: $bin_path"
echo "Uploading artifact..."
gh release upload "$tag" "$bin_path" --clobber
done
fi
done