Add msi creation to release CI #493
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
name: Windows | |
on: push | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Enable long paths for git | |
run: git config --system core.longpaths true # allow long paths from git deps | |
- name: Install fmt and clippy | |
run: | | |
rustup component add rustfmt | |
rustup component add clippy | |
- name: Run fmt | |
run: cargo fmt -- --check | |
- name: Run clippy | |
run: cargo clippy -- -D warnings | |
- name: Build | |
run: cargo build --tests --verbose | |
- name: Run tests | |
run: cargo test --verbose | |
deploy: | |
needs: test | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
target: [i686-pc-windows-msvc, x86_64-pc-windows-msvc] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
- name: Enable long paths for git | |
run: git config --system core.longpaths true # allow long paths from git deps | |
- name: Cargo build # crt-static is set with RUSTFLAGS to statically link MSVCRT (VCRUNTIME140.dll) | |
run: | | |
rustup target add i686-pc-windows-msvc | |
$env:RUSTFLAGS="-C target-feature=+crt-static" | |
cargo build -p tmc --release --verbose --target ${{ matrix.target }} | |
- name: Get the version | |
id: get_version | |
shell: bash | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Create msi installer | |
run: | | |
dotnet tool install --global wix | |
cargo install cargo-wix | |
cargo wix --output installer.msi | |
- name: Upload msi artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./installer.msi | |
asset_name: tmc-cli-rust-${{ steps.get_version.outputs.VERSION }}.msi | |
asset_content_type: application/octet-stream | |
- name: Deploy | |
run: | | |
$env:python_version=$(python -c 'import sys; print(\".\".join(map(str, sys.version_info[:3])))') | |
$env:CLOUDSDK_PYTHON="C:\hostedtoolcache\windows\Python\$env:python_version\x64\python" | |
gsutil cp target/${{ matrix.target }}/release/tmc.exe gs://${{ secrets.GCP_BUCKET }}/tmc-cli-rust/tmc-cli-rust-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}.exe |