Skip to content

ci: cross-compile aarch64-linux on x86 runner instead of hosted arm p… #8

ci: cross-compile aarch64-linux on x86 runner instead of hosted arm p…

ci: cross-compile aarch64-linux on x86 runner instead of hosted arm p… #8

Workflow file for this run

name: release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build:
name: build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-apple-darwin
os: macos-14
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
steps:
- name: Checkout PRIVATE source repo
uses: actions/checkout@v4
with:
repository: ameyypawar/core-merge-engine
token: ${{ secrets.GITFIX_SOURCE_PAT }}
path: src
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross toolchain (aarch64 Linux)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu cmake
{
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc"
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc"
echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++"
echo "AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar"
} >> "$GITHUB_ENV"
- name: Install build deps (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
- name: Build
working-directory: src
run: cargo build --release --target ${{ matrix.target }} --bin gitfix
- name: Rename gitfix to gfix and tar
working-directory: src
run: |
mv target/${{ matrix.target }}/release/gitfix gfix
tar -czf gfix-${{ github.ref_name }}-${{ matrix.target }}.tar.gz gfix
shasum -a 256 gfix-${{ github.ref_name }}-${{ matrix.target }}.tar.gz > gfix-${{ github.ref_name }}-${{ matrix.target }}.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: gfix-${{ matrix.target }}
path: |
src/gfix-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
src/gfix-${{ github.ref_name }}-${{ matrix.target }}.sha256
release:
name: publish draft release
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Build SHA256SUMS.txt
run: |
cd dist
cat *.sha256 > SHA256SUMS.txt
ls -la
- name: Create draft release on ameyypawar/gfix
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--repo ameyypawar/gfix \
--draft \
--title "gfix ${{ github.ref_name }}" \
--notes "See https://github.com/ameyypawar/gfix-docs/blob/main/changelog.md" \
dist/*.tar.gz dist/SHA256SUMS.txt
npm-publish:
name: publish npm packages
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout gfix repo
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Prepare npm packages
run: |
NPM_VERSION="${{ github.ref_name }}"
NPM_VERSION="${NPM_VERSION#v}"
NPM_VERSION="$NPM_VERSION" TARBALLS_DIR="dist" node npm/scripts/prepare-packages.mjs
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish npm/platforms/darwin-arm64 --tag alpha
npm publish npm/platforms/darwin-x64 --tag alpha
npm publish npm/platforms/linux-x64 --tag alpha
npm publish npm/platforms/linux-arm64 --tag alpha
- name: Publish main package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish npm/cli --tag alpha --access public