This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
Update README.md #91
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://github.com/docker/build-push-action | |
name: builddocker | |
on: | |
push: | |
branches: master | |
tags: | |
- "*.*.*" | |
jobs: | |
x64: | |
name: Build x64 | |
runs-on: ubuntu-latest | |
# after every step is finished,exporting to PATH will be clear,so in next step ,need re-export | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up cargo | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
# clone and patch anki library | |
# need to disable bundled feature in rusqlite in anki lib,so copy after-modified cargo file | |
- name: Clone patch Anki | |
run: | | |
sh ./scripts/clone_patch_anki | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
version: '3.x' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Add cargo taget x64 | |
run: rustup target add x86_64-unknown-linux-musl | |
- uses: robinraju/[email protected] | |
with: | |
repository: "dobefore/musl-cross" | |
tag: "0.1.0" | |
fileName: "x86_64-linux-musl-cross.tgz" | |
- name: Copy musl-cross to home | |
run: cp x86_64-linux-musl-cross.tgz $HOME | |
- name: unpack cross-compile toolchains musl | |
run: tar -zxvf $HOME/x86_64-linux-musl-cross.tgz -C $HOME | |
# # openssl | |
- uses: robinraju/[email protected] | |
with: | |
repository: "dobefore/cross-compile-openssl-musl" | |
tag: "1.1.1" | |
fileName: "openssl1.1.1f_1.1.1_linux_x64.tar.gz" | |
- name: Copy openssl lib to home | |
run: cp openssl1.1.1f_1.1.1_linux_x64.tar.gz $HOME | |
- name: unpack openssl | |
run: | | |
tar -zxvf $HOME/openssl1.1.1f_1.1.1_linux_x64.tar.gz -C $HOME | |
cp -r $HOME/openssl1.1.1f_1.1.1_linux_x64/openssl/ $HOME | |
- name: Build | |
run: | | |
export OPENSSL_LIB_DIR=$HOME/openssl/lib | |
export OPENSSL_INCLUDE_DIR=$HOME/openssl/include | |
export OPENSSL_STATIC=true | |
sudo apt install musl-tools | |
export PATH="$HOME/x86_64-linux-musl-cross/bin:$PATH" | |
cargo build --target x86_64-unknown-linux-musl --release | |
- run: mv target/x86_64-unknown-linux-musl/release/ankisyncd x86_64-unknown-linux-musl-ankisyncd | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: binary | |
path: x86_64-unknown-linux-musl-ankisyncd | |
retention-days: 1 | |
arm64: | |
name: Build arm64 | |
runs-on: ubuntu-latest | |
# after every step is finished,exporting to PATH will be clear,so in next step ,need re-export | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up cargo | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
# clone and patch anki library | |
# need to disable bundled feature in rusqlite in anki lib,so copy after-modified cargo file | |
- name: Clone patch Anki | |
run: | | |
sh ./scripts/clone_patch_anki | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
version: '3.x' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Install Protoc | |
# run: | | |
# PB_REL="https://github.com/protocolbuffers/protobuf/releases" | |
# curl -LO $PB_REL/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip | |
# mkdir -p $HOME/protoc | |
# unzip protoc-3.15.8-linux-x86_64.zip -d $HOME/protoc | |
- name: Add cargo taget arm64 | |
run: rustup target add aarch64-unknown-linux-musl | |
- uses: robinraju/[email protected] | |
with: | |
repository: "dobefore/musl-cross" | |
tag: "0.1.0" | |
fileName: "aarch64-linux-musl-cross.tgz" | |
- name: Copy musl-cross to home | |
run: cp aarch64-linux-musl-cross.tgz $HOME | |
- name: unpack cross-compile toolchains musl | |
run: tar -zxvf $HOME/aarch64-linux-musl-cross.tgz -C $HOME | |
# # openssl | |
- uses: robinraju/[email protected] | |
with: | |
repository: "dobefore/cross-compile-openssl-musl" | |
tag: "1.1.1" | |
fileName: "openssl1.1.1f_1.1.1_linux_arm64.tar.gz" | |
- name: Copy openssl lib to home | |
run: cp openssl1.1.1f_1.1.1_linux_arm64.tar.gz $HOME | |
- name: unpack openssl | |
run: | | |
tar -zxvf $HOME/openssl1.1.1f_1.1.1_linux_arm64.tar.gz -C $HOME | |
cp -r $HOME/openssl1.1.1f_1.1.1_linux_arm64/openssl/ $HOME | |
# # sqlite3 seems to need it any more, | |
# - uses: robinraju/[email protected] | |
# with: | |
# repository: "dobefore/cross-compile-sqlite-musl" | |
# tag: "0.1.2" | |
# fileName: "sqliteautoconf3390000_0.1.2_linux_arm64.tar.gz" | |
# - name: Copy sqlite lib to home | |
# run: cp sqliteautoconf3390000_0.1.2_linux_arm64.tar.gz $HOME | |
# tar -zxvf $HOME/sqliteautoconf3390000_0.1.2_linux_arm64.tar.gz -C $HOME | |
# - name: unpack sqlite3 | |
# run: | | |
# tar -zxvf sqliteautoconf3390000_0.1.2_linux_arm64.tar.gz | |
# cp -r sqliteautoconf3390000_0.1.2_linux_arm64/sql/ . | |
# cp -r sql/ $HOME | |
# export SQLITE3_LIB_DIR=$HOME/sql/lib | |
# export SQLITE3_INCLUDE_DIR=$HOME/sql/include | |
# cp -r $HOME/sql/ . | |
# build static-linked binary for armv6 (also suitable for aarch64) | |
- name: Build | |
run: | | |
export OPENSSL_LIB_DIR=$HOME/openssl/lib | |
export OPENSSL_INCLUDE_DIR=$HOME/openssl/include | |
export OPENSSL_STATIC=true | |
export SQLITE3_STATIC=1 | |
export PATH="$HOME/aarch64-linux-musl-cross/bin:$PATH" | |
cargo build --target aarch64-unknown-linux-musl --release | |
- name: Strip binaries (ankisyncd) | |
run: $HOME/aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip target/aarch64-unknown-linux-musl/release/ankisyncd | |
- run: mv target/aarch64-unknown-linux-musl/release/ankisyncd aarch64-unknown-linux-musl-ankisyncd | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: binary | |
path: aarch64-unknown-linux-musl-ankisyncd | |
retention-days: 1 | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: binary | |
path: scripts/ankisyncd.toml | |
retention-days: 1 | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: binary | |
path: scripts/entrypoint.sh | |
retention-days: 1 | |
docker: | |
needs: [x64,arm64] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
# list of Docker images to use as base name for tags | |
images: ankicommunity/anki-sync-server-rs | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
latest | |
type=semver,pattern={{version}} | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- uses: actions/download-artifact@v2 | |
with: | |
name: binary | |
path: binary | |
- | |
name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: .github/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |