Skip to content

Commit d4dd748

Browse files
authored
Merge pull request #27 from bordeux/feature/distribution-v2
ci: apk, rpm distribution
2 parents 37981e5 + c8def93 commit d4dd748

2 files changed

Lines changed: 135 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,21 @@ jobs:
174174
retention-days: 7
175175

176176
build-packages:
177-
name: Build Packages (DEB/RPM)
177+
name: Build Packages (DEB/RPM/APK)
178178
runs-on: ubuntu-latest
179179
steps:
180180
- name: Checkout code
181181
uses: actions/checkout@v4
182182

183183
- name: Setup Rust
184184
uses: dtolnay/rust-toolchain@stable
185+
with:
186+
targets: x86_64-unknown-linux-musl
187+
188+
- name: Install musl tools
189+
run: |
190+
sudo apt-get update
191+
sudo apt-get install -y musl-tools
185192
186193
- name: Cache cargo registry
187194
uses: actions/cache@v4
@@ -195,9 +202,12 @@ jobs:
195202
path: target
196203
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
197204

198-
- name: Build release binary
205+
- name: Build release binary (glibc)
199206
run: cargo build --release
200207

208+
- name: Build release binary (musl)
209+
run: cargo build --release --target x86_64-unknown-linux-musl
210+
201211
- name: Install cargo-deb
202212
run: cargo install cargo-deb
203213

@@ -210,6 +220,36 @@ jobs:
210220
- name: Build RPM package
211221
run: cargo generate-rpm
212222

