name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
title: tree Release ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
upload-assets:
needs: create-release
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: Linux-amd64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: Linux-arm64
- target: x86_64-apple-darwin
os: macos-latest
name: macOS-amd64
- target: aarch64-apple-darwin
os: macos-latest
name: macOS-arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build and upload assets
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: tree
archive: tree-${{ github.ref_name }}-${{ matrix.name }}
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}
setup-windows-tools:
runs-on: windows-latest
steps:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-wix
run: cargo install cargo-wix
- name: Cache cargo-wix
id: cache-cargo-wix
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-wix.exe
key: ${{ runner.os }}-cargo-wix-v1
windows-builds:
needs: [create-release, setup-windows-tools]
runs-on: windows-latest
strategy:
matrix:
include:
- target: x86_64-pc-windows-msvc
name: Windows-64bit
- target: i686-pc-windows-msvc
name: Windows-32bit
- target: aarch64-pc-windows-msvc
name: Windows-arm64
steps:
- uses: actions/checkout@v4
- name: Setup Windows 7 compatible lockfile
shell: pwsh
run: |
Copy-Item "Cargo-win7.lock" -Destination "Cargo.lock" -Force
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.75.0
with:
targets: ${{ matrix.target }}
- name: Restore cargo-wix from cache
uses: actions/cache/restore@v3
with:
path: ~/.cargo/bin/cargo-wix.exe
key: ${{ runner.os }}-cargo-wix-v1
fail-on-cache-miss: true
- name: Install WiX Toolset
shell: pwsh
run: |
curl -L -o wix311-binaries.zip https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
Expand-Archive wix311-binaries.zip -DestinationPath wix
$env:PATH += ";$(Get-Location)\wix"
echo "$(Get-Location)\wix" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Build Windows binary
run: cargo build --release --target ${{ matrix.target }}
env:
RUSTFLAGS: "-C target-feature=+crt-static"
- name: Create zip archive
shell: pwsh
run: |
Compress-Archive -Path "target/${{ matrix.target }}/release/tree.exe" -DestinationPath "tree-${{ github.ref_name }}-${{ matrix.name }}.zip" -Force
- name: Upload zip to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: tree-${{ github.ref_name }}-${{ matrix.name }}.zip
asset_name: tree-${{ github.ref_name }}-${{ matrix.name }}.zip
tag: ${{ github.ref }}
overwrite: true
- name: Copy executable with version in filename
shell: pwsh
run: |
Copy-Item "target/${{ matrix.target }}/release/tree.exe" -Destination "tree-${{ github.ref_name }}_${{ matrix.name }}.exe" -Force
- name: Upload executable to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: tree-${{ github.ref_name }}_${{ matrix.name }}.exe
asset_name: tree-${{ github.ref_name }}_${{ matrix.name }}.exe
tag: ${{ github.ref }}
overwrite: true
- name: Create MSI package
shell: pwsh
run: |
# Build MSI with debug output
cargo wix --target ${{ matrix.target }} --output "tree-${{ github.ref_name }}-${{ matrix.name }}.msi" --nocapture
- name: Upload MSI to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: tree-${{ github.ref_name }}-${{ matrix.name }}.msi
asset_name: tree-${{ github.ref_name }}-${{ matrix.name }}.msi
tag: ${{ github.ref }}
overwrite: true
publish-crate:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}