From 52fcb1aa5e6a52f85c5453a6737c273d78e908d3 Mon Sep 17 00:00:00 2001 From: Michael Kefeder Date: Wed, 28 Aug 2024 14:14:21 +0200 Subject: [PATCH 1/2] fix compiler warning --- src/common/drive_file.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/drive_file.rs b/src/common/drive_file.rs index 6278b63..69a6c8f 100644 --- a/src/common/drive_file.rs +++ b/src/common/drive_file.rs @@ -61,7 +61,7 @@ pub enum DocType { } impl DocType { - const IMPORT_EXTENSION_MAP: &[(FileExtension, DocType)] = &[ + const IMPORT_EXTENSION_MAP: &'static [(FileExtension, DocType)] = &[ (FileExtension::Doc, DocType::Document), (FileExtension::Docx, DocType::Document), (FileExtension::Odt, DocType::Document), From 6fdffcffc5ddce699329424ace53482475f69541 Mon Sep 17 00:00:00 2001 From: Michael Kefeder Date: Wed, 28 Aug 2024 14:15:08 +0200 Subject: [PATCH 2/2] build for macOS arm64, linux armv7 and linux aarch64 --- .cargo/config.toml | 10 +++++ .github/workflows/release_linux.yaml | 2 +- .github/workflows/release_linux_aarch64.yaml | 47 ++++++++++++++++++++ .github/workflows/release_linux_arm.yaml | 47 ++++++++++++++++++++ .github/workflows/release_macos.yaml | 2 +- .github/workflows/release_macos_arm.yaml | 38 ++++++++++++++++ 6 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 .github/workflows/release_linux_aarch64.yaml create mode 100644 .github/workflows/release_linux_arm.yaml create mode 100644 .github/workflows/release_macos_arm.yaml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..d1161a5 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,10 @@ +# use the correct linker for cross compiling to ARM +[target.armv7-unknown-linux-musleabihf] +linker = "rust-lld" + +[target.arm-unknown-linux-musleabi] +linker = "rust-lld" + +[target.aarch64-unknown-linux-musl] +linker = "rust-lld" + diff --git a/.github/workflows/release_linux.yaml b/.github/workflows/release_linux.yaml index 1a02650..20c3595 100644 --- a/.github/workflows/release_linux.yaml +++ b/.github/workflows/release_linux.yaml @@ -1,4 +1,4 @@ -name: Build and upload release (linux) +name: Build and upload release (linux x86_64) on: release: diff --git a/.github/workflows/release_linux_aarch64.yaml b/.github/workflows/release_linux_aarch64.yaml new file mode 100644 index 0000000..84c645c --- /dev/null +++ b/.github/workflows/release_linux_aarch64.yaml @@ -0,0 +1,47 @@ +name: Build and upload release (linux aarch64) + +on: + release: + types: [created] + +env: + APP_NAME: gdrive + ARCHIVE_NAME: gdrive_linux-aarch64.tar.gz + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Prepare upload url + run: | + UPLOAD_URL="$(jq -r '.release.upload_url' "$GITHUB_EVENT_PATH" | sed -e "s/{?name,label}$/?name=${ARCHIVE_NAME}/")" + echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: aarch64-unknown-linux-musl + + - name: Build application + run: | + sudo apt update && sudo apt install -y clang llvm + export TARGET_CC=clang + export TARGET_AR=llvm-ar + cargo build --release --target=aarch64-unknown-linux-musl + + - name: Create archive + run: | + tar -czf $ARCHIVE_NAME -C target/aarch64-unknown-linux-musl/release $APP_NAME + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.UPLOAD_URL }} + asset_path: ${{ env.ARCHIVE_NAME }} + asset_name: ${{ env.ARCHIVE_NAME }} + asset_content_type: application/gzip diff --git a/.github/workflows/release_linux_arm.yaml b/.github/workflows/release_linux_arm.yaml new file mode 100644 index 0000000..945a5a5 --- /dev/null +++ b/.github/workflows/release_linux_arm.yaml @@ -0,0 +1,47 @@ +name: Build and upload release (linux arm 32bit) + +on: + release: + types: [created] + +env: + APP_NAME: gdrive + ARCHIVE_NAME: gdrive_linux-arm.tar.gz + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Prepare upload url + run: | + UPLOAD_URL="$(jq -r '.release.upload_url' "$GITHUB_EVENT_PATH" | sed -e "s/{?name,label}$/?name=${ARCHIVE_NAME}/")" + echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: armv7-unknown-linux-musleabihf + + - name: Build application + run: | + sudo apt update && sudo apt install -y clang llvm + export TARGET_CC=clang + export TARGET_AR=llvm-ar + cargo build --release --target=armv7-unknown-linux-musleabihf + + - name: Create archive + run: | + tar -czf $ARCHIVE_NAME -C target/armv7-unknown-linux-musleabihf/release $APP_NAME + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.UPLOAD_URL }} + asset_path: ${{ env.ARCHIVE_NAME }} + asset_name: ${{ env.ARCHIVE_NAME }} + asset_content_type: application/gzip diff --git a/.github/workflows/release_macos.yaml b/.github/workflows/release_macos.yaml index 1ccdc10..6fee7d0 100644 --- a/.github/workflows/release_macos.yaml +++ b/.github/workflows/release_macos.yaml @@ -1,4 +1,4 @@ -name: Build and upload release (macos) +name: Build and upload release (macos x86_64) on: release: diff --git a/.github/workflows/release_macos_arm.yaml b/.github/workflows/release_macos_arm.yaml new file mode 100644 index 0000000..c66f2af --- /dev/null +++ b/.github/workflows/release_macos_arm.yaml @@ -0,0 +1,38 @@ +name: Build and upload release (macos arm64) + +on: + release: + types: [created] + +env: + APP_NAME: gdrive + ARCHIVE_NAME: gdrive_macos-arm64.tar.gz + +jobs: + build: + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Prepare upload url + run: | + UPLOAD_URL="$(jq -r '.release.upload_url' "$GITHUB_EVENT_PATH" | sed -e "s/{?name,label}$/?name=${ARCHIVE_NAME}/")" + echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV + + - name: Build application + run: | + rustup target add aarch64-apple-darwin + cargo build --release --target=aarch64-apple-darwin + tar -czf $ARCHIVE_NAME -C target/aarch64-apple-darwin/release/ $APP_NAME + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.UPLOAD_URL }} + asset_path: ${{ env.ARCHIVE_NAME }} + asset_name: ${{ env.ARCHIVE_NAME }} + asset_content_type: application/gzip