diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e1de88..0a44a1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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" @@ -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 \ @@ -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 @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d56d506..03ee242 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,28 +11,20 @@ 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: DEBUG — Controllo contenuto release_artifacts + - name: Debug — lista 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 @@ -40,7 +32,7 @@ jobs: 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 }} @@ -55,4 +47,4 @@ jobs: - name: Cleanup if: always() - run: rm -rf release_artifacts/ + run: rm -rf release_artifacts diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c688cf3..c07d42d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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