[#8] gh actions to release #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
env: | |
PROJECT_NAME: gitnote | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ${{ matrix.runner }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: linux-amd64 | |
runner: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
libName: libgitnote.so | |
- name: win-amd64 | |
runner: windows-latest | |
target: x86_64-pc-windows-msvc | |
libName: libgitnote.dll | |
- name: macos-amd64 | |
runner: macos-latest | |
target: x86_64-apple-darwin | |
libName: libgitnote.dylib | |
- name: macos-arm64 | |
runner: macos-latest | |
target: aarch64-apple-darwin | |
libName: libgitnote.dylib | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Build Binary | |
working-directory: ./gitnote-core | |
run: cargo build --lib --verbose --locked --release --target ${{ matrix.target }} | |
- name: Run tests | |
working-directory: ./gitnote-core | |
run: cargo test --lib --verbose | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}_${{ matrix.libName }} | |
path: ./gitnote-core/target/${{ matrix.target }}/release/${{ matrix.libName }} | |
collect: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./libs | |
- name: list libs | |
run: ls -lR ./libs | |
- name: Move artifacts to resources | |
run: | | |
directory="libs" | |
for file in "$directory"/*; do | |
filename=$(basename "$file") | |
IFS='_' read -r dirname _ <<< "$filename" | |
echo "filename: $filename" | |
echo "dirname: $dirname" | |
echo "file: $file" | |
mkdir -p "./gitnote-jetbrains/src/main/resources/core/$dirname/$filename" | |
cp "$file" "./gitnote-jetbrains/src/main/resources/core/$dirname/$filename" | |
echo "Copied $file to ./$dirname/$filename/" | |
done | |
- name: list resources | |
run: ls -lR ./gitnote-jetbrains/src/main/resources/core/ | |
- name: Build JAR | |
run: ./gradlew build |