build2 #3
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
name: build | ||
# ------------- NOTE | ||
# please setup some secrets before running this workflow: | ||
# DOCKER_IMAGE should be the target image name on docker hub (e.g. "rustdesk/rustdesk-server-s6" ) | ||
# DOCKER_USERNAME is the username you normally use to login at https://hub.docker.com/ | ||
# DOCKER_PASSWORD is a token you should create under "account settings / security" with read/write access | ||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-[0-9]+' | ||
- '[0-9]+.[0-9]+.[0-9]+-[0-9]+' | ||
env: | ||
CARGO_TERM_COLOR: always | ||
LATEST_TAG: latest | ||
jobs: | ||
# binary build | ||
build: | ||
name: Build - ${{ matrix.job.name }} | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
job: | ||
- { name: "amd64", target: "x86_64-unknown-linux-musl" } | ||
- { name: "arm64v8", target: "aarch64-unknown-linux-musl" } | ||
- { name: "armv7", target: "armv7-unknown-linux-musleabihf" } | ||
- { name: "i386", target: "i686-unknown-linux-musl" } | ||
- { name: "amd64fb", target: "x86_64-unknown-freebsd" } | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: "1.70.0" | ||
override: true | ||
default: true | ||
components: rustfmt | ||
profile: minimal | ||
target: ${{ matrix.job.target }} | ||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release --all-features --target=${{ matrix.job.target }} | ||
use-cross: true | ||
- name: Exec chmod | ||
run: chmod -v a+x target/${{ matrix.job.target }}/release/* | ||
- name: Publish Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: binaries-linux-${{ matrix.job.name }} | ||
path: | | ||
target/${{ matrix.job.target }}/release/hbbr | ||
target/${{ matrix.job.target }}/release/hbbs | ||
target/${{ matrix.job.target }}/release/rustdesk-utils | ||
if-no-files-found: error | ||
# docker build and push of multiarch images | ||
docker-manifest: | ||
name: Docker manifest | ||
needs: docker | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Log in to Docker Hub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Get git branch name | ||
id: vars | ||
run: | | ||
# Extract the branch name from the GITHUB_REF environment variable | ||
T=${GITHUB_REF#refs/heads/} | ||
echo "BRANCH=$T" >> $GITHUB_ENV | ||
# manifest for :branch tag | ||
- name: Create and push manifest (:major) | ||
uses: Noelware/docker-manifest-action@master | ||
with: | ||
base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.BRANCH }} | ||
# extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.BRANCH }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.BRANCH }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.BRANCH }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.BRANCH }}-i386 | ||
push: true | ||
# manifest for :latest tag | ||
- name: Create and push manifest (:latest) | ||
uses: Noelware/docker-manifest-action@master | ||
with: | ||
base-image: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }} | ||
# extra-images: ${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-amd64,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-arm64v8,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-armv7,${{ secrets.DOCKER_IMAGE }}:${{ env.LATEST_TAG }}-i386 | ||
push: true |