-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (87 loc) · 3.44 KB
/
pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: pr
on: [pull_request]
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: echo "RUST_TOOLCHAIN=$(cat ./rust-toolchain)" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
shared-key: debug-build
- name: Make test
run: make test
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: |
echo "RUST_TOOLCHAIN=$(cat ./rust-toolchain)" >> $GITHUB_ENV
echo "RUST_TOOLCHAIN_NIGHTLY=$(cat ./rust-toolchain-nightly)" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN_NIGHTLY }}
components: rustfmt
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
shared-key: debug-build-nightly
- name: Make lint
run: make lint
semver:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
# Manually extract labels because rymndhng/release-on-push-action can't do this correctly on a PR
- name: Extract labels
id: extract_version_bump
shell: bash
run: |
if [ ${{contains( github.event.pull_request.labels.*.name, 'release:major')}} = true ]; then
echo "bump_version=major" >> $GITHUB_OUTPUT
elif [ ${{contains( github.event.pull_request.labels.*.name, 'release:minor')}} = true ]; then
echo "bump_version=minor" >> $GITHUB_OUTPUT
elif [ ${{contains( github.event.pull_request.labels.*.name, 'norelease')}} = true ]; then
echo "bump_version=" >> $GITHUB_OUTPUT
else
echo "bump_version=patch" >> $GITHUB_OUTPUT
fi
- name: Calculate next version
id: calc_version
if: ${{ steps.extract_version_bump.outputs.bump_version }} != ""
uses: rymndhng/release-on-push-action@master
with:
bump_version_scheme: ${{ steps.extract_version_bump.outputs.bump_version }}
tag_prefix: ""
dry_run: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print version
run: |
echo "${{steps.calc_version.outputs.version}} ${{github.event.pull_request.labels}}"
echo "${{ steps.extract_version_bump.outputs.bump_version }}"
echo "${{toJson(github.event.pull_request.labels.*.name)}}"
- name: Set version
if: ${{ steps.extract_version_bump.outputs.bump_version }} != ""
run: |
sed -i "s/^version = \".*\"$/version = \"${{ steps.calc_version.outputs.version }}\"/" Cargo.toml
- name: Commit new version to main but don't push
if: ${{ steps.extract_version_bump.outputs.bump_version }} != ""
run: |
git config --global user.email "[email protected]"
git config --global user.name "MOIA Rust Maintainers"
git commit -am "Phantom release ${{ steps.calc_version.outputs.version }} [skip ci]"
- name: Check semver
if: ${{ steps.extract_version_bump.outputs.bump_version }} != ""
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
version-tag-prefix: ''