Skip to content

Commit 0cac27d

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

File tree

1 file changed

+246
-0
lines changed

1 file changed

+246
-0
lines changed

.github/workflows/pack-debian.yml

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

0 commit comments

Comments
 (0)