Docker cross-compilation github workflow.
This commit is contained in:
parent
01a4f68e20
commit
11d230f95a
8 changed files with 270 additions and 154 deletions
120
.github/workflows/release-linux.yml
vendored
Normal file
120
.github/workflows/release-linux.yml
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
name: Release binaries for Linux and Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
build-docker-cross:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
platform: [linux/arm/v7, linux/amd64, linux/arm64]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
id: builder1
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v4
|
||||
id: cache
|
||||
with:
|
||||
path: |
|
||||
usr-local-cargo-git-db
|
||||
usr-local-cargo-registry-cache
|
||||
usr-local-cargo-registry-index
|
||||
src-target
|
||||
key: docker-xx-v1-${{ matrix.platform }}-release
|
||||
save-always: true
|
||||
|
||||
- name: inject cache into docker
|
||||
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
|
||||
with:
|
||||
cache-map: |
|
||||
{
|
||||
"usr-local-cargo-git-db": "/usr/local/cargo/git/db",
|
||||
"usr-local-cargo-registry-cache": "/usr/local/cargo/registry/cache",
|
||||
"usr-local-cargo-registry-index": "/usr/local/cargo/registry/index",
|
||||
"src-target": "/src/target"
|
||||
}
|
||||
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
|
||||
|
||||
- name: cross-compile the binary
|
||||
run: |
|
||||
set -e
|
||||
|
||||
mkdir -p target/cross
|
||||
docker buildx ls
|
||||
|
||||
mkdir -p target/cross/${{ matrix.platform }}
|
||||
docker build --builder ${{ steps.builder1.outputs.name }} \
|
||||
--platform ${{ matrix.platform }} \
|
||||
-f docker/Dockerfile.xx \
|
||||
--output type=local,dest=target/cross/${{ matrix.platform }} ./
|
||||
|
||||
- name: list files
|
||||
run: find target/cross/
|
||||
|
||||
- name: generate-archive-key
|
||||
id: gen_artifact_key
|
||||
run: |
|
||||
echo "key=$(echo ${{ matrix.platform }} | tr '/' '-')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: copy binary for release
|
||||
run: |
|
||||
cd target/cross
|
||||
cp -l ${{ matrix.platform }}/arm/v7/rqbit rqbit-${{ steps.gen_artifact_key.outputs.key }}
|
||||
|
||||
- uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
target/cross/rqbit-${{ steps.gen_artifact_key.outputs.key }}
|
||||
|
||||
- name: Archive target/cross/
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ steps.gen_artifact_key.outputs.key }}
|
||||
path: target/cross/${{ matrix.platform }}/rqbit
|
||||
|
||||
build-push-docker-multiarch:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-docker-cross
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-arm-v7
|
||||
path: target/cross/linux/arm/v7/rqbit
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-arm64
|
||||
path: target/cross/linux/arm64/rqbit
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-amd64
|
||||
path: target/cross/linux/amd64/rqbit
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: ikatson/rqbit:${{ github.ref_name }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
context: target/cross/
|
||||
file: docker/Dockerfile
|
||||
Loading…
Add table
Add a link
Reference in a new issue