Skip to content

Commit

Permalink
Merge pull request #4 from chenxiaolong/ci
Browse files Browse the repository at this point in the history
Update GitHub Actions workflows to support creating releases
  • Loading branch information
chenxiaolong authored Dec 3, 2020
2 parents a3fcdde + 4fcab76 commit 13bfd72
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 25 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
on:
push:
branches:
- master
pull_request:
jobs:
build_and_upload:
name: Build and archive artifacts
runs-on: windows-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install winmd files
run: |
cargo install cargo-winrt
cargo winrt install
- name: Install clippy
run: rustup component add clippy

- name: Run clippy checks in debug mode
env:
RUST_BACKTRACE: 1
run: |
cargo clippy --workspace -- -D warnings
- name: Build in debug mode
run: cargo build --verbose

- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: svrbsctl
path: |
target/debug/svrbsctl.exe
target/debug/svrbsctl.pdb
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
on:
push:
# Uncomment to test against a branch
#branches:
# - ci
tags:
- 'v*'
jobs:
create_release:
name: Create GitHub release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version from tag
id: get_version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
version=${GITHUB_REF#refs/tags/v}
else
version=0.0.0-${GITHUB_REF#refs/heads/}
fi
echo "::set-output name=version::${version}"
- name: Create release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get_version.outputs.version }}
release_name: Version ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false

build_and_upload:
name: Build and upload assets
needs: create_release
runs-on: windows-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install winmd files
run: |
cargo install cargo-winrt
cargo winrt install
- name: Install clippy
run: rustup component add clippy

- name: Run clippy checks in release mode
env:
RUST_BACKTRACE: 1
run: |
cargo clippy --workspace --release -- -D warnings
- name: Build in release mode
run: cargo build --release --verbose

- name: Build archive
shell: bash
run: |
base_name=svrbsctl-${{ needs.create_release.outputs.version }}
mkdir "${base_name}"
cp {README.md,LICENSE,target/release/svrbsctl.exe} "${base_name}/"
7z a "${base_name}.zip" "${base_name}"
echo "ASSET=${base_name}.zip" >> "${GITHUB_ENV}"
- name: Upload release assets
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: ${{ env.ASSET }}
asset_path: ${{ env.ASSET }}
asset_content_type: application/octet-stream
24 changes: 0 additions & 24 deletions .github/workflows/rust.yml

This file was deleted.

1 change: 1 addition & 0 deletions src/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ impl BtAddr {
}

impl fmt::Display for BtAddr {
#[allow(clippy::erasing_op, clippy::identity_op)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod bluetooth;
mod constants;
mod device;
mod error;
#[allow(dead_code)]
#[allow(dead_code, clippy::all)]
mod wrap;

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

0 comments on commit 13bfd72

Please sign in to comment.