Skip to content

Add a convenient public API (#74) #196

Add a convenient public API (#74)

Add a convenient public API (#74) #196

Workflow file for this run

on:
pull_request: {}
push:
branches:
- master
tags: [ 'v*.*.*' ]
name: CI
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Check that Cargo.lock is up-to-date
run: cargo metadata --format-version 1 --locked
- name: Run cargo fmt
run: cargo fmt --check
- name: Run cargo clippy
run: cargo clippy -- -D warnings
- name: Run cargo check
run: cargo check
test:
strategy:
matrix:
runner: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Run cargo test
run: cargo test
update-release-draft:
runs-on: ubuntu-latest
if: github.repository == 'coralogix/protofetch' && github.ref == 'refs/heads/master'
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package-linux:
runs-on: ubuntu-latest
needs: [ lint, test ]
strategy:
fail-fast: false
matrix:
target: [ aarch64-unknown-linux-musl, x86_64-unknown-linux-musl ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross
run: |
cargo install --locked cross
- name: Build
run: cross build --release --target ${{ matrix.target }} --features vendored-openssl,vendored-libgit2
- name: Package
run: |
mv target/${{ matrix.target }}/release bin/
tar -czvf protofetch_${{ matrix.target }}.tar.gz bin/protofetch
- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
protofetch_${{ matrix.target }}.tar.gz
package-mac:
runs-on: macos-latest
needs: [ lint, test ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Build
run: |
cargo build --release
- name: Package
run: |
mv target/release bin/
tar -czvf protofetch_darwin_amd64.tar.gz bin/protofetch
- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
protofetch_darwin_amd64.tar.gz
package-windows:
runs-on: windows-latest
needs: [ lint, test ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Build
run: |
cargo build --release
- name: Package
run: |
mv target/release bin/
tar -czvf protofetch_win64.tar.gz bin/protofetch.exe
- name: Upload
uses: actions/upload-artifact@v3
with:
path: |
protofetch_win64.tar.gz
release:
runs-on: ubuntu-latest
if: github.repository == 'coralogix/protofetch' && startsWith(github.ref, 'refs/tags/')
needs: [ package-linux, package-mac, package-windows ]
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Publish cargo package
run: cargo publish --token ${{ env.CRATES_IO_TOKEN }}
- name: Publish npm package
run: |
VERSION=$(sed -n -e '/version/ s/.* = *//p' "Cargo.toml" | head -1 | tr -d '"')
export VERSION
# Tee had issue to write to the same file which is used for read so creating a temp package.json file
mv .github/npm/package.json .github/npm/package.json.temp
sed "s/VERSION#TO#REPLACE/${VERSION}/g" .github/npm/package.json.temp | tee .github/npm/package.json
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ".npmrc"
npm publish .github/npm
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Upload release artifacts
uses: softprops/action-gh-release@v1
with:
files: |
protofetch_aarch64-unknown-linux-musl.tar.gz
protofetch_x86_64-unknown-linux-musl.tar.gz
protofetch_darwin_amd64.tar.gz
protofetch_win64.tar.gz