commit 4471607f9691d6c9487edb6e0a195ebbcc651f3d
parent b6191ccf13cf9ad160b3ede749ecd3594ec77dce
Author: Johann150 <johann.galle@protonmail.com>
Date: Fri, 5 Feb 2021 22:42:40 +0100
add release build action
No longer using `cross`, so Cross.toml is not needed any more.
Instead releases are just built with cargo build --release.
Diffstat:
5 files changed, 142 insertions(+), 3 deletions(-)
diff --git a/.cargo/config b/.cargo/config
@@ -0,0 +1,8 @@
+[target.aarch64-unknown-linux-gnu]
+linker = "aarch64-linux-gnu-gcc"
+
+[target.arm-unknown-linux-gnueabihf]
+linker = "arm-linux-gnueabihf-gcc"
+
+[target.armv7-unknown-linux-gnueabihf]
+linker = "arm-linux-gnueabihf-gcc"
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
@@ -0,0 +1,109 @@
+name: Release Builds
+
+on:
+ push:
+ tags:
+ - 'v*' # on every version tag
+
+jobs:
+ # first just a small job to draft the release so all others can use the upload_url
+ create_release:
+ runs-on: ubuntu-latest
+ steps:
+ - name: create release
+ id: create_release
+ uses: actions/create-release@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ github.ref }}
+ release_name: ${{ github.ref }}
+ # only draft the release so changelog can be edited
+ draft: true
+ prerelease: false
+ outputs:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+
+ build_ubuntu:
+ runs-on: ubuntu-latest
+ needs: create_release
+ steps:
+ - uses: actions/checkout@v1
+ - name: build
+ run: bash release.sh
+ - name: upload release asset x86_64
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create_release.outputs.upload_url }}
+ asset_path: ./agate.x86_64-unknown-linux-gnu.gz
+ asset_name: agate.x86_64-unknown-linux-gnu.gz
+ asset_content_type: application/gzip
+ - name: upload release asset arm
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create_release.outputs.upload_url }}
+ asset_path: ./agate.arm-unknown-linux-gnueabihf.gz
+ asset_name: agate.arm-unknown-linux-gnueabihf.gz
+ asset_content_type: application/gzip
+ - name: upload release asset armv7
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create_release.outputs.upload_url }}
+ asset_path: ./agate.armv7-unknown-linux-gnueabihf.gz
+ asset_name: agate.armv7-unknown-linux-gnueabihf.gz
+ asset_content_type: application/gzip
+ - name: upload release asset aarch64
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create_release.outputs.upload_url }}
+ asset_path: ./agate.aarch64-unknown-linux-gnu.gz
+ asset_name: agate.aarch64-unknown-linux-gnu.gz
+ asset_content_type: application/gzip
+
+ build_windows:
+ runs-on: windows-latest
+ needs: create_release
+ steps:
+ - uses: actions/checkout@v1
+ - run: rustc -Vv
+ - name: Build
+ run: cargo build --verbose --release
+ - name: upload release asset win
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create_release.outputs.upload_url }}
+ asset_name: agate.x86_64-pc-windows-msvc.exe
+ # TODO: this one is not zipped and not stripped
+ asset_path: target/release/agate.exe
+ asset_content_type: application/vnd.microsoft.portable-executable
+
+ build_macos:
+ runs-on: macos-latest
+ needs: create_release
+ steps:
+ - uses: actions/checkout@v1
+ - name: Build
+ run: cargo build --verbose --release
+ - name: strip names
+ run: strip target/release/agate
+ - name: compress
+ run: gzip -c target/release/agate > ./agate.gz
+ - name: upload release asset darwin
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ needs.create_release.outputs.upload_url }}
+ asset_path: ./agate.gz
+ asset_name: agate.x86_64-apple-darwin.gz
+ asset_content_type: application/gzip
diff --git a/Cargo.toml b/Cargo.toml
@@ -9,7 +9,7 @@ repository = "https://github.com/mbrubeck/agate"
readme = "README.md"
license = "MIT/Apache-2.0"
edition = "2018"
-exclude = ["/tools"]
+exclude = ["/tools", ".github/", "release.sh"]
[dependencies]
tokio-rustls = "0.22.0"
diff --git a/Cross.toml b/Cross.toml
@@ -1,2 +0,0 @@
-[target.arm-unknown-linux-gnueabihf]
-image = "zenria/cross:arm-rpi-4.9.3-linux-gnueabihf"
diff --git a/release.sh b/release.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# This is used to build cross platform linux binaries for a release in CI.
+# Since this is not supervised, abort if anything does not work.
+set -e
+
+# Cross-compiling needs a linker for the respective platforms. If you are on a Debian-based x86_64 Linux,
+# you can install them with:
+sudo apt -y install gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
+
+for i in x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf armv7-unknown-linux-gnueabihf
+do
+ # Make sure the cross-compiled std crate is available.
+ rustup target add $i
+ cargo build --verbose --release --target $i
+ cp target/$i/release/agate agate.$i
+done
+
+# Strip all the binaries.
+strip agate.x86_64-unknown-linux-gnu
+aarch64-linux-gnu-strip agate.aarch64-unknown-linux-gnu
+arm-linux-gnueabihf-strip agate.arm-unknown-linux-gnueabihf agate.armv7-unknown-linux-gnueabihf
+
+# compress the binaries.
+gzip agate.*