Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,57 +174,104 @@
retention-days: 7

build-packages:
name: Build Packages (DEB/RPM)
name: Build Packages (DEB/RPM/APK)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl

- name: Install musl tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}

- name: Build release binary
- name: Build release binary (glibc)
run: cargo build --release

- name: Build release binary (musl)
run: cargo build --release --target x86_64-unknown-linux-musl

- name: Install cargo-deb
run: cargo install cargo-deb

- name: Build DEB package
run: cargo deb --no-build

- name: Install cargo-generate-rpm
run: cargo install cargo-generate-rpm

- name: Build RPM package
run: cargo generate-rpm

- name: Build APK package
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
ARCH="x86_64"
PKGNAME="tmpltool-${VERSION}-r0-${ARCH}.apk"

mkdir -p apk_pkg/usr/bin
cp target/x86_64-unknown-linux-musl/release/tmpltool apk_pkg/usr/bin/
chmod 755 apk_pkg/usr/bin/tmpltool

cat > apk_pkg/.PKGINFO << EOF
pkgname = tmpltool
pkgver = ${VERSION}-r0
pkgdesc = A fast and simple command-line template rendering tool using MiniJinja templates
url = https://github.com/bordeux/tmpltool
arch = ${ARCH}
license = MIT
size = $(stat -c%s target/x86_64-unknown-linux-musl/release/tmpltool)
origin = tmpltool
maintainer = Chris Bednarczyk <tmpltool@bordeux.net>
builddate = $(date +%s)
EOF

cd apk_pkg
tar -czf "../${PKGNAME}" .PKGINFO usr
cd ..

mkdir -p target/apk
mv "${PKGNAME}" target/apk/

- name: Upload DEB artifact
uses: actions/upload-artifact@v4
with:
name: tmpltool-deb
path: target/debian/*.deb
retention-days: 7

- name: Upload RPM artifact
uses: actions/upload-artifact@v4
with:
name: tmpltool-rpm
path: target/generate-rpm/*.rpm
retention-days: 7

- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: tmpltool-apk
path: target/apk/*.apk
retention-days: 7

docker-build:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Docker Build
runs-on: ubuntu-latest
steps:
Expand Down
108 changes: 86 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ jobs:
os: ubuntu-latest
artifact_name: tmpltool
asset_name: tmpltool-linux-x86_64-musl
apk_arch: x86_64

- target: aarch64-unknown-linux-musl
os: ubuntu-latest
artifact_name: tmpltool
asset_name: tmpltool-linux-aarch64-musl
apk_arch: aarch64

- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
Expand Down Expand Up @@ -116,10 +123,10 @@ jobs:
targets: ${{ matrix.target }}

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

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

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

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

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

- name: Build APK package
if: matrix.apk_arch != ''
run: |
VERSION=${{ needs.semantic-release.outputs.new_release_version }}
ARCH=${{ matrix.apk_arch }}
PKGNAME="tmpltool-${VERSION}-r0-${ARCH}.apk"

# Create package directory structure
mkdir -p apk_pkg/usr/bin
cp target/${{ matrix.target }}/release/tmpltool apk_pkg/usr/bin/
chmod 755 apk_pkg/usr/bin/tmpltool

# Create .PKGINFO
cat > apk_pkg/.PKGINFO << EOF
pkgname = tmpltool
pkgver = ${VERSION}-r0
pkgdesc = A fast and simple command-line template rendering tool using MiniJinja templates
url = https://github.com/bordeux/tmpltool
arch = ${ARCH}
license = MIT
size = $(stat -c%s target/${{ matrix.target }}/release/tmpltool 2>/dev/null || stat -f%z target/${{ matrix.target }}/release/tmpltool)
origin = tmpltool
maintainer = Chris Bednarczyk <tmpltool@bordeux.net>
builddate = $(date +%s)
EOF

# Create the APK (gzipped tarball)
cd apk_pkg
tar -czf "../${PKGNAME}" .PKGINFO usr
cd ..

echo "Created ${PKGNAME}"

- name: Upload APK artifact
if: matrix.apk_arch != ''
uses: actions/upload-artifact@v4
with:
name: tmpltool-apk-${{ matrix.apk_arch }}
path: tmpltool-${{ needs.semantic-release.outputs.new_release_version }}-r0-${{ matrix.apk_arch }}.apk

- name: Upload artifact (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -286,28 +333,45 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

update-homebrew:
name: Trigger Homebrew Formula Update
needs: [semantic-release, upload-release-assets]
runs-on: ubuntu-latest
steps:
- name: Trigger homebrew-tap workflow
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.HOMEBREW_TAP_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/bordeux/homebrew-tap/actions/workflows/update-formulas.yml/dispatches \
-d '{"ref":"master","inputs":{"project":"tmpltool"}}'

update-apt-repo:
name: Trigger APT Repository Update
update-package-repos:
name: Trigger ${{ matrix.name }} Update
needs: [semantic-release, upload-release-assets]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Homebrew
repo: bordeux/homebrew-tap
workflow: update-formulas.yml
token_env: HOMEBREW_TAP_TOKEN
- name: APT Repository
repo: bordeux/apt-repo
workflow: update-repo.yml
token_env: APT_REPO_TOKEN
- name: APK Repository
repo: bordeux/apk-repo
workflow: update-repo.yml
token_env: APK_REPO_TOKEN
- name: RPM Repository
repo: bordeux/rpm-repo
workflow: update-repo.yml
token_env: RPM_REPO_TOKEN
- name: ARCH Repository
repo: bordeux/arch-repo
workflow: update-repo.yml
token_env: ARCH_REPO_TOKEN
steps:
- name: Trigger apt-repo workflow
- name: Trigger ${{ matrix.name }} workflow
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
APT_REPO_TOKEN: ${{ secrets.APT_REPO_TOKEN }}
APK_REPO_TOKEN: ${{ secrets.APK_REPO_TOKEN }}
RPM_REPO_TOKEN: ${{ secrets.RPM_REPO_TOKEN }}
ARCH_REPO_TOKEN: ${{ secrets.ARCH_REPO_TOKEN }}
run: |
TOKEN="${!${{ matrix.token_env }}}"
curl -X POST \
-H "Authorization: token ${{ secrets.APT_REPO_TOKEN }}" \
-H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/bordeux/apt-repo/actions/workflows/update-repo.yml/dispatches \
"https://api.github.com/repos/${{ matrix.repo }}/actions/workflows/${{ matrix.workflow }}/dispatches" \
-d '{"ref":"master","inputs":{"project":"bordeux/tmpltool"}}'