zoxide/.github/workflows/release.yml

110 lines
3.3 KiB
YAML
Raw Normal View History

2021-05-02 03:26:12 +05:30
name: release
2021-05-02 03:19:22 +05:30
on:
push:
2023-01-07 01:31:49 +05:30
branches: [main]
2021-10-29 20:31:25 +02:00
pull_request:
workflow_dispatch:
2022-04-25 14:45:46 +05:30
env:
CARGO_INCREMENTAL: 0
permissions:
contents: write
2021-05-02 03:19:22 +05:30
jobs:
2021-10-29 20:31:25 +02:00
release:
name: ${{ matrix.target }}
2021-05-02 03:19:22 +05:30
runs-on: ${{ matrix.os }}
strategy:
2021-10-29 20:31:25 +02:00
fail-fast: false
2021-05-02 03:19:22 +05:30
matrix:
include:
2021-10-29 20:31:25 +02:00
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
2022-06-26 00:37:44 +05:30
deb: true
2021-10-29 20:31:25 +02:00
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
2022-06-26 00:37:44 +05:30
deb: true
2021-10-29 20:31:25 +02:00
- os: macos-11
target: x86_64-apple-darwin
- os: macos-11
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
2021-05-02 03:19:22 +05:30
steps:
- name: Checkout repository
2023-05-05 13:24:44 +05:30
uses: actions/checkout@v3
2021-05-02 03:19:22 +05:30
with:
2021-10-29 20:31:25 +02:00
fetch-depth: 0
2022-06-26 00:52:42 +05:30
- name: Get version
id: get_version
2023-05-05 13:24:44 +05:30
uses: SebRollen/toml-action@v1.0.2
2023-01-08 04:57:13 +05:30
with:
file: Cargo.toml
field: package.version
2021-05-02 03:19:22 +05:30
- name: Install Rust
2023-05-05 13:24:44 +05:30
uses: actions-rs/toolchain@v1
2021-05-02 03:19:22 +05:30
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
2022-04-25 14:45:46 +05:30
- name: Setup cache
uses: Swatinem/rust-cache@v2.4.0
2022-08-12 12:43:41 +05:30
with:
key: ${{ matrix.target }}
2021-05-02 03:19:22 +05:30
- name: Build binary
2023-05-05 13:24:44 +05:30
uses: actions-rs/cargo@v1
2021-05-02 03:19:22 +05:30
with:
command: build
2021-10-29 20:31:25 +02:00
args: --release --locked --target=${{ matrix.target }} --color=always --verbose
use-cross: ${{ runner.os == 'Linux' }}
2022-06-26 00:37:44 +05:30
- name: Install cargo-deb
if: ${{ matrix.deb == true }}
2023-05-05 13:24:44 +05:30
uses: actions-rs/install@v0.1
2022-06-26 00:37:44 +05:30
with:
2022-06-26 00:52:42 +05:30
crate: cargo-deb
2022-06-26 00:37:44 +05:30
- name: Build deb
if: ${{ matrix.deb == true }}
2023-05-05 13:24:44 +05:30
uses: actions-rs/cargo@v1
2022-06-26 00:37:44 +05:30
with:
command: deb
args: --no-build --no-strip --output=. --target=${{ matrix.target }}
2021-10-29 20:31:25 +02:00
- name: Package (*nix)
if: runner.os != 'Windows'
2023-05-06 14:09:23 +05:30
run: |
tar -cv CHANGELOG.md LICENSE README.md man/ \
-C contrib/ completions/ -C ../ \
-C target/${{ matrix.target }}/release/ zoxide |
gzip --best > \
zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz
2021-10-29 20:31:25 +02:00
- name: Package (Windows)
if: runner.os == 'Windows'
2023-05-06 14:09:23 +05:30
run: |
7z a zoxide-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip `
CHANGELOG.md LICENSE README.md ./man/ ./contrib/completions/ `
./target/${{ matrix.target }}/release/zoxide.exe
2021-10-29 20:31:25 +02:00
- name: Upload artifact
2023-05-05 13:24:44 +05:30
uses: actions/upload-artifact@v3
2021-05-02 03:19:22 +05:30
with:
2021-10-29 20:31:25 +02:00
name: ${{ matrix.target }}
path: |
2022-06-26 00:37:44 +05:30
*.deb
2021-10-29 20:31:25 +02:00
*.tar.gz
2022-06-26 00:37:44 +05:30
*.zip
2021-05-02 03:19:22 +05:30
- name: Create release
2023-05-06 14:09:23 +05:30
if: |
${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }}
2023-05-05 13:24:44 +05:30
uses: softprops/action-gh-release@v1
2021-05-02 03:19:22 +05:30
with:
draft: true
2021-10-29 20:31:25 +02:00
files: |
2022-06-26 00:37:44 +05:30
*.deb
2021-10-29 20:31:25 +02:00
*.tar.gz
2022-06-26 00:37:44 +05:30
*.zip
2022-06-26 00:52:42 +05:30
name: ${{ steps.get_version.outputs.value }}
2022-06-26 00:37:44 +05:30
tag_name: ""