Skip to content

fix: explicitly add rustup target for cross-compilation #4

fix: explicitly add rustup target for cross-compilation

fix: explicitly add rustup target for cross-compilation #4

Workflow file for this run

name: release
on:
push:
tags: ["v*"]
permissions:
contents: write
packages: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: ember-server-linux-amd64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: ember-server-linux-arm64
- target: x86_64-apple-darwin
os: macos-latest
artifact: ember-server-darwin-amd64
- target: aarch64-apple-darwin
os: macos-latest
artifact: ember-server-darwin-arm64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: add cross-compilation target
run: rustup target add ${{ matrix.target }}
- name: install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: build
run: cargo build --release --target ${{ matrix.target }}
- name: package
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/ember-server dist/${{ matrix.artifact }}
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}
docker:
name: docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: extract version
id: version
run: echo "tag=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: set up docker buildx
uses: docker/setup-buildx-action@v3
- name: login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.tag }}
ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
release:
name: github release
runs-on: ubuntu-latest
needs: [build, docker]
steps:
- uses: actions/checkout@v4
- name: download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: collect binaries
run: |
mkdir -p release
find artifacts -type f -name 'ember-server-*' -exec cp {} release/ \;
cd release && sha256sum * > checksums.txt
- name: create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: release/*