Skip to content

ci

ci #1753

Workflow file for this run

name: ci
on:
pull_request:
push:
branches: ['master']
tags: ['v*']
schedule:
- cron: '00 01 * * *'
jobs:
build:
name: build
env:
CARGO: cargo
FEATURES:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build:
- aarch64-unknown-linux-gnu
- arm-unknown-linux-gnueabi
- armv7-unknown-linux-gnueabihf
- powerpc64-unknown-linux-gnu
- i686-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
include:
- build: aarch64-unknown-linux-gnu
os: ubuntu-latest
run_test: 'false'
- build: arm-unknown-linux-gnueabi
os: ubuntu-latest
run_test: 'false'
- build: armv7-unknown-linux-gnueabihf
os: ubuntu-latest
run_test: 'false'
- build: powerpc64-unknown-linux-gnu
os: ubuntu-latest
run_test: 'false'
- build: i686-unknown-linux-gnu
os: ubuntu-latest
- build: x86_64-unknown-linux-musl
os: ubuntu-latest
- build: x86_64-apple-darwin
os: macos-12
- build: aarch64-apple-darwin
os: macos-14
- build: x86_64-pc-windows-msvc
os: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set target environment
shell: bash
run: |
echo "TARGET_TRIPLE=${{ matrix.build }}" >> $GITHUB_ENV
echo "TARGET_FLAG=--target ${{ matrix.build }}" >> $GITHUB_ENV
- name: Setup cross compilation (linux)
if: matrix.os == 'ubuntu-latest'
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "FEATURES=--features vendored-openssl" >> $GITHUB_ENV
- name: Setup cross compilation (non-linux)
if: matrix.os != 'ubuntu-latest'
run: rustup target add ${{ env.TARGET_TRIPLE }}
- name: Build
run: ${{ env.CARGO }} build ${{ env.FEATURES }} --verbose ${{ env.TARGET_FLAG }}
- name: Tests
if: matrix.run_test != 'false'
run: ${{ env.CARGO }} test ${{ env.FEATURES }} --verbose ${{ env.TARGET_FLAG }}
- name: Release Build
run: ${{ env.CARGO }} build --release ${{ env.FEATURES }} --verbose ${{ env.TARGET_FLAG }}
- name: Build deb
if: matrix.build == 'x86_64-unknown-linux-musl'
run: |
cargo install cargo-deb
${{ env.CARGO }} build ${{ env.FEATURES }} --all --release ${{ env.TARGET_FLAG }}
cargo deb --no-build ${{ env.TARGET_FLAG }}
- name: Stage Release
shell: bash
run: |
VERSION="${GITHUB_REF#refs/tags/}"
if [[ "$VERSION" = refs* ]]; then
VERSION="-nightly"
fi
echo "version is $VERSION"
STAGING="dness-${VERSION:1}-$TARGET_TRIPLE"
echo "STAGING DIR: $STAGING"
mkdir $STAGING
if [[ "${{ matrix.os }}" = windows* ]]; then
cp "target/$TARGET_TRIPLE/release/dness.exe" "$STAGING/"
7z a "$STAGING.zip" "$STAGING"
echo "ASSET=$STAGING.zip" >> $GITHUB_ENV
else
strip "target/$TARGET_TRIPLE/release/dness" || true
cp "target/$TARGET_TRIPLE/release/dness" "$STAGING/"
tar czf "$STAGING.tar.gz" "$STAGING"
echo "ASSET=$STAGING.tar.gz" >> $GITHUB_ENV
fi
- uses: actions/upload-artifact@v4
with:
path: ${{ env.ASSET }}
name: ${{ env.ASSET }}
if-no-files-found: error
- name: compute deb package name
if: matrix.build == 'x86_64-unknown-linux-musl'
run: echo "ASSET=$(basename target/${{ env.TARGET_TRIPLE}}/debian/*.deb)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
if: matrix.build == 'x86_64-unknown-linux-musl'
with:
path: target/${{ env.TARGET_TRIPLE}}/debian/*.deb
name: ${{ env.ASSET }}
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts-temp
- name: Flatten artifacts
run: |
mkdir artifacts
find artifacts-temp -type f -exec cp '{}' artifacts/ \;
ls -lR artifacts
- name: Create Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const tag_name = process.env.GITHUB_REF.split("/")[2];
const release = await github.rest.repos.createRelease({
owner, repo,
tag_name,
draft: false,
target_commitish: sha
});
console.log('created release', { release });
for (let file of await fs.readdir('artifacts')) {
console.log('uploading', file);
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`artifacts/${file}`)
});
}