-
Notifications
You must be signed in to change notification settings - Fork 5
203 lines (189 loc) · 6.68 KB
/
gen5.yml
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Build and Release AppBundles - NG
on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
script_pattern:
description: "Pattern to match scripts to build (leave empty to build all)"
required: false
default: ""
release:
description: "Create a release (true/false)"
required: false
default: "true"
jobs:
build:
name: Build AppBundles
runs-on: ubuntu-latest
permissions: write-all
container:
image: "docker.io/azathothas/appbundler-alpine:latest"
options: --privileged
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove non-compliant tools
run: |
apk del bash findutils gawk grep diffutils coreutils
- name: Set up GOBIN and install lib4bin
run: |
set -x
export GOBIN="$GITHUB_WORKSPACE/.local/bin"
mkdir -p "$GOBIN"
echo "GOBIN=$GOBIN" >> $GITHUB_ENV
echo "PATH=$GOBIN:$PATH" >> $GITHUB_ENV
git clone --depth 1 --branch dev https://github.com/xplshn/pelf
cp ./pelf/* "$GOBIN" || true
cd ./pelf/cmd/dynexec/lib4bin
go install .
cd -
cd ./pelf/cmd/misc/appstream_helper
go install .
- name: Set OUT_DIR environment variable
run: |
OUT_DIR="$GITHUB_WORKSPACE/APPBUNDLES"
META_OUT_DIR="$GITHUB_WORKSPACE/APPBUNDLES_META"
mkdir -p "$OUT_DIR" "$META_OUT_DIR"
echo "OUT_DIR=${OUT_DIR}" >> $GITHUB_ENV
echo "META_OUT_DIR=${META_OUT_DIR}" >> $GITHUB_ENV
- name: List available scripts
run: |
echo "Listing available recipes:"
tree "$GITHUB_WORKSPACE/recipes"
- name: Run selected build scripts
run: |
ls "$GITHUB_WORKSPACE/baseSystems"
set -x
export PATH="$GITHUB_WORKSPACE/baseSystems:$PATH"
echo "PATH=$PATH" >> $GITHUB_ENV
cd $OUT_DIR
SCRIPT_PATTERN="${{ github.event.inputs.script_pattern }}"
if [ -z "$SCRIPT_PATTERN" ]; then
echo "No script pattern provided, running all scripts."
PATTERN=".*"
else
PATTERN="$SCRIPT_PATTERN"
fi
for script in "$GITHUB_WORKSPACE/recipes/"*/*.*sh; do
if echo "$script" | grep -E "$PATTERN"; then
chmod +x "$script"
DEBUG=1 "$script"
fi
done
- name: Generate metadata
run: |
set -x
wget "https://huggingface.co/datasets/pkgforge/pkgcache/resolve/main/FLATPAK_APPSTREAM.xml"
appstream-helper --components-xml ./FLATPAK_APPSTREAM.xml --input-dir "$OUT_DIR" --output-dir "$META_OUT_DIR" --output-file "$META_OUT_DIR/metadata.json" --download-url-prefix "https://github.com/xplshn/AppBundleHUB/releases/download/" --metadata-prefix "https://github.com/xplshn/AppBundleHUB/releases/download/latest_metadata/"
- name: Upload app bundle artifacts
uses: actions/upload-artifact@v4
with:
name: app-bundles
path: ${{ env.OUT_DIR }}/*.AppBundle
- name: List generated metadata files
run: |
ls ${{ env.META_OUT_DIR }}/*
- name: Upload metadata artifacts
uses: actions/upload-artifact@v4
with:
name: metadata
path: ${{ env.META_OUT_DIR }}/*
release:
name: Release AppBundles
runs-on: ubuntu-latest
needs: build
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download app bundle artifacts
uses: actions/download-artifact@v4
with:
name: app-bundles
path: ${{ github.workspace }}
- name: Download metadata artifact
uses: actions/download-artifact@v4
with:
name: metadata
path: ${{ github.workspace }}
- name: Manage Tags
if: ${{ github.event.inputs.release == 'true' }}
run: |
git fetch --tags
TAGS=$(git tag | grep -v "^latest_metadata$" | sort -V)
TAG_COUNT=$(echo "$TAGS" | wc -l)
if [ "$TAG_COUNT" -gt 5 ]; then
TAGS_TO_DELETE=$(echo "$TAGS" | head -n -1)
for TAG in $TAGS_TO_DELETE; do
git tag -d "$TAG"
git push origin --delete "$TAG"
done
fi
- name: Create Git Tag
if: ${{ github.event.inputs.release == 'true' }}
run: |
TAG_NAME="v$(date +'%Y%m%d%H%M%S')"
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: Determine if pre-release
id: determine_prerelease
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "prerelease=true" >> $GITHUB_ENV
else
echo "prerelease=false" >> $GITHUB_ENV
fi
- name: Create Release
if: ${{ github.event.inputs.release == 'true' }}
uses: softprops/[email protected]
with:
name: "Weekly Release - ${{ env.TAG_NAME }}"
tag_name: "${{ env.TAG_NAME }}"
prerelease: ${{ env.prerelease }}
draft: false
generate_release_notes: false
make_latest: true
files: |
${{ github.workspace }}/*.AppBundle
${{ github.workspace }}/metadata.json
continue-on-error: true
publish_metadata:
name: Publish Metadata
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.release == 'true' }}
permissions: write-all
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download metadata artifact
uses: actions/download-artifact@v4
with:
name: metadata
path: ${{ github.workspace }}
- name: Update latest_metadata tag and create release
run: |
git fetch --tags
if git tag -l | grep -q "^latest_metadata$"; then
git tag -d latest_metadata
git push origin --delete latest_metadata || true
fi
git tag latest_metadata
git push origin latest_metadata
- name: Create Release for Metadata
uses: softprops/[email protected]
with:
name: "Latest Metadata"
tag_name: "latest_metadata"
files: |
${{ github.workspace }}/*.json
${{ github.workspace }}/*.png
${{ github.workspace }}/*.svg
${{ github.workspace }}/*.desktop
${{ github.workspace }}/*.xml
body: "Latest metadata files"
draft: false
prerelease: true
make_latest: false