Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ name: Build and Upload Artifacts

on:
workflow_run:
workflows: ["Rust Build & Test"]
types: [completed]
workflows: [ "Rust Build & Test" ]
types: [ completed ]

jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -28,14 +29,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Package binary and resources
- name: Install Rust target
run: rustup target add ${{ matrix.target }}

- name: Build binary
run: cargo build --release --target ${{ matrix.target }}

- name: Package binary
shell: bash
run: |
mkdir -p release_artifacts/${{ matrix.target }}
cd target/${{ matrix.target }}/release
mkdir -p rfortune-${{ matrix.target }}
cp rfortune rfortune-${{ matrix.target }}/ 2>/dev/null || cp rfortune.exe rfortune-${{ matrix.target }}/
cp $GITHUB_WORKSPACE/README.md $GITHUB_WORKSPACE/CHANGELOG.md $GITHUB_WORKSPACE/LICENSE rfortune-${{ matrix.target }}/
cp $GITHUB_WORKSPACE/{README.md,LICENSE,CHANGELOG.md} rfortune-${{ matrix.target }}/

if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
powershell -Command "Compress-Archive -Path rfortune-${{ matrix.target }} -DestinationPath rfortune-${{ matrix.target }}.zip"
Expand Down Expand Up @@ -65,7 +72,6 @@ jobs:
run: |
cd release_artifacts/${{ matrix.target }}
file="rfortune-${{ matrix.target }}.${{ matrix.ext }}"

echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import

echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 \
Expand All @@ -77,9 +83,8 @@ jobs:

upload-artifacts:
name: Upload All Artifacts
runs-on: ubuntu-latest
needs: build
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -97,19 +102,13 @@ jobs:
path: temp_download
merge-multiple: true

- name: DEBUG - verifica cosa è stato scaricato
shell: bash
run: |
echo "[DEBUG] Contenuto di temp_download:"
find temp_download || echo "temp_download è vuota o non trovata"

- name: Move all platform builds into one folder
- name: Consolidate all artifacts
shell: bash
run: |
mkdir release_artifacts
find temp_download -type f -name "rfortune-*" -exec cp {} release_artifacts/ \;
mkdir -p release_artifacts
find temp_download -type f -exec cp {} release_artifacts/ \;

- name: Upload combined artifacts for release
- name: Upload for Release
uses: actions/upload-artifact@v4
with:
name: release_artifacts
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
- name: Checkout repository
uses: actions/checkout@v4

- name: DEBUG — Info evento e run
run: |
echo "Workflow triggering this run:"
echo "Workflow name: ${{ github.event.workflow.name }}"
echo "Workflow run ID: ${{ github.event.workflow_run.id }}"

- name: Download Combined Artifacts
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
run-id: ${{ github.event.workflow_run.id }}
name: release_artifacts
path: release_artifacts
merge-multiple: true

- name: DEBUGControllo contenuto release_artifacts
- name: Debuglista file scaricati
shell: bash
run: |
echo "[DEBUG] Verifica contenuto dopo il download:"
ls -l release_artifacts || echo "release_artifacts non trovata"
find release_artifacts || echo "nessun file scaricato"
echo "Contenuto scaricato:"
find release_artifacts || echo "Nessun file trovato"

- name: Estrai versione da Cargo.toml
id: extract_version
run: |
VERSION=$(grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Crea release GitHub
- name: Crea GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.extract_version.outputs.version }}
Expand All @@ -55,4 +47,4 @@ jobs:

- name: Cleanup
if: always()
run: rm -rf release_artifacts/
run: rm -rf release_artifacts
47 changes: 15 additions & 32 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,27 @@ name: Rust Build & Test

on:
push:
branches: [ "main" ]
branches: [ main ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
workflow_dispatch:

jobs:
build-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

check:
name: Lint & Test
runs-on: ubuntu-latest

steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Format check

- name: Format Check
run: cargo fmt --all -- --check
- name: Clippy (linter)

- name: Clippy Check
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Build
run: cargo build --release

- name: Run tests
run: cargo test --verbose

- name: Run Tests
run: cargo test --all