-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from chenxiaolong/ci
Update GitHub Actions workflows to support creating releases
- Loading branch information
Showing
5 changed files
with
128 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters