Skip to content

Cross Compilation

Cross Compilation #56

Workflow file for this run

name: Cross Compilation
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- riscv64gc-unknown-linux-gnu
steps:
- uses: actions/checkout@v3
- name: Pull Docker image from Docker Hub
run: docker pull 255doesnotexist/lintestor-cross-compile:latest
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Cross compile
run: |
docker run --rm -v ${{ github.workspace }}:/root/src 255doesnotexist/lintestor-cross-compile:latest \
sh -c "cd /root/src && cargo build --release --target ${{ matrix.target }} && mv target/${{ matrix.target }}/release/lintestor target/${{ matrix.target }}/release/lintestor-${{ matrix.target }}-${{ steps.date.outputs.date }}"
- name: Listing targets
run: |
ls target/${{ matrix.target }}/release/ # 不是我 binary 呢让我看看编译了吗
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: lintestor-${{ matrix.target }}-${{ steps.date.outputs.date }}
path: target/${{ matrix.target }}/release/lintestor-${{ matrix.target }}-${{ steps.date.outputs.date }}
create-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release-${{ steps.date.outputs.date }}
release_name: Nightly Release ${{ steps.date.outputs.date }}
draft: false
prerelease: false
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Listing artifacts
run: |
ls artifacts # 不是我 binary 呢让我看看啥情况
- name: Upload Release Assets
run: |
for artifact in artifacts/lintestor-*/*; do
if [ -f "$artifact" ]; then
ls -l "$artifact"
asset_name=$(basename "$artifact")
echo "Uploading $asset_name"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=${asset_name}" \
--data-binary "@$artifact"
else
echo "File $artifact not found, skipping."
fi
done