Skip to content

Commit c44215b

Browse files
committed
workflowの修正
1 parent 4357989 commit c44215b

File tree

3 files changed

+46
-39
lines changed

3 files changed

+46
-39
lines changed

.github/workflows/ci.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
ci:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Rust
17+
uses: actions-rs/toolchain@v1
18+
with:
19+
toolchain: stable
20+
override: true
21+
22+
- name: Run cargo build
23+
run: cargo build --release
24+
25+
- name: Run tests
26+
run: cargo test --release
27+
28+
- name: Check formatting
29+
run: cargo fmt -- --check
30+
31+
- name: Run clippy
32+
run: cargo clippy -- -D warnings

.github/workflows/publish.yml

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
name: Publish to crates.io
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
paths:
8-
- 'src/**'
4+
workflow_run:
5+
workflows: ["Continuous Integration"]
6+
types:
7+
- completed
98

109
jobs:
1110
publish:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }}
1212
runs-on: ubuntu-latest
1313

1414
steps:
1515
- name: Checkout repository
1616
uses: actions/checkout@v3
1717

18-
- name: Set up Rust
19-
uses: actions-rs/toolchain@v1
20-
with:
21-
toolchain: stable
22-
override: true
23-
24-
- name: Build the project
25-
run: cargo build --release
26-
27-
- name: Run tests
28-
run: cargo test --release
18+
- name: Check for changes in src directory
19+
id: check_changes
20+
run: |
21+
if git diff --name-only ${{ github.event.workflow_run.head_commit.id }}^ ${{ github.event.workflow_run.head_commit.id }} | grep -q '^src/'; then
22+
echo "changes_in_src=true" >> $GITHUB_ENV
23+
else
24+
echo "changes_in_src=false" >> $GITHUB_ENV
25+
fi
2926
3027
- name: Publish to crates.io
31-
if: success()
28+
if: env.changes_in_src == 'true'
3229
env:
3330
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3431
run: cargo publish

.github/workflows/rust.yml

-22
This file was deleted.

0 commit comments

Comments
 (0)