6363 - uses : actions/checkout@v5
6464
6565 - name : Install Rust
66- uses : dtolnay/rust-toolchain@stable
66+ uses : dtolnay/rust-toolchain@nightly
6767 with :
6868 components : llvm-tools-preview
6969
@@ -132,7 +132,7 @@ jobs:
132132 key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
133133
134134 - name : Build all examples
135- run : cargo build --examples --all-features --verbose
135+ run : cargo build --examples --all-features
136136
137137 - name : Run all examples
138138 run : |
@@ -141,3 +141,77 @@ jobs:
141141 echo "Running example: $example_name"
142142 cargo run --example "$example_name" --all-features || exit 1
143143 done
144+
145+ release :
146+ name : Semantic Release
147+ runs-on : ubuntu-latest
148+ needs : [clippy, test, examples]
149+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
150+ environment : main
151+ permissions :
152+ contents : write
153+ issues : write
154+ pull-requests : write
155+ id-token : write
156+ steps :
157+ - uses : actions/checkout@v5
158+ with :
159+ fetch-depth : 0
160+ persist-credentials : false
161+
162+ - name : Install Rust
163+ uses : dtolnay/rust-toolchain@stable
164+
165+ - name : Cache cargo registry
166+ uses : actions/cache@v4
167+ with :
168+ path : ~/.cargo/registry
169+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
170+
171+ - name : Cache cargo index
172+ uses : actions/cache@v4
173+ with :
174+ path : ~/.cargo/git
175+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
176+
177+ - name : Cache cargo build
178+ uses : actions/cache@v4
179+ with :
180+ path : target
181+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
182+
183+ - name : Build package
184+ run : cargo build --release --all-features
185+
186+ - name : Setup Node.js
187+ uses : actions/setup-node@v6
188+ with :
189+ node-version : ' lts/*'
190+
191+ - name : Install semantic-release and plugins
192+ run : |
193+ npm install -g \
194+ semantic-release@latest \
195+ @semantic-release/git@latest \
196+ @semantic-release/changelog@latest \
197+ @semantic-release/exec@latest \
198+ conventional-changelog-conventionalcommits@latest
199+
200+ - name : Semantic Release
201+ id : semantic
202+ env :
203+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
204+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_TOKEN }}
205+ run : |
206+ npx semantic-release
207+ echo "new_release_published=$([ -f .semanticRelease ])" >> $GITHUB_OUTPUT
208+
209+ - name : Publish to crates.io
210+ if : always()
211+ run : |
212+ if cargo publish --token ${{ secrets.CARGO_TOKEN }} --allow-dirty 2>&1 | grep -q "crate version .* is already uploaded"; then
213+ echo "Version already published, skipping"
214+ exit 0
215+ fi
216+ env :
217+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_TOKEN }}
0 commit comments