name: ci
on:
push:
branches:
- main
- dev
tags:
- "v[0-9]+.[0-9]+.[0-9]+**"
jobs:
build-and-test:
name: Build & Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [linux, linux-arm, macos]
include:
- build: linux
os: ubuntu-22.04
rust: nightly
target: x86_64-unknown-linux-musl
- build: linux-arm
os: ubuntu-22.04
rust: nightly
target: arm-unknown-linux-gnueabihf
- build: macos
os: macos-12
rust: nightly
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v3
- run: |
TARGET_DIR=./target/${{ matrix.target }}
echo "TARGET_DIR=$TARGET_DIR" >> $GITHUB_ENV
echo "BINFILE=$TARGET_DIR/release/git-nu" >> $GITHUB_ENV
- name: Set CI git user
run: |
git config --global user.name gitnu-ci
git config --global user.email ci@gitnu.com
- name: Run tests
run: make ci-test
- name: Build binary
run: make ci-build
env:
CARGO_BUILD_TARGET_DIR: ${{ env.TARGET_DIR }}
- name: Strip release binary
if: >-
github.ref_type == 'tag' &&
(matrix.build == 'linux' || matrix.build == 'linux-arm' || matrix.build == 'macos')
run: strip ${{ env.BINFILE }}
- name: Build archive
if: github.ref_type == 'tag'
run: |
STAGING="git-nu-${{ env.SEMVER }}-${{ matrix.target }}"
mkdir -p "$STAGING"
cp ${{ env.BINFILE }} "$STAGING"
tar czf "$STAGING.tar.gz" "$STAGING"
echo "ASSET=$STAGING.tar.gz" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: ${{ env.ASSET }}
release:
name: Release
if: github.ref_type != 'tag'
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get git tags
run: git fetch --tags origin
- name: Set CI git user
run: |
git config --global user.name gitnu-ci
git config --global user.email ci@gitnu.com
- name: Increment prerelease version number
run: make ci-version
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}