name: windows-release
on:
push:
tags:
- "*"
jobs:
build:
name: Build on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Build
env:
RUSTFLAGS: "-C link-arg=-s -C target-feature=+crt-static"
run: |
cargo build --release --locked
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: binary
path: target/release/crowbar.exe
test:
name: Test on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Test
env:
RUSTFLAGS: "-C link-arg=-s -C target-feature=+crt-static"
run: |
cargo fmt -- --check
cargo clippy --release
cargo test --release --locked
release:
runs-on: windows-latest
needs: [build, test]
steps:
- name: Set the release tag
id: set_tag
run: echo ::set-output name=RELEASE_TAG::${GITHUB_REF/refs\/tags\/v/}
shell: bash
- uses: actions/checkout@v3
- name: Restore artifact from previous job
uses: actions/download-artifact@v3
with:
name: binary
- name: Upload binaries to release
uses: svenstaro/upload-release-action@2.5.0
with:
file: crowbar.exe
asset_name: crowbar-x86_64-windows.exe
overwrite: true
- name: Upload release to Chocolatey
continue-on-error: true
run: |
mkdir -p chocolatey/release
cp -v crowbar.exe chocolatey/release/
cp -v chocolatey/VERIFICATION.txt chocolatey/release/
cp -v LICENSE chocolatey/release/
cd chocolatey/
choco pack --version ${{ steps.set_tag.outputs.RELEASE_TAG }} crowbar.nuspec
choco push crowbar.${{ steps.set_tag.outputs.RELEASE_TAG }}.nupkg -k ${{ secrets.CHOCOLATEY_API_KEY }} -s https://push.chocolatey.org/