Skip to content

Commit 8a572b6

Browse files
committed
#
1 parent 994759b commit 8a572b6

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

.github/workflows/semver.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: semver
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'Cargo.toml'
7+
- 'src/**'
8+
- 'sea-orm-cli/**'
9+
- 'sea-orm-codegen/**'
10+
- 'sea-orm-macros/**'
11+
- 'sea-orm-migration/**'
12+
- 'sea-orm-rocket/**'
13+
- '.github/workflows/semver.yml'
14+
push:
15+
branches:
16+
- master
17+
- '1.*.x'
18+
paths:
19+
- 'Cargo.toml'
20+
- 'src/**'
21+
- 'sea-orm-cli/**'
22+
- 'sea-orm-codegen/**'
23+
- 'sea-orm-macros/**'
24+
- 'sea-orm-migration/**'
25+
- 'sea-orm-rocket/**'
26+
workflow_dispatch:
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
30+
cancel-in-progress: true
31+
32+
jobs:
33+
detect:
34+
name: Detect changes
35+
runs-on: ubuntu-latest
36+
outputs:
37+
matrix: ${{ steps.build-matrix.outputs.matrix }}
38+
core: ${{ steps.build-matrix.outputs.core }}
39+
cli: ${{ steps.build-matrix.outputs.cli }}
40+
codegen: ${{ steps.build-matrix.outputs.codegen }}
41+
macros: ${{ steps.build-matrix.outputs.macros }}
42+
migration: ${{ steps.build-matrix.outputs.migration }}
43+
rocket_codegen: ${{ steps.build-matrix.outputs.rocket_codegen }}
44+
rocket_lib: ${{ steps.build-matrix.outputs.rocket_lib }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
- id: filter
48+
uses: dorny/paths-filter@v3
49+
with:
50+
filters: |
51+
core:
52+
- 'Cargo.lock'
53+
- 'Cargo.toml'
54+
- 'src/**'
55+
cli:
56+
- 'sea-orm-cli/**'
57+
codegen:
58+
- 'sea-orm-codegen/**'
59+
macros:
60+
- 'sea-orm-macros/**'
61+
migration:
62+
- 'sea-orm-migration/**'
63+
rocket_codegen:
64+
- 'sea-orm-rocket/codegen/**'
65+
- 'sea-orm-rocket/Cargo.toml'
66+
rocket_lib:
67+
- 'sea-orm-rocket/lib/**'
68+
- 'sea-orm-rocket/Cargo.toml'
69+
- id: build-matrix
70+
name: Build matrix
71+
uses: actions/github-script@v8
72+
env:
73+
EVENT_NAME: ${{ github.event_name }}
74+
CORE_CHANGED: ${{ steps.filter.outputs.core }}
75+
CLI_CHANGED: ${{ steps.filter.outputs.cli }}
76+
CODEGEN_CHANGED: ${{ steps.filter.outputs.codegen }}
77+
MACROS_CHANGED: ${{ steps.filter.outputs.macros }}
78+
MIGRATION_CHANGED: ${{ steps.filter.outputs.migration }}
79+
ROCKET_CODEGEN_CHANGED: ${{ steps.filter.outputs.rocket_codegen }}
80+
ROCKET_LIB_CHANGED: ${{ steps.filter.outputs.rocket_lib }}
81+
with:
82+
script: |
83+
const event = process.env.EVENT_NAME;
84+
const entries = [
85+
{ id: 'core', name: 'core', manifest: 'Cargo.toml', changed: process.env.CORE_CHANGED === 'true' },
86+
{ id: 'cli', name: 'cli', manifest: 'sea-orm-cli/Cargo.toml', changed: process.env.CLI_CHANGED === 'true' },
87+
{ id: 'codegen', name: 'codegen', manifest: 'sea-orm-codegen/Cargo.toml', changed: process.env.CODEGEN_CHANGED === 'true' },
88+
{ id: 'macros', name: 'macros', manifest: 'sea-orm-macros/Cargo.toml', changed: process.env.MACROS_CHANGED === 'true' },
89+
{ id: 'migration', name: 'migration', manifest: 'sea-orm-migration/Cargo.toml', changed: process.env.MIGRATION_CHANGED === 'true' },
90+
{ id: 'rocket_codegen', name: 'rocket/codegen', manifest: 'sea-orm-rocket/codegen/Cargo.toml', changed: process.env.ROCKET_CODEGEN_CHANGED === 'true' },
91+
{ id: 'rocket_lib', name: 'rocket/lib', manifest: 'sea-orm-rocket/lib/Cargo.toml', changed: process.env.ROCKET_LIB_CHANGED === 'true' }
92+
];
93+
94+
const shouldRunAll = event === 'workflow_dispatch';
95+
const selected = shouldRunAll ? entries : entries.filter((entry) => entry.changed);
96+
const matrix = selected.map(({ id, name, manifest }) => ({ id, name, manifest }));
97+
98+
core.setOutput('matrix', JSON.stringify(matrix));
99+
100+
for (const entry of entries) {
101+
const shouldRun = shouldRunAll || entry.changed ? 'true' : 'false';
102+
core.setOutput(entry.id, shouldRun);
103+
}
104+
105+
semver:
106+
name: Semver Check (${{ matrix.name }})
107+
needs: detect
108+
if: ${{ needs.detect.outputs.matrix != '[]' }}
109+
runs-on: ubuntu-latest
110+
strategy:
111+
fail-fast: false
112+
matrix: ${{ fromJson(needs.detect.outputs.matrix) }}
113+
steps:
114+
- uses: actions/checkout@v4
115+
- name: Semver checks
116+
uses: obi1kenobi/cargo-semver-checks-action@v2
117+
with:
118+
manifest-path: ${{ matrix.manifest }}

0 commit comments

Comments
 (0)