forked from chrisj951/MainPyUI
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (92 loc) · 3.74 KB
/
create-builds.yml
File metadata and controls
109 lines (92 loc) · 3.74 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
name: Create Builds
permissions:
contents: write
packages: write
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to build'
required: true
default: 'main'
jobs:
build-zips:
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.get_sha.outputs.short_sha }}
version_suffix: ${{ steps.set_version_suffix.outputs.version_suffix }}
steps:
- name: Install 7-Zip
run: sudo apt-get update && sudo apt-get install -y p7zip-full
- name: Check out specified branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Get short commit SHA
id: get_sha
run: echo "short_sha=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
# New step to define VERSION_SUFFIX once and for all
- name: Set VERSION_SUFFIX
id: set_version_suffix
run: |
DATE=$(date +%F)
VERSION_SUFFIX=${DATE}-${{ steps.get_sha.outputs.short_sha }}
echo "version_suffix=$VERSION_SUFFIX" >> "$GITHUB_OUTPUT"
- name: Create muxapp folder
run: |
mkdir PyUI
cp -R main-ui muOS/source/PyUI/
cp -R Themes muOS/source/PyUI/
- name: Create onionOS folder
run: |
cp -R main-ui onionOS/source/App/PyUI/
- name: Create muxapp archive
run: |
cd muOS/source && zip -r ../../muOS-pyui-v${{ steps.set_version_suffix.outputs.version_suffix }}.muxapp ./ \
-xr'!.git' \
-xr'!.github' \
-xr'!.gitignore' \
-xr'!.gitattributes' \
-xr'!.gitkeep'
- name: Create onionOS archives
run: |
cd onionOS/source && zip -r ../../onion-pyui-v${{ steps.set_version_suffix.outputs.version_suffix }}.zip ./ \
-xr'!.git' \
-xr'!.github' \
-xr'!.gitignore' \
-xr'!.gitattributes' \
-xr'!.gitkeep'
- name: Install GitHub CLI
run: sudo apt-get install -y gh
- name: Generate release notes
run: |
echo "Automated build from commit ${{ steps.get_sha.outputs.short_sha }}." > release_notes.txt
echo "" >> release_notes.txt
echo "Changes since last release:" >> release_notes.txt
LATEST_TAG=$(gh release list --json tagName --jq '.[1].tagName' 2>/dev/null || echo "")
if git rev-parse "$LATEST_TAG" >/dev/null 2>&1; then
git log "$LATEST_TAG"..HEAD --pretty=format:"- %s" >> release_notes.txt
else
git log --pretty=format:"- %s" >> release_notes.txt
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=pyui-${{ steps.set_version_suffix.outputs.version_suffix }}
MUOS_FILE=muOS-pyui-v${{ steps.set_version_suffix.outputs.version_suffix }}.muxapp
ONION_FILE=onion-pyui-v${{ steps.set_version_suffix.outputs.version_suffix }}.zip
gh release delete "$TAG_NAME" -y || true
gh release create "$TAG_NAME" "$MUOS_FILE" "$ONION_FILE"\
--title "Build $TAG_NAME" \
--notes-file release_notes.txt
- name: Prune old nightly builds (keep latest 10)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release list --limit 100 --json tagName,createdAt --jq \
'[.[] | select(.tagName | startswith("nightly-"))] | sort_by(.createdAt) | .[:-10] | .[].tagName' | \
while read tag; do
echo "Deleting old release: $tag"
gh release delete "$tag" -y
done