Skip to content

CI fixes

CI fixes #501

Workflow file for this run

name: Quick check crates
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ published ]
env:
version: ${{ github.event.release.tag_name || github.head_ref }}
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
clippy_check:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get -y install fuse3 libfuse3-dev
- uses: actions/checkout@v1
- uses: Swatinem/rust-cache@v2.4.0
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
build:
strategy:
matrix:
name: [
linux,
macos,
macos-m1,
windows
]
include:
- name: linux
os: ubuntu-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-linux-x86_64
target: x86_64-unknown-linux-musl
cross: true
- name: macos
os: macos-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-macos-x86_64
target: x86_64-apple-darwin
cross: false
- name: macos-m1
os: macos-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-macos-aarch64
target: aarch64-apple-darwin
cross: true
- name: windows
os: windows-latest
asset_name: 0s-${{ github.event.release.tag_name || github.head_ref }}-windows-x86_64.exe
target: x86_64-pc-windows-msvc
cross: false
rust:
- 1.70.0 # MSRV
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v2.4.0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
target: ${{ matrix.target }}
- name: Install deps
if: matrix.os == 'macos-latest'
run: brew install macfuse
- name: Test
if: matrix.target != 'aarch64-apple-darwin' || matrix.target != 'x86_64-pc-windows-msvc'
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
args: --locked --target ${{ matrix.target }} --release
command: test
- name: Test
if: matrix.target == 'x86_64-pc-windows-msvc'
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
args: --locked --target ${{ matrix.target }} --release -p zerostash -p zerostash-files
command: test
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
args: --locked --target ${{ matrix.target }} --release
command: build
- name: Upload binaries
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.asset_name }}
path: "target/${{ matrix.target }}/release/0s${{ matrix.os == 'windows-latest' && '.exe' || '' }}"
release:
runs-on: ubuntu-latest
needs: [build, security_audit]
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bin
- name: Package artifacts
run: |
set -e
cd bin
for dir in 0s-*-linux-* 0s-*-macos-*; do
(cd $dir;
echo $dir
tar czf $dir.tar.gz 0s;
sha256sum $dir.tar.gz
)
done
- name: Attach binaries to release
uses: actions/github-script@v6
with:
script: |
const fs = require('fs/promises');
const path = require('path');
const {owner, repo} = context.repo;
const release_id = context.payload.release.id;
const artifacts = await fs.readdir('bin/');
for (dir of artifacts) {
const files = await fs.readdir(`bin/${dir}`);
for (file of files) {
if (file === '0s') {
continue;
}
var file_name = file;
if (file === '0s.exe') {
file_name = `${dir}.exe`;
}
console.log(`Uploading ${dir}/${file} as ${file_name} for release ${release_id}`);
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id,
name: file_name,
data: await fs.readFile(`bin/${dir}/${file}`),
});
// only upload the first file
// there shouldn't be more anyway
break;
}
}