-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests on all platforms, and add release workflow
- Loading branch information
1 parent
47a383a
commit 22540f3
Showing
3 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
paths: | ||
- 'Cargo.toml' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Get package info from Cargo.toml | ||
id: get-package-info | ||
run: | | ||
version=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2) | ||
package_name=$(grep -m1 '^name = ' Cargo.toml | cut -d '"' -f2) | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
echo "package_name=${package_name}" >> $GITHUB_OUTPUT | ||
- name: Check if version exists on crates.io | ||
id: check-version | ||
run: | | ||
version="${{ steps.get-package-info.outputs.version }}" | ||
package_name="${{ steps.get-package-info.outputs.package_name }}" | ||
if cargo search "${package_name}" | grep -q "^${package_name} = \"${version}\""; then | ||
echo "exists=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "exists=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create release | ||
if: steps.check-version.outputs.exists == 'false' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
version="${{ steps.get-package-info.outputs.version }}" | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git tag -a "v${version}" -m "Release v${version}" | ||
git push origin "v${version}" | ||
gh release create "v${version}" \ | ||
--title "Release v${version}" \ | ||
--generate-notes | ||
- name: Install Rust toolchain | ||
if: steps.check-version.outputs.exists == 'false' | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Rust cache | ||
if: steps.check-version.outputs.exists == 'false' | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Publish to crates.io | ||
if: steps.check-version.outputs.exists == 'false' | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
run: cargo publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test: | ||
name: Test (${{ matrix.os }}) | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build | ||
run: cargo build --verbose | ||
|
||
- name: Run tests | ||
run: cargo test --verbose |
This file was deleted.
Oops, something went wrong.