Merge branch 'main' of https://github.com/harilvfs/rdevs #10
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: Build Rust Release | |
on: | |
pull_request: | |
paths: | |
- '**/*.rs' | |
- 'Cargo.toml' | |
- 'src/main.rs' | |
push: | |
branches: | |
- main | |
paths: | |
- '**/*.rs' | |
- 'Cargo.toml' | |
- 'src/main.rs' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Build release binary | |
run: | | |
cargo build --release || { echo "Build failed"; exit 1; } | |
if [ -f target/release/rdevs ]; then | |
mkdir -p build | |
mv target/release/rdevs ./build/rdevs | |
else | |
echo "Binary not found. Build may have failed." | |
exit 1 | |
fi | |
rm -rf target/release | |
- name: List build artifacts | |
run: ls ./build | |
- name: Commit and push the build directory | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add build/rdevs | |
git commit -m "Update build directory with new binary" || echo "No changes to commit" | |
git push https://x-access-token:${GITHUB_TOKEN}@github.com/harilvfs/rdevs.git HEAD:main || echo "Push failed. Check permissions." |