Skip to content

Commit aa4e9ef

Browse files
authored
Merge pull request #16 from arceos-org/crates-io
2 parents b99e4cc + 4924d9b commit aa4e9ef

File tree

24 files changed

+799
-80
lines changed

24 files changed

+799
-80
lines changed

.github/workflows/check.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Quality Checks
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
RUST_BACKTRACE: 1
9+
10+
jobs:
11+
check:
12+
name: Quality Checks
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
target:
18+
- x86_64-unknown-linux-gnu
19+
- x86_64-unknown-none
20+
- riscv64gc-unknown-none-elf
21+
- aarch64-unknown-none-softfloat
22+
- loongarch64-unknown-none-softfloat
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Install Rust toolchain
29+
uses: dtolnay/rust-toolchain@nightly
30+
with:
31+
components: rust-src, clippy, rustfmt
32+
targets: ${{ matrix.target }}
33+
34+
- name: Check rust version
35+
run: rustc --version --verbose
36+
37+
- name: Check code format
38+
run: cargo fmt --all -- --check
39+
40+
- name: Clippy
41+
run: cargo clippy --target ${{ matrix.target }} --all-features
42+
43+
- name: Build
44+
run: cargo build --target ${{ matrix.target }} --all-features

.github/workflows/ci.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
pages: write
8+
id-token: write
9+
10+
concurrency:
11+
group: 'pages'
12+
cancel-in-progress: false
13+
14+
jobs:
15+
check:
16+
uses: ./.github/workflows/check.yml
17+
18+
test:
19+
uses: ./.github/workflows/test.yml
20+
21+
build-doc:
22+
name: Build documentation
23+
runs-on: ubuntu-latest
24+
needs: [check, test]
25+
env:
26+
RUSTDOCFLAGS: "-Zunstable-options --enable-index-page -D rustdoc::broken_intra_doc_links -D missing-docs"
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Install Rust toolchain
32+
uses: dtolnay/rust-toolchain@nightly
33+
34+
- name: Build docs
35+
run: |
36+
for crate in axdriver_base axdriver_block axdriver_net axdriver_display axdriver_pci axdriver_virtio;
37+
do
38+
cargo rustdoc --all-features -p $crate
39+
done
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: target/doc
45+
46+
deploy-doc:
47+
name: Deploy to GitHub Pages
48+
environment:
49+
name: github-pages
50+
url: ${{ steps.deployment.outputs.page_url }}
51+
runs-on: ubuntu-latest
52+
needs: build-doc
53+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
- 'v*.*.*-pre.*'
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
check:
14+
uses: ./.github/workflows/check.yml
15+
16+
test:
17+
uses: ./.github/workflows/test.yml
18+
19+
create-release:
20+
name: Create GitHub Release
21+
runs-on: ubuntu-latest
22+
needs: [check, test]
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Validate tag is on main branch
31+
shell: bash
32+
run: |
33+
set -e
34+
35+
TAG="${{ github.ref_name }}"
36+
TAG_COMMIT=$(git rev-list -n 1 "$TAG")
37+
38+
git fetch origin main
39+
40+
MAIN_HEAD=$(git rev-parse origin/main)
41+
42+
echo "Tag: $TAG"
43+
echo "Tag commit: $TAG_COMMIT"
44+
echo "main HEAD: $MAIN_HEAD"
45+
46+
if [ "$TAG_COMMIT" != "$MAIN_HEAD" ]; then
47+
echo "❌ release tag must be created from main HEAD"
48+
exit 1
49+
fi
50+
echo "✅ release tag validated on main"
51+
52+
- name: Validate version consistency
53+
shell: bash
54+
run: |
55+
set -e
56+
57+
TAG="${{ github.ref_name }}"
58+
# Remove 'v' prefix from tag
59+
TAG_VERSION="${TAG#v}"
60+
61+
# Get version from Cargo.toml
62+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
63+
echo "CARGO_VERSION=$CARGO_VERSION" >> "$GITHUB_ENV"
64+
65+
echo "Tag version: $TAG_VERSION"
66+
echo "Cargo version: $CARGO_VERSION"
67+
68+
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
69+
echo "❌ Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
70+
exit 1
71+
fi
72+
echo "✅ Version consistency validated"
73+
74+
- name: Create GitHub Release
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
draft: false
78+
prerelease: ${{ contains(github.ref_name, '-pre.') }}
79+
body: |
80+
## ${{ github.ref_name }}
81+
82+
- [Documentation](https://arceos.org/axdriver_crates/)
83+
- crates.io:
84+
- https://crates.io/crates/axdriver_base/${{ env.CARGO_VERSION }}
85+
- https://crates.io/crates/axdriver_block/${{ env.CARGO_VERSION }}
86+
- https://crates.io/crates/axdriver_display/${{ env.CARGO_VERSION }}
87+
- https://crates.io/crates/axdriver_net/${{ env.CARGO_VERSION }}
88+
- https://crates.io/crates/axdriver_pci/${{ env.CARGO_VERSION }}
89+
- https://crates.io/crates/axdriver_virtio/${{ env.CARGO_VERSION }}
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
publish-crates:
94+
name: Publish to crates.io
95+
runs-on: ubuntu-latest
96+
needs: [check, test]
97+
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v4
101+
with:
102+
fetch-depth: 0
103+
104+
- name: Validate tag is on main branch
105+
shell: bash
106+
run: |
107+
set -e
108+
109+
TAG="${{ github.ref_name }}"
110+
TAG_COMMIT=$(git rev-list -n 1 "$TAG")
111+
112+
git fetch origin main
113+
114+
MAIN_HEAD=$(git rev-parse origin/main)
115+
116+
echo "Tag: $TAG"
117+
echo "Tag commit: $TAG_COMMIT"
118+
echo "main HEAD: $MAIN_HEAD"
119+
120+
if [ "$TAG_COMMIT" != "$MAIN_HEAD" ]; then
121+
echo "❌ release tag must be created from main HEAD"
122+
exit 1
123+
fi
124+
echo "✅ release tag validated on main"
125+
126+
- name: Validate version consistency
127+
shell: bash
128+
run: |
129+
set -e
130+
131+
TAG="${{ github.ref_name }}"
132+
# Remove 'v' prefix from tag
133+
TAG_VERSION="${TAG#v}"
134+
135+
# Get version from Cargo.toml
136+
CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
137+
138+
echo "Tag version: $TAG_VERSION"
139+
echo "Cargo version: $CARGO_VERSION"
140+
141+
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
142+
echo "❌ Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
143+
exit 1
144+
fi
145+
echo "✅ Version consistency validated"
146+
147+
- name: Install Rust toolchain
148+
uses: dtolnay/rust-toolchain@nightly
149+
150+
- name: Publish to crates.io
151+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
CARGO_TERM_COLOR: always
8+
RUST_BACKTRACE: 1
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Install Rust toolchain
18+
uses: dtolnay/rust-toolchain@nightly
19+
20+
- name: Run tests
21+
run: cargo test --all-features -- --nocapture

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/target
22
/.vscode
33
.DS_Store
4-
Cargo.lock

0 commit comments

Comments
 (0)