-
Notifications
You must be signed in to change notification settings - Fork 2
168 lines (148 loc) · 5.01 KB
/
rust.yml
File metadata and controls
168 lines (148 loc) · 5.01 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Rust Build and Artifact Creation
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: write
# For syyyr/rust-pycobertura-action
pull-requests: write
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
toolchain: [stable, nightly]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: ${{ matrix.toolchain }}
override: true
components: clippy
- name: Build and Install Binary
run: |
mkdir -p ${{github.workspace}}/install
export RUSTFLAGS="-A mismatched_lifetime_syntaxes"
FEATURES="cq,cp2cp,serde"
if rustup default | grep nightly; then
FEATURES+=",specialization"
fi
cargo clippy --all-targets --features "${FEATURES}"
cargo test --features "${FEATURES}"
cargo install --path '${{github.workspace}}' --root '${{github.workspace}}/install' --target ${{ matrix.target }} --features "${FEATURES}" --locked
shell: bash
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}-${{ matrix.toolchain }}-binary
path: ${{github.workspace}}/install/bin
create-nightly-release:
name: Create nightly
if: github.ref == 'refs/heads/master'
needs: [build]
runs-on: ubuntu-latest
env:
HASH_FOR_FILENAMES: ${{github.event.pull_request.head.sha || github.sha}}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Consolidate artifacts
uses: actions/download-artifact@v8
with:
pattern: '*-latest-nightly-binary'
merge-multiple: true
- name: Rename artifacts
run: |
CP2CP_FILE_NAME="$(printf "cp2cp-nightly-g%s" "$(head -c 7 <<< '${{env.HASH_FOR_FILENAMES}}')")"
mv cp2cp "${CP2CP_FILE_NAME}"
mv cp2cp.exe "${CP2CP_FILE_NAME}.exe"
- name: Create release
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: silicon-heaven/rust-nightly-release-action@v1.0.0
with:
path_glob: cp2cp*
coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Generate coverage
uses: silicon-heaven/rust-pycobertura-action@v4.1.0
with:
project_name: libshvproto
cargo_test_arguments: --features cq,cp2cp,serde
check-version-bump:
name: Check version bump
runs-on: ubuntu-latest
steps:
- name: Check version bump
id: version-check
continue-on-error: ${{startsWith(github.head_ref, 'dependabot/')}}
uses: silicon-heaven/rust-check-version-bump@v1.0.1
- name: Checkout code
if: steps.version-check.outcome == 'failure'
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{github.head_ref}}
- name: Bump version
if: steps.version-check.outcome == 'failure'
run: |
[[ "$(grep '^version' Cargo.toml | head -n1)" =~ ([0-9]+\.[0-9]+\.)([0-9]+) ]]
NEW_VERSION="${BASH_REMATCH[1]}$((BASH_REMATCH[2] + 1))"
cargo install cargo-release
echo Bumping "${BASH_REMATCH[0]} -> $NEW_VERSION"
BUMP_TYPE='patch'
yes | cargo release version "$BUMP_TYPE" --execute
if [[ -f Cargo.lock ]]; then
cargo update
fi
git diff
git config --global user.name "Login will be determined by the Github API based on the creator of the token"
git config --global user.email ""
git commit -am '[dependabot-skip] Bump version'
- name: Push changes
if: steps.version-check.outcome == 'failure'
uses: Asana/push-signed-commits@v1
with:
github-token: ${{ secrets.DEPENDABOT_GITHUB_TOKEN }}
local_branch_name: ${{github.head_ref}}
remote_branch_name: ${{github.head_ref}}
tag-release:
name: Tag Release
if: github.ref == 'refs/heads/master'
needs: [build, check-version-bump]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get version from Cargo.toml
id: get-version
run: |
version="$(grep '^version' Cargo.toml | head -n1 | sed 's/version\s*=\s*"\(.*\)"/\1/')"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Create and push tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.get-version.outputs.version }}