|
1 | | -name: CI |
| 1 | +name: CI & Release |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [main, develop] |
| 5 | + branches: [main] |
6 | 6 | pull_request: |
7 | | - branches: [main, develop] |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +env: |
| 10 | + RUST_VERSION: stable |
| 11 | + CARGO_TERM_COLOR: always |
8 | 12 |
|
9 | 13 | jobs: |
| 14 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 15 | + # LINT |
| 16 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 17 | + fmt: |
| 18 | + name: Format |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - uses: dtolnay/rust-toolchain@stable |
| 23 | + with: |
| 24 | + components: rustfmt |
| 25 | + - name: Check formatting |
| 26 | + run: cargo fmt --all -- --check |
| 27 | + |
| 28 | + clippy: |
| 29 | + name: Clippy |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - uses: dtolnay/rust-toolchain@stable |
| 34 | + with: |
| 35 | + components: clippy |
| 36 | + - name: Run clippy |
| 37 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 38 | + |
| 39 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 40 | + # TEST |
| 41 | + # ═══════════════════════════════════════════════════════════════════════════════ |
10 | 42 | test: |
| 43 | + name: Test |
11 | 44 | runs-on: ubuntu-latest |
12 | 45 | steps: |
13 | 46 | - uses: actions/checkout@v4 |
14 | | - - name: Setup Rust |
15 | | - uses: dtolnay/rust-toolchain@stable |
| 47 | + - uses: dtolnay/rust-toolchain@stable |
16 | 48 | - name: Run tests |
17 | | - run: cargo test |
| 49 | + run: cargo test --all-features |
18 | 50 |
|
19 | | - build: |
| 51 | + security: |
| 52 | + name: Security |
20 | 53 | runs-on: ubuntu-latest |
21 | 54 | steps: |
22 | 55 | - uses: actions/checkout@v4 |
| 56 | + - name: Run security audit |
| 57 | + uses: rustsec/audit-check@v2.0.0 |
| 58 | + with: |
| 59 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 62 | + # BUILD |
| 63 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 64 | + build: |
| 65 | + name: Build (${{ matrix.target }}) |
| 66 | + needs: [fmt, clippy, test, security] |
| 67 | + runs-on: ${{ matrix.os }} |
| 68 | + strategy: |
| 69 | + fail-fast: false |
| 70 | + matrix: |
| 71 | + include: |
| 72 | + - os: ubuntu-latest |
| 73 | + target: x86_64-unknown-linux-gnu |
| 74 | + binary: git-reports |
| 75 | + ext: '' |
| 76 | + - os: ubuntu-latest |
| 77 | + target: aarch64-unknown-linux-gnu |
| 78 | + binary: git-reports |
| 79 | + ext: '' |
| 80 | + - os: macos-latest |
| 81 | + target: x86_64-apple-darwin |
| 82 | + binary: git-reports |
| 83 | + ext: '' |
| 84 | + - os: windows-latest |
| 85 | + target: x86_64-pc-windows-msvc |
| 86 | + binary: git-reports.exe |
| 87 | + ext: .exe |
| 88 | + |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@v4 |
| 91 | + |
23 | 92 | - name: Setup Rust |
24 | 93 | uses: dtolnay/rust-toolchain@stable |
25 | | - - name: Build |
26 | | - run: cargo build --release |
| 94 | + with: |
| 95 | + targets: ${{ matrix.target }} |
| 96 | + |
| 97 | + - name: Build release |
| 98 | + run: cargo build --release --locked |
| 99 | + |
| 100 | + - name: Create package |
| 101 | + run: | |
| 102 | + mkdir -p release |
| 103 | + cp target/release/${{ matrix.binary }} release/${{ matrix.binary }} |
| 104 | +
|
| 105 | + - name: Upload artifact |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: ${{ matrix.binary }}-${{ matrix.target }} |
| 109 | + path: release/${{ matrix.binary }} |
| 110 | + retention-days: 5 |
| 111 | + |
| 112 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 113 | + # RELEASE |
| 114 | + # ═══════════════════════════════════════════════════════════════════════════════ |
| 115 | + release: |
| 116 | + name: Release |
| 117 | + needs: build |
| 118 | + runs-on: ubuntu-latest |
| 119 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 120 | + |
| 121 | + steps: |
| 122 | + - name: Download all artifacts |
| 123 | + uses: actions/download-artifact@v4 |
| 124 | + with: |
| 125 | + path: artifacts |
| 126 | + pattern: '*' |
| 127 | + merge-multiple: true |
| 128 | + |
| 129 | + - name: Generate checksum |
| 130 | + run: | |
| 131 | + cd artifacts |
| 132 | + sha256sum * > SHA256SUMS.txt |
| 133 | + cat SHA256SUMS.txt |
| 134 | +
|
| 135 | + - name: Determine version |
| 136 | + id: version |
| 137 | + run: | |
| 138 | + VERSION="v1.0.$(date +%Y%m%d%H%M%S)" |
| 139 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 140 | + echo "Creating release: $VERSION" |
| 141 | +
|
| 142 | + - name: Create Release |
| 143 | + uses: softprops/action-gh-release@v2 |
| 144 | + with: |
| 145 | + name: ${{ steps.version.outputs.version }} |
| 146 | + draft: false |
| 147 | + prerelease: false |
| 148 | + generate_release_notes: true |
| 149 | + files: | |
| 150 | + artifacts/* |
| 151 | + body: | |
| 152 | + ## 📦 Executables |
| 153 | +
|
| 154 | + Download the executable for your platform: |
| 155 | +
|
| 156 | + | Platform | File | |
| 157 | + |----------|------| |
| 158 | + | Linux x64 | `git-reports-x86_64-unknown-linux-gnu` | |
| 159 | + | Linux ARM64 | `git-reports-aarch64-unknown-linux-gnu` | |
| 160 | + | macOS x64 | `git-reports-x86_64-apple-darwin` | |
| 161 | + | Windows x64 | `git-reports.exe` | |
| 162 | +
|
| 163 | + ## 🔒 Checksums |
| 164 | +
|
| 165 | + Verify the integrity of your download: |
| 166 | +
|
| 167 | + ``` |
| 168 | + $(cat artifacts/SHA256SUMS.txt) |
| 169 | + ``` |
| 170 | +
|
| 171 | + ## 🚀 Usage |
| 172 | +
|
| 173 | + ```bash |
| 174 | + # Create config.yaml in the same directory as the executable |
| 175 | + ./git-reports |
| 176 | + ``` |
| 177 | +
|
| 178 | + See [README](https://github.com/madkoding/git-reports#readme) for configuration. |
| 179 | + env: |
| 180 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments