Skip to content

Commit f0c41fa

Browse files
committed
Refactored entire scripts for GitHub
1 parent 7ce712e commit f0c41fa

File tree

3 files changed

+39
-65
lines changed

3 files changed

+39
-65
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ name: Build and Upload Artifacts
22

33
on:
44
workflow_run:
5-
workflows: ["Rust Build & Test"]
6-
types: [completed]
5+
workflows: [ "Rust Build & Test" ]
6+
types: [ completed ]
77

88
jobs:
99
build:
10+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1011
runs-on: ${{ matrix.os }}
1112
strategy:
1213
matrix:
@@ -28,14 +29,20 @@ jobs:
2829
- name: Checkout repository
2930
uses: actions/checkout@v4
3031

31-
- name: Package binary and resources
32+
- name: Install Rust target
33+
run: rustup target add ${{ matrix.target }}
34+
35+
- name: Build binary
36+
run: cargo build --release --target ${{ matrix.target }}
37+
38+
- name: Package binary
3239
shell: bash
3340
run: |
3441
mkdir -p release_artifacts/${{ matrix.target }}
3542
cd target/${{ matrix.target }}/release
3643
mkdir -p rfortune-${{ matrix.target }}
3744
cp rfortune rfortune-${{ matrix.target }}/ 2>/dev/null || cp rfortune.exe rfortune-${{ matrix.target }}/
38-
cp $GITHUB_WORKSPACE/README.md $GITHUB_WORKSPACE/CHANGELOG.md $GITHUB_WORKSPACE/LICENSE rfortune-${{ matrix.target }}/
45+
cp $GITHUB_WORKSPACE/{README.md,LICENSE,CHANGELOG.md} rfortune-${{ matrix.target }}/
3946
4047
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
4148
powershell -Command "Compress-Archive -Path rfortune-${{ matrix.target }} -DestinationPath rfortune-${{ matrix.target }}.zip"
@@ -65,7 +72,6 @@ jobs:
6572
run: |
6673
cd release_artifacts/${{ matrix.target }}
6774
file="rfortune-${{ matrix.target }}.${{ matrix.ext }}"
68-
6975
echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import
7076
7177
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 \
@@ -77,9 +83,8 @@ jobs:
7783

7884
upload-artifacts:
7985
name: Upload All Artifacts
80-
runs-on: ubuntu-latest
8186
needs: build
82-
if: ${{ always() }}
87+
runs-on: ubuntu-latest
8388
steps:
8489
- name: Checkout repository
8590
uses: actions/checkout@v4
@@ -97,19 +102,13 @@ jobs:
97102
path: temp_download
98103
merge-multiple: true
99104

100-
- name: DEBUG - verifica cosa è stato scaricato
101-
shell: bash
102-
run: |
103-
echo "[DEBUG] Contenuto di temp_download:"
104-
find temp_download || echo "temp_download è vuota o non trovata"
105-
106-
- name: Move all platform builds into one folder
105+
- name: Consolidate all artifacts
107106
shell: bash
108107
run: |
109-
mkdir release_artifacts
110-
find temp_download -type f -name "rfortune-*" -exec cp {} release_artifacts/ \;
108+
mkdir -p release_artifacts
109+
find temp_download -type f -exec cp {} release_artifacts/ \;
111110
112-
- name: Upload combined artifacts for release
111+
- name: Upload for Release
113112
uses: actions/upload-artifact@v4
114113
with:
115114
name: release_artifacts

.github/workflows/release.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,28 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Checkout Repository
14+
- name: Checkout repository
1515
uses: actions/checkout@v4
1616

17-
- name: DEBUG — Info evento e run
18-
run: |
19-
echo "Workflow triggering this run:"
20-
echo "Workflow name: ${{ github.event.workflow.name }}"
21-
echo "Workflow run ID: ${{ github.event.workflow_run.id }}"
22-
23-
- name: Download Combined Artifacts
17+
- name: Download release artifacts
2418
uses: actions/download-artifact@v4
2519
with:
26-
run-id: ${{ github.event.workflow_run.id }}
20+
name: release_artifacts
2721
path: release_artifacts
28-
merge-multiple: true
2922

30-
- name: DEBUGControllo contenuto release_artifacts
23+
- name: Debuglista file scaricati
3124
shell: bash
3225
run: |
33-
echo "[DEBUG] Verifica contenuto dopo il download:"
34-
ls -l release_artifacts || echo "release_artifacts non trovata"
35-
find release_artifacts || echo "nessun file scaricato"
26+
echo "Contenuto scaricato:"
27+
find release_artifacts || echo "Nessun file trovato"
3628
3729
- name: Estrai versione da Cargo.toml
3830
id: extract_version
3931
run: |
4032
VERSION=$(grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2)
4133
echo "version=$VERSION" >> $GITHUB_OUTPUT
4234
43-
- name: Crea release GitHub
35+
- name: Crea GitHub Release
4436
uses: softprops/action-gh-release@v1
4537
with:
4638
tag_name: v${{ steps.extract_version.outputs.version }}
@@ -55,4 +47,4 @@ jobs:
5547

5648
- name: Cleanup
5749
if: always()
58-
run: rm -rf release_artifacts/
50+
run: rm -rf release_artifacts

.github/workflows/rust.yml

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,27 @@ name: Rust Build & Test
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ "main" ]
8-
9-
env:
10-
CARGO_TERM_COLOR: always
7+
workflow_dispatch:
118

129
jobs:
13-
build-test:
14-
runs-on: ${{ matrix.os }}
15-
strategy:
16-
matrix:
17-
os: [ubuntu-latest, windows-latest, macos-latest]
18-
10+
check:
11+
name: Lint & Test
12+
runs-on: ubuntu-latest
13+
1914
steps:
20-
- name: Checkout repository
15+
- name: Checkout
2116
uses: actions/checkout@v4
22-
17+
2318
- name: Install Rust
2419
uses: dtolnay/rust-toolchain@stable
25-
26-
- name: Cache Cargo registry
27-
uses: actions/cache@v3
28-
with:
29-
path: |
30-
~/.cargo/registry
31-
~/.cargo/git
32-
target
33-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
34-
35-
- name: Format check
20+
21+
- name: Format Check
3622
run: cargo fmt --all -- --check
37-
38-
- name: Clippy (linter)
23+
24+
- name: Clippy Check
3925
run: cargo clippy --all-targets --all-features -- -D warnings
40-
41-
- name: Build
42-
run: cargo build --release
43-
44-
- name: Run tests
45-
run: cargo test --verbose
26+
27+
- name: Run Tests
28+
run: cargo test --all

0 commit comments

Comments
 (0)