aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorxxanqw <[email protected]>2025-11-23 06:19:13 +0200
committerxxanqw <[email protected]>2025-11-23 06:19:13 +0200
commit05e667006070281ee475b54acbf737d50fdb9718 (patch)
tree136bc4d25457a0ea211c38c17ccea7978f13db73 /.github
parentfbe779b71d903e277765d9d64dc938120a9e11dc (diff)
downloadmikusays-c-05e667006070281ee475b54acbf737d50fdb9718.tar.gz
mikusays-c-05e667006070281ee475b54acbf737d50fdb9718.zip
Add support for building DEB and RPM packages in CI workflows
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/package.yml173
-rw-r--r--.github/workflows/release.yml6
2 files changed, 179 insertions, 0 deletions
diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml
new file mode 100644
index 0000000..035d656
--- /dev/null
+++ b/.github/workflows/package.yml
@@ -0,0 +1,173 @@
+name: Build Packages
+
+on:
+ release:
+ types: [created]
+ workflow_dispatch:
+ inputs:
+ release_tag:
+ description: 'Release tag to attach packages to (e.g., v0.1.3)'
+ required: false
+ type: string
+
+jobs:
+ build-deb:
+ name: Build DEB Package (${{ matrix.arch }})
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ include:
+ - arch: x86_64
+ target: x86_64-unknown-linux-gnu
+ deb_arch: amd64
+ - arch: aarch64
+ target: aarch64-unknown-linux-gnu
+ deb_arch: arm64
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: ${{ matrix.target }}
+
+ - name: Install cross-compilation tools
+ if: matrix.arch == 'aarch64'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y gcc-aarch64-linux-gnu
+
+ - name: Install cargo-deb
+ run: cargo install cargo-deb
+
+ - name: Build DEB package
+ run: cargo deb --target ${{ matrix.target }}
+ env:
+ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
+
+ - name: Find DEB package
+ id: find-deb
+ run: |
+ DEB_PATH=$(find target/${{ matrix.target }}/debian -name "*.deb" | head -n 1)
+ echo "path=$DEB_PATH" >> $GITHUB_OUTPUT
+ VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
+ ARCH_NAME="${{ matrix.deb_arch }}"
+ if [ "$ARCH_NAME" = "amd64" ]; then ARCH_NAME="x64"; fi
+ DEB_NAME="mikusays-debian-${ARCH_NAME}-${VERSION}.deb"
+ echo "name=$DEB_NAME" >> $GITHUB_OUTPUT
+
+ - name: Upload DEB artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: deb-package-${{ matrix.arch }}
+ path: ${{ steps.find-deb.outputs.path }}
+
+ - name: Get release upload URL
+ id: get-release
+ if: github.event_name == 'release' || github.event.inputs.release_tag
+ run: |
+ if [ "${{ github.event_name }}" = "release" ]; then
+ echo "upload_url=${{ github.event.release.upload_url }}" >> $GITHUB_OUTPUT
+ else
+ RELEASE_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
+ "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.release_tag }}")
+ UPLOAD_URL=$(echo "$RELEASE_DATA" | jq -r '.upload_url')
+ echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Upload to release
+ if: github.event_name == 'release' || github.event.inputs.release_tag
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.get-release.outputs.upload_url }}
+ asset_path: ${{ steps.find-deb.outputs.path }}
+ asset_name: ${{ steps.find-deb.outputs.name }}
+ asset_content_type: application/vnd.debian.binary-package
+
+ build-rpm:
+ name: Build RPM Package (${{ matrix.arch }})
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ include:
+ - arch: x86_64
+ target: x86_64-unknown-linux-gnu
+ rpm_arch: x86_64
+ - arch: aarch64
+ target: aarch64-unknown-linux-gnu
+ rpm_arch: aarch64
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: ${{ matrix.target }}
+
+ - name: Install cross-compilation tools
+ if: matrix.arch == 'aarch64'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y gcc-aarch64-linux-gnu
+
+ - name: Install cargo-generate-rpm
+ run: cargo install cargo-generate-rpm
+
+ - name: Build release binary
+ run: cargo build --release --target ${{ matrix.target }}
+ env:
+ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
+
+ - name: Strip binary
+ run: |
+ if [ "${{ matrix.arch }}" = "aarch64" ]; then
+ aarch64-linux-gnu-strip target/${{ matrix.target }}/release/mikusays
+ else
+ strip target/${{ matrix.target }}/release/mikusays
+ fi
+
+ - name: Generate RPM package
+ run: cargo generate-rpm --target ${{ matrix.target }}
+
+ - name: Find RPM package
+ id: find-rpm
+ run: |
+ RPM_PATH=$(find target/${{ matrix.target }}/generate-rpm -name "*.rpm" | head -n 1)
+ echo "path=$RPM_PATH" >> $GITHUB_OUTPUT
+ VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
+ ARCH_NAME="${{ matrix.rpm_arch }}"
+ if [ "$ARCH_NAME" = "x86_64" ]; then ARCH_NAME="x64"; fi
+ RPM_NAME="mikusays-redhat-${ARCH_NAME}-${VERSION}.rpm"
+ echo "name=$RPM_NAME" >> $GITHUB_OUTPUT
+
+ - name: Upload RPM artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: rpm-package-${{ matrix.arch }}
+ path: ${{ steps.find-rpm.outputs.path }}
+
+ - name: Get release upload URL
+ id: get-release
+ if: github.event_name == 'release' || github.event.inputs.release_tag
+ run: |
+ if [ "${{ github.event_name }}" = "release" ]; then
+ echo "upload_url=${{ github.event.release.upload_url }}" >> $GITHUB_OUTPUT
+ else
+ RELEASE_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
+ "https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.event.inputs.release_tag }}")
+ UPLOAD_URL=$(echo "$RELEASE_DATA" | jq -r '.upload_url')
+ echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
+ fi
+
+ - name: Upload to release
+ if: github.event_name == 'release' || github.event.inputs.release_tag
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.get-release.outputs.upload_url }}
+ asset_path: ${{ steps.find-rpm.outputs.path }}
+ asset_name: ${{ steps.find-rpm.outputs.name }}
+ asset_content_type: application/x-rpm \ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7cad5b6..2ec62ee 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -158,6 +158,12 @@ jobs:
### Linux
- **x64**: `mikusays-linux-x64`
- **ARM64**: `mikusays-linux-arm64`
+
+ - **x64 Debian Package**: `mikusays-debian-x64.deb`
+ - **ARM64 Debian Package**: `mikusays-debian-arm64.deb`
+
+ - **x64 RPM Package**: `mikusays-redhat-x64.rpm`
+ - **ARM64 RPM Package**: `mikusays-redhat-arm64.rpm`
### macOS
- **Intel (x64)**: `mikusays-macos-x64`