Skip to content

Commit 691af7a

Browse files
committed
Add pack-debian to main
1 parent d1a8720 commit 691af7a

File tree

1 file changed

+258
-0
lines changed

1 file changed

+258
-0
lines changed

.github/workflows/pack-debian.yml

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
name: Build, release, upload to GH & server
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
matrix:
8+
required: true
9+
type: string
10+
maintainer:
11+
required: true
12+
type: string
13+
package:
14+
required: true
15+
type: string
16+
licence:
17+
required: false
18+
type: string
19+
homepage:
20+
required: false
21+
type: string
22+
depends:
23+
required: false
24+
type: string
25+
section:
26+
required: false
27+
type: string
28+
priority:
29+
required: false
30+
type: string
31+
description:
32+
required: false
33+
type: string
34+
35+
secrets:
36+
GPG_PRIVATE_KEY:
37+
required: true
38+
PASSPHRASE:
39+
required: true
40+
SSH_KEY_TORRENTS:
41+
required: false
42+
KNOWN_HOSTS_UPLOAD:
43+
required: false
44+
45+
jobs:
46+
47+
prepare:
48+
runs-on: ubuntu-latest
49+
outputs:
50+
matrix: ${{ steps.prep.outputs.JSON_CONTENT }}
51+
steps:
52+
- name: Prepare releases
53+
id: prep
54+
run: |
55+
56+
echo 'JSON_CONTENT<<EOF' >> $GITHUB_OUTPUT
57+
printf "{ \"matrix\":\"${{ inputs.matrix }}\", \"created\":\"$(date -u +'%Y%m%d-%H%M')\"}\n" | jq -s >> $GITHUB_OUTPUT
58+
echo 'EOF' >> $GITHUB_OUTPUT
59+
60+
build:
61+
needs: [ prepare ]
62+
runs-on: ubuntu-latest
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
node: ${{fromJson(needs.prepare.outputs.matrix)}}
67+
68+
steps:
69+
70+
- name: "Checkout Armbian OS"
71+
uses: actions/checkout@v4
72+
with:
73+
repository: armbian/os
74+
ref: main
75+
fetch-depth: 1
76+
path: os
77+
78+
- name: "Checkout this repository"
79+
uses: actions/checkout@v4
80+
with:
81+
path: source
82+
83+
- name: Build ${{ matrix.node }}
84+
run: |
85+
86+
ARCH=$(echo ${{ matrix.node }} | cut -d":" -f1)
87+
PKG_NAME=${{ inputs.package }}_${{needs.prepare.outputs.created}}_${ARCH}
88+
89+
mkdir -p output/${PKG_NAME}/DEBIAN
90+
cat <<-END > output/${PKG_NAME}/DEBIAN/control
91+
Package: ${{ inputs.package }}
92+
Version: ${{needs.prepare.outputs.created}}
93+
Architecture: ${ARCH}
94+
END
95+
if [[ -n "${{ inputs.maintainer }}" ]]; then
96+
echo "Maintainer: ${{ inputs.maintainer }}" >> output/${PKG_NAME}/DEBIAN/control
97+
fi
98+
if [[ -n "${{ inputs.depends }}" ]]; then
99+
echo "Depends: ${{ inputs.depends }}" >> output/${PKG_NAME}/DEBIAN/control
100+
fi
101+
if [[ -n "${{ inputs.section }}" ]]; then
102+
echo "Section: ${{ inputs.section }}" >> output/${PKG_NAME}/DEBIAN/control
103+
fi
104+
if [[ -n "${{ inputs.priority }}" ]]; then
105+
echo "Priority: ${{ inputs.priority }}" >> output/${PKG_NAME}/DEBIAN/control
106+
fi
107+
if [[ -n "${{ inputs.description }}" ]]; then
108+
echo "Description: ${{ inputs.description }}" >> output/${PKG_NAME}/DEBIAN/control
109+
fi
110+
111+
if [[ -f source/debian.conf ]]; then
112+
while read p; do
113+
FILE=$(echo $p | cut -d":" -f1)
114+
LOCATION=$(echo $p | cut -d":" -f2 | cut -d"/" -f2-)
115+
if [[ -n $LOCATION && -n $FILE ]]; then
116+
mkdir -p "output/${PKG_NAME}/$LOCATION"
117+
cp -R source/$FILE "output/${PKG_NAME}/$LOCATION"
118+
fi
119+
done < source/debian.conf
120+
fi
121+
fakeroot dpkg-deb -b output/${PKG_NAME}/
122+
cd output/${PKG_NAME}/
123+
tar cvfz ../${PKG_NAME}.tar.gz .
124+
125+
- name: Upload deb as artifact ${{ matrix.node }}
126+
uses: actions/upload-artifact@v3
127+
with:
128+
name: deb
129+
path: output/*.deb
130+
131+
- name: Upload tarball as artifact ${{ matrix.node }}
132+
uses: actions/upload-artifact@v3
133+
with:
134+
name: tar
135+
path: output/*.tar.gz
136+
137+
release:
138+
needs: [ prepare, build ]
139+
if: "${{ always() }}"
140+
runs-on: ubuntu-latest
141+
steps:
142+
143+
- name: Install dependencies
144+
run: |
145+
echo 'man-db man-db/auto-update boolean false' | sudo debconf-set-selections
146+
sudo apt-get -q -y install reprepro
147+
148+
- uses: actions/[email protected]
149+
name: Download deb artifacts
150+
with:
151+
name: deb
152+
path: output
153+
154+
- uses: actions/[email protected]
155+
name: Download tarball artifacts
156+
with:
157+
name: tar
158+
path: output
159+
160+
- name: Checkout
161+
uses: actions/[email protected]
162+
with:
163+
path: repository
164+
ref: repository
165+
166+
- name: Import GPG key
167+
id: import_gpg
168+
uses: crazy-max/ghaction-import-gpg@v5
169+
with:
170+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
171+
passphrase: ${{ secrets.PASSPHRASE }}
172+
173+
- name: Configure git identity
174+
working-directory: repository
175+
run: |
176+
177+
echo "Testing signing" | gpg --sign --armor
178+
179+
gpg -K
180+
echo "#"
181+
git config user.name github-actions
182+
git config user.email [email protected]
183+
184+
- name: Deploy packages
185+
run: |
186+
187+
PACKAGES_DIR="$(pwd)"/output
188+
REPO_DIR="$(pwd)"/repository
189+
190+
[[ ! -d "${PACKAGES_DIR}" ]] && echo "Packages dir ${PACKAGES_DIR} is not there." && exit 2
191+
mkdir -p "${REPO_DIR}" "${REPO_DIR}"/pool
192+
193+
# Configure reprepro
194+
mkdir -p ${REPO_DIR}/conf
195+
cat <<EOD >${REPO_DIR}/conf/distributions
196+
Origin: armbian.github.io/configurator
197+
Label: armbian.github.io/configurator
198+
Codename: stable
199+
Architectures: amd64 arm64 armhf
200+
Components: main
201+
Description: Armbian development repo
202+
SignWith: DF00FAF1C577104B50BF1D0093D6889F9F0E78D5
203+
EOD
204+
205+
# Determine a list of binary debs to include in the repo
206+
# reprepro does not accept identical package(-names) with different contents (sha1)
207+
# our build does generate different contents (in different runs) and I'd like to keep old versions around
208+
LIST_DEBS_NEW=""
209+
for ONE_DEB in ${PACKAGES_DIR}/*.deb; do
210+
echo "Considering adding to repo: $ONE_DEB"
211+
BASE_ONE_DEB=$(basename ${ONE_DEB})
212+
EXISTING_DEB_IN_REPO=$(find ${REPO_DIR}/pool -type f -name ${BASE_ONE_DEB})
213+
if [[ "a${EXISTING_DEB_IN_REPO}" == "a" ]]; then
214+
echo "- New .deb to include in repo: ${BASE_ONE_DEB}"
215+
LIST_DEBS_NEW="${LIST_DEBS_NEW} ${ONE_DEB}"
216+
else
217+
echo "- Existing .deb: ${BASE_ONE_DEB}"
218+
fi
219+
done
220+
221+
echo "** Final list of DEBs to include: ${LIST_DEBS_NEW}"
222+
if [[ "a${LIST_DEBS_NEW}a" == "aa" ]]; then
223+
echo "No new packages, nothing to do."
224+
else
225+
echo "New packages, running reprepro..."
226+
reprepro -b "${REPO_DIR}" includedeb stable ${LIST_DEBS_NEW}
227+
echo "Repository generated at ${REPO_DIR}/"
228+
fi
229+
230+
cd ${REPO_DIR}
231+
git add .
232+
git commit -m "Updating repo" || true
233+
git push origin repository || true
234+
235+
236+
# - name: Install SSH key for storage
237+
# uses: shimataro/ssh-key-action@v2
238+
# with:
239+
# key: ${{ secrets.SSH_KEY_TORRENTS }}
240+
# known_hosts: ${{ secrets.KNOWN_HOSTS_UPLOAD }}
241+
# if_key_exists: replace
242+
243+
# - name: Deploy to server
244+
# run: |
245+
# ls -l build/output/images/*/*/
246+
# sudo apt-get -y -qq install lftp
247+
# lftp -u upload, -e "set net:timeout 4;set net:max-retries 6;mirror --Remove-source-files -R --no-empty-dirs --parallel=8 --no-perms $(pwd)/build/output/images/ images/ ;bye" sftp://users.armbian.com
248+
249+
- name: "GH specific release"
250+
uses: "marvinpinto/action-automatic-releases@latest"
251+
with:
252+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
253+
automatic_release_tag: "${{needs.prepare.outputs.created}}"
254+
prerelease: false
255+
title: "${{needs.prepare.outputs.created}}"
256+
files: |
257+
output/*.deb
258+
output/*.tar.gz

0 commit comments

Comments
 (0)