Repository navigation
122 lines (103 loc) · 4.53 KB
/
Copy pathrelease.yml
File metadata and controls
122 lines (103 loc) · 4.53 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Release
on:
push:
tags:
- '*'
branches:
- master
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
release_version: ${{ github.ref_name }}
current_tag: ${{ github.ref_name }}
ref_type: ${{ github.ref_type }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up build environment
run: |
sudo apt update
sudo apt install -y gh jq fakeroot dpkg tar gzip xz-utils
# Prepare control file
if [ "${ref_type}" != "tag" ]; then
current_tag="${{ github.sha }}"
release_version="$(awk -F'"' '/^PV *=/ {print $2}' src/__init__.py)-pre"
echo "release_version=${release_version}" >> $GITHUB_ENV
fi
sed -i "s/^Version: .*/Version: ${release_version}/" CONTROL/control
sed -i "s/^\(PV *= *\).*/\1\"${release_version}\"/" src/__init__.py
# Script multiboot-selector.sh must be executable
chmod +x src/usr/bin/multiboot-selector.sh
# Generate release notes body using GitHub API
gh api repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="$release_version" > changelog.json
# Add download counter badge to release_body.md
printf "\n\n" > badge.txt
# Add changelog with commit messages to release_body.md
previous_tag=$(git describe --tags --abbrev=0 "$current_tag^")
printf "## Commits since $previous_tag\n" > commits.txt
git log --pretty=format:"- %s (%h)" $previous_tag..$current_tag >> commits.txt
# Add the 'body' field from JSON to release_body.md
{ printf "\n\n"; jq -r '.body' changelog.json; } > changlog.txt
cat badge.txt commits.txt changlog.txt > release_body.md
# Build .deb package
- name: Build .deb package
run: |
mkdir -p deb_pkg/DEBIAN
mkdir -p deb_pkg/usr/bin
mkdir -p deb_pkg/usr/lib/enigma2/python/Plugins/Extensions/MultiBootSelector
# Add files to publish
cp CONTROL/control deb_pkg/DEBIAN/
cp src/usr/bin/multiboot-selector.sh deb_pkg/usr/bin/
cp src/*.py src/*.png deb_pkg/usr/lib/enigma2/python/Plugins/Extensions/MultiBootSelector/
# Create deb package
fakeroot dpkg-deb -Z xz --build deb_pkg enigma2-plugin-extensions-multibootselector_${release_version}-r0_all.deb
# Build .ipk package
- name: Build .ipk package
run: |
mkdir -p ipk_pkg/control
mkdir -p ipk_pkg/usr/bin
mkdir -p ipk_pkg/usr/lib/enigma2/python/Plugins/Extensions/MultiBootSelector
# Add files to publish
cp CONTROL/control ipk_pkg/control/
cp src/usr/bin/multiboot-selector.sh ipk_pkg/usr/bin/
cp src/*.py src/*.png ipk_pkg/usr/lib/enigma2/python/Plugins/Extensions/MultiBootSelector/
# Create ipk package
cd ipk_pkg
tar -czvf control.tar.gz -C ./control .
tar -czvf data.tar.gz ./usr
echo "2.0" > debian-binary
ar r ../enigma2-plugin-extensions-multibootselector_${release_version}-r0_all.ipk ./debian-binary ./control.tar.gz ./data.tar.gz
cd ..
# =============================
# ✅ Create GitHub Release with auto-generated release notes
# =============================
- name: Create GitHub Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: |
enigma2-plugin-extensions-multibootselector_*_all.deb
enigma2-plugin-extensions-multibootselector_*_all.ipk
body_path: release_body.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# =============================
# ✅ Create GitHub artifacts for testing
# =============================
- name: Upload build artifacts
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: enigma2-plugin-extensions-multibootselector_${{ env.release_version }}
retention-days: 1
compression-level: 9
path: |
enigma2-plugin-extensions-multibootselector_*_all.deb
enigma2-plugin-extensions-multibootselector_*_all.ipk
commits.txt