ci: use cross-compilation for windows to support linux-only runners
Some checks failed
Build and Release / Build All Platforms (push) Failing after 17s
Some checks failed
Build and Release / Build All Platforms (push) Failing after 17s
This commit is contained in:
@@ -6,8 +6,8 @@ on:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
name: Build Linux
|
||||
build-all:
|
||||
name: Build All Platforms
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -15,68 +15,36 @@ jobs:
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: x86_64-unknown-linux-gnu, x86_64-pc-windows-gnu
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
- name: Package Linux
|
||||
- name: Install Cross-Compilation Tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y mingw-w64
|
||||
|
||||
- name: Build Linux
|
||||
run: cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Build Windows
|
||||
run: cargo build --release --target x86_64-pc-windows-gnu
|
||||
|
||||
- name: Package Release Assets
|
||||
run: |
|
||||
# Package Linux
|
||||
mkdir -p dist-linux
|
||||
cp target/release/dhl dist-linux/dhl
|
||||
cp target/x86_64-unknown-linux-gnu/release/dhl dist-linux/dhl
|
||||
cp config.json.example dist-linux/config.json
|
||||
cp response.json.example dist-linux/response.json
|
||||
tar -czvf dhl-linux.tar.gz -C dist-linux .
|
||||
|
||||
- name: Upload Linux Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dhl-linux
|
||||
path: dhl-linux.tar.gz
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release
|
||||
|
||||
- name: Package Windows
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force -Path dist-windows
|
||||
Copy-Item target/release/dhl.exe dist-windows/dhl.exe
|
||||
Copy-Item config.json.example dist-windows/config.json
|
||||
Copy-Item response.json.example dist-windows/response.json
|
||||
Compress-Archive -Path dist-windows/* -DestinationPath dhl-windows.zip
|
||||
|
||||
- name: Upload Windows Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: dhl-windows
|
||||
path: dhl-windows.zip
|
||||
|
||||
create-release:
|
||||
name: Create Release
|
||||
needs: [build-linux, build-windows]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Linux Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: dhl-linux
|
||||
path: .
|
||||
|
||||
- name: Download Windows Artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: dhl-windows
|
||||
path: .
|
||||
# Package Windows
|
||||
mkdir -p dist-windows
|
||||
cp target/x86_64-pc-windows-gnu/release/dhl.exe dist-windows/dhl.exe
|
||||
cp config.json.example dist-windows/config.json
|
||||
cp response.json.example dist-windows/response.json
|
||||
# Use zip on linux to package windows build
|
||||
zip -j dhl-windows.zip dist-windows/*
|
||||
|
||||
- name: Create Gitea Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
|
||||
Reference in New Issue
Block a user