|
1 | 1 | name: Release |
2 | 2 |
|
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
3 | 6 | on: |
4 | 7 | push: |
5 | 8 | tags: |
6 | 9 | - "v*" |
| 10 | + workflow_dispatch: |
7 | 11 |
|
8 | 12 | env: |
9 | 13 | CARGO_TERM_COLOR: always |
| 14 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
10 | 15 |
|
11 | 16 | 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: Setup OpenSSL for macOS |
101 | | - if: matrix.os == 'macos-latest' |
102 | | - run: | |
103 | | - brew install openssl pkg-config |
104 | | - # For cross-compilation, we need to set up the environment properly |
105 | | - if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then |
106 | | - echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV |
107 | | - echo "OPENSSL_DIR=$(brew --prefix openssl)" >> $GITHUB_ENV |
108 | | - fi |
109 | | -
|
110 | | - - name: Cache cargo registry |
111 | | - uses: actions/cache@v4 |
112 | | - with: |
113 | | - path: ~/.cargo/registry |
114 | | - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
115 | | - |
116 | | - - name: Cache cargo index |
117 | | - uses: actions/cache@v4 |
118 | | - with: |
119 | | - path: ~/.cargo/git |
120 | | - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
121 | | - |
122 | | - - name: Cache cargo build |
123 | | - uses: actions/cache@v4 |
124 | | - with: |
125 | | - path: target |
126 | | - key: ${{ runner.os }}-cargo-build-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |
127 | | - |
128 | | - - name: Build |
129 | | - run: | |
130 | | - # For macOS x86_64 cross-compilation, build without git2 to avoid OpenSSL issues |
131 | | - if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" && "${{ runner.arch }}" == "ARM64" ]]; then |
132 | | - cargo build --release --target ${{ matrix.target }} --no-default-features |
133 | | - else |
134 | | - cargo build --release --target ${{ matrix.target }} |
135 | | - fi |
136 | | -
|
137 | | - - name: Upload artifact |
138 | | - uses: actions/upload-artifact@v4 |
139 | | - with: |
140 | | - name: ${{ matrix.asset_name }} |
141 | | - path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} |
142 | | - |
143 | | - publish: |
144 | | - name: Publish to crates.io |
145 | | - needs: [test, build] |
146 | | - runs-on: ubuntu-latest |
147 | | - steps: |
148 | | - - uses: actions/checkout@v4 |
149 | | - with: |
150 | | - submodules: recursive |
151 | | - |
152 | | - - name: Install Rust |
153 | | - uses: dtolnay/rust-toolchain@stable |
154 | | - |
155 | | - - name: Cache cargo registry |
156 | | - uses: actions/cache@v4 |
157 | | - with: |
158 | | - path: ~/.cargo/registry |
159 | | - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
160 | | - |
161 | | - - name: Cache cargo index |
162 | | - uses: actions/cache@v4 |
163 | | - with: |
164 | | - path: ~/.cargo/git |
165 | | - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
166 | | - |
167 | | - - name: Publish to crates.io |
168 | | - run: cargo publish --token ${{ secrets.CRATESIO_KEY }} |
169 | | - |
170 | | - github_release: |
171 | | - name: Create GitHub Release |
172 | | - needs: [test, build, publish] |
173 | | - runs-on: ubuntu-latest |
174 | | - steps: |
175 | | - - uses: actions/checkout@v4 |
176 | | - |
177 | | - - name: Download all artifacts |
178 | | - uses: actions/download-artifact@v4 |
179 | | - |
180 | | - - name: Create Release |
181 | | - uses: softprops/action-gh-release@v2 |
182 | | - with: |
183 | | - files: | |
184 | | - submod-linux-x86_64/submod |
185 | | - submod-linux-x86_64-musl/submod |
186 | | - submod-windows-x86_64.exe/submod.exe |
187 | | - submod-macos-x86_64/submod |
188 | | - submod-macos-aarch64/submod |
189 | | - generate_release_notes: true |
190 | | - draft: false |
191 | | - prerelease: false |
192 | | - env: |
193 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 17 | + build: |
| 18 | + runs-on: ${{ matrix.os }} |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - target: aarch64-apple-darwin |
| 24 | + os: macos-latest |
| 25 | + build-tool: cargo |
| 26 | + - target: x86_64-unknown-linux-gnu |
| 27 | + os: ubuntu-latest |
| 28 | + build-tool: cross |
| 29 | + - target: aarch64-unknown-linux-gnu |
| 30 | + os: ubuntu-latest |
| 31 | + build-tool: cross |
| 32 | + - target: x86_64-pc-windows-msvc |
| 33 | + os: windows-latest |
| 34 | + build-tool: cargo |
| 35 | + - target: aarch64-pc-windows-msvc |
| 36 | + os: windows-latest |
| 37 | + build-tool: cargo |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + - uses: Swatinem/rust-cache@v2 |
| 41 | + with: |
| 42 | + shared-key: rust-${{ matrix.target }} |
| 43 | + - uses: taiki-e/upload-rust-binary-action@v1 |
| 44 | + with: |
| 45 | + bin: submod |
| 46 | + checksum: sha256 |
| 47 | + target: ${{ matrix.target }} |
| 48 | + build-tool: ${{ matrix.build-tool }} |
| 49 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + features: git2/vendored-libgit2,git2/vendored-openssl |
| 51 | + dry-run: ${{ github.event_name == 'workflow_dispatch' }} |
| 52 | + |
| 53 | + publish: |
| 54 | + name: Publish to crates.io |
| 55 | + needs: [build] |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + submodules: recursive |
| 61 | + |
| 62 | + - name: Install Rust |
| 63 | + uses: dtolnay/rust-toolchain@stable |
| 64 | + |
| 65 | + - name: Cache cargo registry |
| 66 | + uses: actions/cache@v4 |
| 67 | + with: |
| 68 | + path: ~/.cargo/registry |
| 69 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 70 | + |
| 71 | + - name: Cache cargo index |
| 72 | + uses: actions/cache@v4 |
| 73 | + with: |
| 74 | + path: ~/.cargo/git |
| 75 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
| 76 | + |
| 77 | + - name: Publish to crates.io |
| 78 | + run: cargo publish --token ${{ secrets.CRATESIO_KEY }} |
| 79 | + |
| 80 | + github_release: |
| 81 | + name: Create GitHub Release |
| 82 | + needs: [build, publish] |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Download all artifacts |
| 88 | + uses: actions/download-artifact@v4 |
| 89 | + |
| 90 | + - name: Create Release |
| 91 | + uses: softprops/action-gh-release@v2 |
| 92 | + with: |
| 93 | + files: | |
| 94 | + submod-linux-x86_64/submod |
| 95 | + submod-linux-x86_64-musl/submod |
| 96 | + submod-windows-x86_64.exe/submod.exe |
| 97 | + submod-macos-aarch64/submod |
| 98 | + body_path: CHANGELOG.md |
| 99 | + draft: false |
| 100 | + prerelease: false |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments