Skip to content

Commit f8f952e

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

File tree

1 file changed

+259
-0
lines changed

1 file changed

+259
-0
lines changed

.github/workflows/pack-debian.yml

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

0 commit comments

Comments
 (0)