|
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: Set up mise |
44 | | - run: | |
45 | | - curl https://mise.run | sh |
46 | | - echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH |
47 | | - echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH |
48 | | - MISE="$HOME/.local/bin/mise" |
49 | | - $MISE trust -y |
50 | | - $MISE install -y |
51 | | - $MISE reshim |
52 | | - $HOME/.local/share/mise/shims/hk install --mise |
53 | | -
|
54 | | - - name: Run hk ci workflow |
55 | | - run: $HOME/.local/share/mise/shims/hk run ci |
56 | | - |
57 | | - build: |
58 | | - name: Build Release Binaries |
59 | | - needs: test |
60 | | - runs-on: ${{ matrix.os }} |
61 | | - strategy: |
62 | | - matrix: |
63 | | - include: |
64 | | - - os: ubuntu-latest |
65 | | - target: x86_64-unknown-linux-gnu |
66 | | - artifact_name: submod |
67 | | - asset_name: submod-linux-x86_64 |
68 | | - - os: ubuntu-latest |
69 | | - target: x86_64-unknown-linux-musl |
70 | | - artifact_name: submod |
71 | | - asset_name: submod-linux-x86_64-musl |
72 | | - - os: windows-latest |
73 | | - target: x86_64-pc-windows-msvc |
74 | | - artifact_name: submod.exe |
75 | | - asset_name: submod-windows-x86_64.exe |
76 | | - - os: macos-latest |
77 | | - target: x86_64-apple-darwin |
78 | | - artifact_name: submod |
79 | | - asset_name: submod-macos-x86_64 |
80 | | - - os: macos-latest |
81 | | - target: aarch64-apple-darwin |
82 | | - artifact_name: submod |
83 | | - asset_name: submod-macos-aarch64 |
84 | | - |
85 | | - steps: |
86 | | - - uses: actions/checkout@v4 |
87 | | - with: |
88 | | - submodules: recursive |
89 | | - |
90 | | - - name: Install Rust |
91 | | - uses: dtolnay/rust-toolchain@stable |
92 | | - with: |
93 | | - targets: ${{ matrix.target }} |
94 | | - |
95 | | - - name: Install musl-tools (Linux musl) |
96 | | - if: matrix.target == 'x86_64-unknown-linux-musl' |
97 | | - run: sudo apt-get update && sudo apt-get install -y musl-tools |
98 | | - |
99 | | - - name: Cache cargo registry |
100 | | - uses: actions/cache@v4 |
101 | | - with: |
102 | | - path: ~/.cargo/registry |
103 | | - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
104 | | - |
105 | | - - name: Cache cargo index |
106 | | - uses: actions/cache@v4 |
107 | | - with: |
108 | | - path: ~/.cargo/git |
109 | | - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
110 | | - |
111 | | - - name: Cache cargo build |
112 | | - uses: actions/cache@v4 |
113 | | - with: |
114 | | - path: target |
115 | | - key: ${{ runner.os }}-cargo-build-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} |
116 | | - |
117 | | - - name: Build |
118 | | - run: cargo build --release --target ${{ matrix.target }} |
119 | | - |
120 | | - - name: Upload artifact |
121 | | - uses: actions/upload-artifact@v4 |
122 | | - with: |
123 | | - name: ${{ matrix.asset_name }} |
124 | | - path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} |
125 | | - |
126 | | - publish: |
127 | | - name: Publish to crates.io |
128 | | - needs: [test, build] |
129 | | - runs-on: ubuntu-latest |
130 | | - steps: |
131 | | - - uses: actions/checkout@v4 |
132 | | - with: |
133 | | - submodules: recursive |
134 | | - |
135 | | - - name: Install Rust |
136 | | - uses: dtolnay/rust-toolchain@stable |
137 | | - |
138 | | - - name: Cache cargo registry |
139 | | - uses: actions/cache@v4 |
140 | | - with: |
141 | | - path: ~/.cargo/registry |
142 | | - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
143 | | - |
144 | | - - name: Cache cargo index |
145 | | - uses: actions/cache@v4 |
146 | | - with: |
147 | | - path: ~/.cargo/git |
148 | | - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} |
149 | | - |
150 | | - - name: Publish to crates.io |
151 | | - run: cargo publish --token ${{ secrets.CRATESIO_KEY }} |
152 | | - |
153 | | - github_release: |
154 | | - name: Create GitHub Release |
155 | | - needs: [test, build, publish] |
156 | | - runs-on: ubuntu-latest |
157 | | - steps: |
158 | | - - uses: actions/checkout@v4 |
159 | | - |
160 | | - - name: Download all artifacts |
161 | | - uses: actions/download-artifact@v4 |
162 | | - |
163 | | - - name: Create Release |
164 | | - uses: softprops/action-gh-release@v2 |
165 | | - with: |
166 | | - files: | |
167 | | - submod-linux-x86_64/submod |
168 | | - submod-linux-x86_64-musl/submod |
169 | | - submod-windows-x86_64.exe/submod.exe |
170 | | - submod-macos-x86_64/submod |
171 | | - submod-macos-aarch64/submod |
172 | | - generate_release_notes: true |
173 | | - draft: false |
174 | | - prerelease: false |
175 | | - env: |
176 | | - 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