@@ -2,18 +2,70 @@ name: CI
2
2
3
3
on :
4
4
push :
5
- branches : [main]
5
+ branches : [ main ]
6
6
pull_request :
7
- branches : [main]
7
+ branches : [ main ]
8
8
release :
9
- types : [published]
9
+ types : [ published ]
10
10
workflow_dispatch :
11
11
12
12
jobs :
13
- build :
14
- name : Build
13
+ test :
14
+ name : Test
15
15
runs-on : ubuntu-latest
16
16
steps :
17
+ - uses : taiki-e/install-action@v2
18
+ with : { tool: just }
17
19
- uses : actions/checkout@v4
18
20
- uses : Swatinem/rust-cache@v2
19
- - run : source .cargo-husky/hooks/pre-push
21
+ if : github.event_name != 'release' && github.event_name != 'workflow_dispatch'
22
+ - run : just ci-test
23
+ - name : Check semver
24
+ uses : obi1kenobi/cargo-semver-checks-action@v2
25
+ - name : Get local and published versions
26
+ id : get-versions
27
+ run : |
28
+ echo "local_version=$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]*)".*/\1/')" >> $GITHUB_OUTPUT
29
+ CRATE_NAME=$(grep '^name =' Cargo.toml | head -1 | sed -E 's/name = "(.*)"/\1/')
30
+ PUBLISHED_VERSION=$(cargo search ${CRATE_NAME} | grep "^${CRATE_NAME} =" | sed -E 's/.* = "(.*)".*/\1/')
31
+ echo "published_version=${PUBLISHED_VERSION}" >> $GITHUB_OUTPUT
32
+ - name : Test that we haven't published current version yet
33
+ run : |
34
+ LOCAL_VERSION=${{ steps.get-versions.outputs.local_version }}
35
+ PUBLISHED_VERSION=${{ steps.get-versions.outputs.published_version }}
36
+ if [ "$LOCAL_VERSION" = "$PUBLISHED_VERSION" ]; then
37
+ echo "The current crate version ($LOCAL_VERSION) has already been published."
38
+ exit 1
39
+ else
40
+ echo "The current crate version ($LOCAL_VERSION) has not been published yet."
41
+ fi
42
+
43
+ msrv :
44
+ name : Test MSRV
45
+ runs-on : ubuntu-latest
46
+ steps :
47
+ - uses : taiki-e/install-action@v2
48
+ with : { tool: just }
49
+ - uses : actions/checkout@v4
50
+ - uses : Swatinem/rust-cache@v2
51
+ if : github.event_name != 'release' && github.event_name != 'workflow_dispatch'
52
+ - name : Read crate metadata
53
+ id : metadata
54
+ run : echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT
55
+ - name : Install Rust
56
+ uses : dtolnay/rust-toolchain@stable
57
+ with :
58
+ toolchain : ${{ steps.metadata.outputs.rust-version }}
59
+ - run : just ci-test-msrv
60
+
61
+ publish :
62
+ name : Publish to crates.io
63
+ if : startsWith(github.ref, 'refs/tags/')
64
+ needs : [ test, msrv ]
65
+ runs-on : ubuntu-latest
66
+ steps :
67
+ - uses : actions/checkout@v4
68
+ - name : Publish to crates.io
69
+ run : cargo publish
70
+ env :
71
+ CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
0 commit comments