223+
- name: Build APK package
224+
run: |
225+
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
226+
ARCH="x86_64"
227+
PKGNAME="tmpltool-${VERSION}-r0-${ARCH}.apk"
228+
229+
mkdir -p apk_pkg/usr/bin
230+
cp target/x86_64-unknown-linux-musl/release/tmpltool apk_pkg/usr/bin/
231+
chmod 755 apk_pkg/usr/bin/tmpltool
232+
233+
cat > apk_pkg/.PKGINFO << EOF
234+
pkgname = tmpltool
235+
pkgver = ${VERSION}-r0
236+
pkgdesc = A fast and simple command-line template rendering tool using MiniJinja templates
237+
url = https://github.com/bordeux/tmpltool
238+
arch = ${ARCH}
239+
license = MIT
240+
size = $(stat -c%s target/x86_64-unknown-linux-musl/release/tmpltool)
241+
origin = tmpltool
242+
maintainer = Chris Bednarczyk <tmpltool@bordeux.net>
243+
builddate = $(date +%s)
244+
EOF
245+
246+
cd apk_pkg
247+
tar -czf "../${PKGNAME}" .PKGINFO usr
248+
cd ..
249+
250+
mkdir -p target/apk
251+
mv "${PKGNAME}" target/apk/
252+
213253
- name: Upload DEB artifact
214254
uses: actions/upload-artifact@v4
215255
with:
@@ -224,6 +264,13 @@ jobs:
224264
path: target/generate-rpm/*.rpm
225265
retention-days: 7
226266

267+
- name: Upload APK artifact
268+
uses: actions/upload-artifact@v4
269+
with:
270+
name: tmpltool-apk
271+
path: target/apk/*.apk
272+
retention-days: 7
273+
227274
docker-build:
228275
name: Docker Build
229276
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 86 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ jobs:
8181
os: ubuntu-latest
8282
artifact_name: tmpltool
8383
asset_name: tmpltool-linux-x86_64-musl
84+
apk_arch: x86_64
85+
86+
- target: aarch64-unknown-linux-musl
87+
os: ubuntu-latest
88+
artifact_name: tmpltool
89+
asset_name: tmpltool-linux-aarch64-musl
90+
apk_arch: aarch64
8491

8592
- target: aarch64-unknown-linux-gnu
8693
os: ubuntu-latest
@@ -116,10 +123,10 @@ jobs:
116123
targets: ${{ matrix.target }}
117124

118125
- name: Install cross (Linux ARM)
119-
if: matrix.target == 'aarch64-unknown-linux-gnu'
126+
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'aarch64-unknown-linux-musl'
120127
run: cargo install cross --git https://github.com/cross-rs/cross
121128

122-
- name: Install musl tools (Linux musl)
129+
- name: Install musl tools (Linux musl x86_64)
123130
if: matrix.target == 'x86_64-unknown-linux-musl'
124131
run: |
125132
sudo apt-get update
@@ -144,11 +151,11 @@ jobs:
144151
key: ${{ runner.os }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
145152

146153
- name: Build (cross)
147-
if: matrix.target == 'aarch64-unknown-linux-gnu'
154+
if: matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'aarch64-unknown-linux-musl'
148155
run: cross build --release --target ${{ matrix.target }}
149156

150157
- name: Build (cargo)
151-
if: matrix.target != 'aarch64-unknown-linux-gnu'
158+
if: matrix.target != 'aarch64-unknown-linux-gnu' && matrix.target != 'aarch64-unknown-linux-musl'
152159
run: cargo build --release --target ${{ matrix.target }}
153160

154161
- name: Strip binary (Linux/macOS)
@@ -216,6 +223,46 @@ jobs:
216223
name: tmpltool-rpm-${{ matrix.rpm_arch }}
217224
path: tmpltool-${{ needs.semantic-release.outputs.new_release_version }}-1.${{ matrix.rpm_arch }}.rpm
218225

226+
- name: Build APK package
227+
if: matrix.apk_arch != ''
228+
run: |
229+
VERSION=${{ needs.semantic-release.outputs.new_release_version }}
230+
ARCH=${{ matrix.apk_arch }}
231+
PKGNAME="tmpltool-${VERSION}-r0-${ARCH}.apk"
232+
233+
# Create package directory structure
234+
mkdir -p apk_pkg/usr/bin
235+
cp target/${{ matrix.target }}/release/tmpltool apk_pkg/usr/bin/
236+
chmod 755 apk_pkg/usr/bin/tmpltool
237+
238+
# Create .PKGINFO
239+
cat > apk_pkg/.PKGINFO << EOF
240+
pkgname = tmpltool
241+
pkgver = ${VERSION}-r0
242+
pkgdesc = A fast and simple command-line template rendering tool using MiniJinja templates
243+
url = https://github.com/bordeux/tmpltool
244+
arch = ${ARCH}
245+
license = MIT
246+
size = $(stat -c%s target/${{ matrix.target }}/release/tmpltool 2>/dev/null || stat -f%z target/${{ matrix.target }}/release/tmpltool)
247+
origin = tmpltool
248+
maintainer = Chris Bednarczyk <tmpltool@bordeux.net>
249+
builddate = $(date +%s)
250+
EOF
251+
252+
# Create the APK (gzipped tarball)
253+
cd apk_pkg
254+
tar -czf "../${PKGNAME}" .PKGINFO usr
255+
cd ..
256+
257+
echo "Created ${PKGNAME}"
258+
259+
- name: Upload APK artifact
260+
if: matrix.apk_arch != ''
261+
uses: actions/upload-artifact@v4
262+
with:
263+
name: tmpltool-apk-${{ matrix.apk_arch }}
264+
path: tmpltool-${{ needs.semantic-release.outputs.new_release_version }}-r0-${{ matrix.apk_arch }}.apk
265+
219266
- name: Upload artifact (Windows)
220267
if: matrix.os == 'windows-latest'
221268
uses: actions/upload-artifact@v4
@@ -286,28 +333,45 @@ jobs:
286333
cache-from: type=gha
287334
cache-to: type=gha,mode=max
288335

289-
update-homebrew:
290-
name: Trigger Homebrew Formula Update
291-
needs: [semantic-release, upload-release-assets]
292-
runs-on: ubuntu-latest
293-
steps:
294-
- name: Trigger homebrew-tap workflow
295-
run: |
296-
curl -X POST \
297-
-H "Authorization: token ${{ secrets.HOMEBREW_TAP_TOKEN }}" \
298-
-H "Accept: application/vnd.github.v3+json" \
299-
https://api.github.com/repos/bordeux/homebrew-tap/actions/workflows/update-formulas.yml/dispatches \
300-
-d '{"ref":"master","inputs":{"project":"tmpltool"}}'
301-
302-
update-apt-repo:
303-
name: Trigger APT Repository Update
336+
update-package-repos:
337+
name: Trigger ${{ matrix.name }} Update
304338
needs: [semantic-release, upload-release-assets]
305339
runs-on: ubuntu-latest
340+
strategy:
341+
matrix:
342+
include:
343+
- name: Homebrew
344+
repo: bordeux/homebrew-tap
345+
workflow: update-formulas.yml
346+
token_env: HOMEBREW_TAP_TOKEN
347+
- name: APT Repository
348+
repo: bordeux/apt-repo
349+
workflow: update-repo.yml
350+
token_env: APT_REPO_TOKEN
351+
- name: APK Repository
352+
repo: bordeux/apk-repo
353+
workflow: update-repo.yml
354+
token_env: APK_REPO_TOKEN
355+
- name: RPM Repository
356+
repo: bordeux/rpm-repo
357+
workflow: update-repo.yml
358+
token_env: RPM_REPO_TOKEN
359+
- name: ARCH Repository
360+
repo: bordeux/arch-repo
361+
workflow: update-repo.yml
362+
token_env: ARCH_REPO_TOKEN
306363
steps:
307-
- name: Trigger apt-repo workflow
364+
- name: Trigger ${{ matrix.name }} workflow
365+
env:
366+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
367+
APT_REPO_TOKEN: ${{ secrets.APT_REPO_TOKEN }}
368+
APK_REPO_TOKEN: ${{ secrets.APK_REPO_TOKEN }}
369+
RPM_REPO_TOKEN: ${{ secrets.RPM_REPO_TOKEN }}
370+
ARCH_REPO_TOKEN: ${{ secrets.ARCH_REPO_TOKEN }}
308371
run: |
372+
TOKEN="${!${{ matrix.token_env }}}"
309373
curl -X POST \
310-
-H "Authorization: token ${{ secrets.APT_REPO_TOKEN }}" \
374+
-H "Authorization: token $TOKEN" \
311375
-H "Accept: application/vnd.github.v3+json" \
312-
https://api.github.com/repos/bordeux/apt-repo/actions/workflows/update-repo.yml/dispatches \
376+
"https://api.github.com/repos/${{ matrix.repo }}/actions/workflows/${{ matrix.workflow }}/dispatches" \
313377
-d '{"ref":"master","inputs":{"project":"bordeux/tmpltool"}}'

0 commit comments

Comments
 (0)