blob: 01aa465e4383a1c86a865a69a60049b23098f68d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
name: Build Packages
permissions:
contents: read
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 }})
permissions:
contents: write
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"
# Store version for later use
echo "version=$VERSION" >> $GITHUB_OUTPUT
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.RELEASE_TOKEN }}
with:
upload_url: ${{ steps.get-release.outputs.upload_url }}
asset_path: ${{ steps.find-deb.outputs.path }}
asset_name: mikusays-debian-${{ matrix.arch }}-${{ steps.find-deb.outputs.version }}.deb
asset_content_type: application/vnd.debian.binary-package
build-rpm:
name: Build RPM Package (${{ matrix.arch }})
permissions:
contents: write
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"
# Store version for later use
echo "version=$VERSION" >> $GITHUB_OUTPUT
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.RELEASE_TOKEN }}
with:
upload_url: ${{ steps.get-release.outputs.upload_url }}
asset_path: ${{ steps.find-rpm.outputs.path }}
asset_name: mikusays-redhat-${{ matrix.arch }}-${{ steps.find-rpm.outputs.version }}.rpm
asset_content_type: application/x-rpm
|