Skip to content

Commit e82230a

Browse files
committed
ci: add release-aot.yml for cross-platform NativeAOT CLI binaries
1 parent 01ccd81 commit e82230a

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/release-aot.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release AOT Binaries
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
if: startsWith(github.ref_name, 'v') || github.event_name == 'workflow_dispatch'
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- { os: windows-latest, rid: win-x64, artifact: minipdf-win-x64.zip }
20+
- { os: windows-latest, rid: win-arm64, artifact: minipdf-win-arm64.zip }
21+
- { os: ubuntu-22.04, rid: linux-x64, artifact: minipdf-linux-x64.tar.gz }
22+
- os: ubuntu-22.04
23+
rid: linux-arm64
24+
artifact: minipdf-linux-arm64.tar.gz
25+
extra_args: -p:ObjCopyName=aarch64-linux-gnu-objcopy
26+
- { os: macos-latest, rid: osx-x64, artifact: minipdf-osx-x64.tar.gz }
27+
- { os: macos-latest, rid: osx-arm64, artifact: minipdf-osx-arm64.tar.gz }
28+
29+
runs-on: ${{ matrix.os }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-dotnet@v4
33+
with: { dotnet-version: '9.0.x' }
34+
35+
- name: Install cross-compilation toolchain (Linux ARM64)
36+
if: matrix.rid == 'linux-arm64'
37+
run: |
38+
sudo dpkg --add-architecture arm64
39+
sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list << EOF
40+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs) main restricted universe multiverse
41+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-updates main restricted universe multiverse
42+
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release -cs)-security main restricted universe multiverse
43+
EOF'
44+
sudo sed -i 's/^deb \(http\|mirror\)/deb [arch=amd64] \1/g' /etc/apt/sources.list
45+
sudo sed -i 's/^deb \(http\|mirror\)/deb [arch=amd64] \1/g' /etc/apt/sources.list.d/*.list 2>/dev/null || true
46+
sudo apt-get update
47+
sudo apt-get install -y gcc-aarch64-linux-gnu zlib1g-dev:arm64
48+
49+
- name: Extract version from tag
50+
id: version
51+
shell: bash
52+
run: |
53+
VERSION="${GITHUB_REF_NAME#v}"
54+
if [ -z "$VERSION" ] || [ "$VERSION" = "$GITHUB_REF_NAME" ]; then VERSION="0.0.1"; fi
55+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
56+
57+
- name: Publish AOT
58+
run: >
59+
dotnet publish src/MiniPdf.Cli/MiniPdf.Cli.csproj
60+
-c Release -r ${{ matrix.rid }} -o publish
61+
-p:Version=${{ steps.version.outputs.VERSION }}
62+
${{ matrix.extra_args }}
63+
64+
- name: Package (Windows)
65+
if: runner.os == 'Windows'
66+
run: |
67+
Copy-Item publish/MiniPdf.Cli.exe publish/minipdf.exe
68+
Compress-Archive -Path publish/minipdf.exe -DestinationPath ${{ matrix.artifact }}
69+
70+
- name: Package (Linux/macOS)
71+
if: runner.os != 'Windows'
72+
run: |
73+
cp publish/MiniPdf.Cli publish/minipdf
74+
chmod +x publish/minipdf
75+
tar -czf ${{ matrix.artifact }} -C publish minipdf
76+
77+
- name: Upload release asset
78+
if: github.event_name == 'release'
79+
uses: softprops/action-gh-release@v2
80+
with: { files: '${{ matrix.artifact }}' }
81+
82+
- name: Upload build artifact
83+
if: github.event_name == 'workflow_dispatch'
84+
uses: actions/upload-artifact@v4
85+
with: { name: '${{ matrix.artifact }}', path: '${{ matrix.artifact }}' }

0 commit comments

Comments
 (0)