chore(release): 0.4.0 (#29) #117
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: release | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
workflow_dispatch: | |
env: | |
CARGO_INCREMENTAL: 0 | |
jobs: | |
release: | |
name: ${{ matrix.target }} | |
permissions: | |
contents: write | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# - os: ubuntu-latest | |
# target: x86_64-unknown-linux-musl | |
# deb: true | |
# - os: ubuntu-latest | |
# target: arm-unknown-linux-musleabihf | |
# - os: ubuntu-latest | |
# target: armv7-unknown-linux-musleabihf | |
# - os: ubuntu-latest | |
# target: aarch64-unknown-linux-musl | |
# deb: true | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Get version | |
id: get_version | |
uses: SebRollen/[email protected] | |
with: | |
file: Cargo.toml | |
field: package.version | |
- name: Setup Rust toolchain and cache | |
uses: actions-rust-lang/[email protected] | |
with: | |
target: ${{ matrix.target }} | |
toolchain: nightly-2024-05-16 | |
- name: Install cargo-src | |
run: | | |
rustup target add ${{ matrix.target }} | |
rustup component add rust-src --target ${{ matrix.target }} | |
- name: Build binary | |
# use optimize_for_size in the future (https://github.com/rust-lang/rust/issues/125612) | |
run: cargo build --release -Z build-std=core,std,alloc,proc_macro,panic_abort -Z build-std-features=panic_immediate_abort --locked --target=${{ matrix.target }} --color=always | |
- name: Install cargo-deb | |
if: ${{ matrix.deb == true }} | |
uses: actions-rs/[email protected] | |
with: | |
crate: cargo-deb | |
- name: Build deb | |
if: ${{ matrix.deb == true }} | |
uses: actions-rs/cargo@v1 | |
with: | |
command: deb | |
args: --no-build --no-strip --output=. --target=${{ matrix.target }} | |
- name: Package (*nix) | |
if: runner.os != 'Windows' | |
run: > | |
tar -cv | |
README.md | |
-C target/${{ matrix.target }}/release/ posh-tabcomplete | |
| gzip --best | |
> 'posh-tabcomplete-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz' | |
- name: Package (Windows) | |
if: runner.os == 'Windows' | |
run: > | |
7z a 'posh-tabcomplete-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip' | |
README.md | |
./target/${{ matrix.target }}/release/posh-tabcomplete.exe | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }} | |
path: | | |
*.deb | |
*.tar.gz | |
*.zip | |
- name: Create release | |
if: ${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: true | |
files: | | |
*.deb | |
*.tar.gz | |
*.zip | |
name: ${{ steps.get_version.outputs.value }} | |
tag_name: "" | |
publish: | |
runs-on: macos-latest | |
needs: release | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Rust toolchain and cache | |
uses: actions-rust-lang/[email protected] | |
with: | |
target: x86_64-apple-darwin | |
- name: Publish | |
if: ${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }} | |
run: cargo publish | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |