|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test Suite |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + submodules: recursive |
| 19 | + |
| 20 | + - name: Install Rust |
| 21 | + uses: dtolnay/rust-toolchain@stable |
| 22 | + with: |
| 23 | + components: rustfmt, clippy |
| 24 | + |
| 25 | + - name: Cache cargo registry |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: ~/.cargo/registry |
| 29 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 30 | + |
| 31 | + - name: Cache cargo index |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: ~/.cargo/git |
| 35 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 36 | + |
| 37 | + - name: Cache cargo build |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: target |
| 41 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} |
| 42 | + |
| 43 | + - name: Check formatting |
| 44 | + run: cargo fmt --all -- --check |
| 45 | + |
| 46 | + - name: Run clippy |
| 47 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 48 | + |
| 49 | + - name: Build |
| 50 | + run: cargo build --verbose |
| 51 | + |
| 52 | + - name: Run tests |
| 53 | + run: cargo test --verbose |
| 54 | + |
| 55 | + - name: Run tests with all features |
| 56 | + run: cargo test --all-features --verbose |
| 57 | + |
| 58 | + build: |
| 59 | + name: Build Release Binaries |
| 60 | + needs: test |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + strategy: |
| 63 | + matrix: |
| 64 | + include: |
| 65 | + - os: ubuntu-latest |
| 66 | + target: x86_64-unknown-linux-gnu |
| 67 | + artifact_name: submod |
| 68 | + asset_name: submod-linux-x86_64 |
| 69 | + - os: ubuntu-latest |
| 70 | + target: x86_64-unknown-linux-musl |
| 71 | + artifact_name: submod |
| 72 | + asset_name: submod-linux-x86_64-musl |
| 73 | + - os: windows-latest |
| 74 | + target: x86_64-pc-windows-msvc |
| 75 | + artifact_name: submod.exe |
| 76 | + asset_name: submod-windows-x86_64.exe |
| 77 | + - os: macos-latest |
| 78 | + target: x86_64-apple-darwin |
| 79 | + artifact_name: submod |
| 80 | + asset_name: submod-macos-x86_64 |
| 81 | + - os: macos-latest |
| 82 | + target: aarch64-apple-darwin |
| 83 | + artifact_name: submod |
| 84 | + asset_name: submod-macos-aarch64 |
| 85 | + |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + with: |
| 89 | + submodules: recursive |
| 90 | + |
| 91 | + - name: Install Rust |
| 92 | + uses: dtolnay/rust-toolchain@stable |
| 93 | + with: |
| 94 | + targets: ${{ matrix.target }} |
| 95 | + |
| 96 | + - name: Install musl-tools (Linux musl) |
| 97 | + if: matrix.target == 'x86_64-unknown-linux-musl' |
| 98 | + run: sudo apt-get update && sudo apt-get install -y musl-tools |
| 99 | + |
| 100 | + - name: Cache cargo registry |
| 101 | + uses: actions/cache@v4 |
| 102 | + with: |
| 103 | + path: ~/.cargo/registry |
| 104 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 105 | + |
| 106 | + - name: Cache cargo index |
| 107 | + uses: actions/cache@v4 |
| 108 | + with: |
| 109 | + path: ~/.cargo/git |
| 110 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 111 | + |
| 112 | + - name: Cache cargo build |
| 113 | + uses: actions/cache@v4 |
| 114 | + with: |
| 115 | + path: target |
| 116 | + key: ${{ runner.os }}-cargo-build-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |
| 117 | + |
| 118 | + - name: Build |
| 119 | + run: cargo build --release --target ${{ matrix.target }} |
| 120 | + |
| 121 | + - name: Upload artifact |
| 122 | + uses: actions/upload-artifact@v4 |
| 123 | + with: |
| 124 | + name: ${{ matrix.asset_name }} |
| 125 | + path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} |
| 126 | + |
| 127 | + publish: |
| 128 | + name: Publish to crates.io |
| 129 | + needs: [test, build] |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + with: |
| 134 | + submodules: recursive |
| 135 | + |
| 136 | + - name: Install Rust |
| 137 | + uses: dtolnay/rust-toolchain@stable |
| 138 | + |
| 139 | + - name: Cache cargo registry |
| 140 | + uses: actions/cache@v4 |
| 141 | + with: |
| 142 | + path: ~/.cargo/registry |
| 143 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 144 | + |
| 145 | + - name: Cache cargo index |
| 146 | + uses: actions/cache@v4 |
| 147 | + with: |
| 148 | + path: ~/.cargo/git |
| 149 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 150 | + |
| 151 | + - name: Publish to crates.io |
| 152 | + run: cargo publish --token ${{ secrets.CRATESIO_KEY }} |
| 153 | + |
| 154 | + github_release: |
| 155 | + name: Create GitHub Release |
| 156 | + needs: [test, build, publish] |
| 157 | + runs-on: ubuntu-latest |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@v4 |
| 160 | + |
| 161 | + - name: Download all artifacts |
| 162 | + uses: actions/download-artifact@v4 |
| 163 | + |
| 164 | + - name: Create Release |
| 165 | + uses: softprops/action-gh-release@v2 |
| 166 | + with: |
| 167 | + files: | |
| 168 | + submod-linux-x86_64/submod |
| 169 | + submod-linux-x86_64-musl/submod |
| 170 | + submod-windows-x86_64.exe/submod.exe |
| 171 | + submod-macos-x86_64/submod |
| 172 | + submod-macos-aarch64/submod |
| 173 | + generate_release_notes: true |
| 174 | + draft: false |
| 175 | + prerelease: false |
| 176 | + env: |
| 177 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 178 | + |
0 commit comments