Skip to content

Commit 13bfd72

Browse files
authored
Merge pull request #4 from chenxiaolong/ci
Update GitHub Actions workflows to support creating releases
2 parents a3fcdde + 4fcab76 commit 13bfd72

File tree

5 files changed

+128
-25
lines changed

5 files changed

+128
-25
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
jobs:
8+
build_and_upload:
9+
name: Build and archive artifacts
10+
runs-on: windows-latest
11+
env:
12+
CARGO_TERM_COLOR: always
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 1
18+
19+
- name: Install winmd files
20+
run: |
21+
cargo install cargo-winrt
22+
cargo winrt install
23+
24+
- name: Install clippy
25+
run: rustup component add clippy
26+
27+
- name: Run clippy checks in debug mode
28+
env:
29+
RUST_BACKTRACE: 1
30+
run: |
31+
cargo clippy --workspace -- -D warnings
32+
33+
- name: Build in debug mode
34+
run: cargo build --verbose
35+
36+
- name: Archive artifacts
37+
uses: actions/upload-artifact@v2
38+
with:
39+
name: svrbsctl
40+
path: |
41+
target/debug/svrbsctl.exe
42+
target/debug/svrbsctl.pdb

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
on:
3+
push:
4+
# Uncomment to test against a branch
5+
#branches:
6+
# - ci
7+
tags:
8+
- 'v*'
9+
jobs:
10+
create_release:
11+
name: Create GitHub release
12+
runs-on: ubuntu-latest
13+
outputs:
14+
upload_url: ${{ steps.create_release.outputs.upload_url }}
15+
version: ${{ steps.get_version.outputs.version }}
16+
steps:
17+
- name: Get version from tag
18+
id: get_version
19+
run: |
20+
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
21+
version=${GITHUB_REF#refs/tags/v}
22+
else
23+
version=0.0.0-${GITHUB_REF#refs/heads/}
24+
fi
25+
echo "::set-output name=version::${version}"
26+
27+
- name: Create release
28+
id: create_release
29+
uses: actions/create-release@latest
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
tag_name: v${{ steps.get_version.outputs.version }}
34+
release_name: Version ${{ steps.get_version.outputs.version }}
35+
draft: false
36+
prerelease: false
37+
38+
build_and_upload:
39+
name: Build and upload assets
40+
needs: create_release
41+
runs-on: windows-latest
42+
env:
43+
CARGO_TERM_COLOR: always
44+
steps:
45+
- name: Check out repository
46+
uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 1
49+
50+
- name: Install winmd files
51+
run: |
52+
cargo install cargo-winrt
53+
cargo winrt install
54+
55+
- name: Install clippy
56+
run: rustup component add clippy
57+
58+
- name: Run clippy checks in release mode
59+
env:
60+
RUST_BACKTRACE: 1
61+
run: |
62+
cargo clippy --workspace --release -- -D warnings
63+
64+
- name: Build in release mode
65+
run: cargo build --release --verbose
66+
67+
- name: Build archive
68+
shell: bash
69+
run: |
70+
base_name=svrbsctl-${{ needs.create_release.outputs.version }}
71+
mkdir "${base_name}"
72+
cp {README.md,LICENSE,target/release/svrbsctl.exe} "${base_name}/"
73+
7z a "${base_name}.zip" "${base_name}"
74+
echo "ASSET=${base_name}.zip" >> "${GITHUB_ENV}"
75+
76+
- name: Upload release assets
77+
uses: actions/upload-release-asset@v1.0.2
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
with:
81+
upload_url: ${{ needs.create_release.outputs.upload_url }}
82+
asset_name: ${{ env.ASSET }}
83+
asset_path: ${{ env.ASSET }}
84+
asset_content_type: application/octet-stream

.github/workflows/rust.yml

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

src/bluetooth.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ impl BtAddr {
1515
}
1616

1717
impl fmt::Display for BtAddr {
18+
#[allow(clippy::erasing_op, clippy::identity_op)]
1819
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1920
write!(
2021
f,

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod bluetooth;
1010
mod constants;
1111
mod device;
1212
mod error;
13-
#[allow(dead_code)]
13+
#[allow(dead_code, clippy::all)]
1414
mod wrap;
1515

1616
#[derive(Clap, Clone, Copy, Eq, PartialEq)]

0 commit comments

Comments
 (0)