Skip to content

Commit 0bf281a

Browse files
committed
Add pack-debian to main
1 parent d1a8720 commit 0bf281a

File tree

1 file changed

+256
-0
lines changed

1 file changed

+256
-0
lines changed

.github/workflows/pack-debian.yml

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

0 commit comments

Comments
 (0)