Skip to content

Commit

Permalink
ci(github): release
Browse files Browse the repository at this point in the history
Signed-off-by: loongtao.zhang <[email protected]>
  • Loading branch information
cathaysia committed Aug 26, 2024
1 parent 01c7434 commit 23d33ca
Showing 1 changed file with 133 additions and 0 deletions.
133 changes: 133 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# copy from https://github.com/ajeetdsouza/zoxide/blob/297499a4fe515d8242bd1fb68efee1da1d47217a/.github/workflows/release.yml
name: release

on:
push:
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0

permissions:
contents: write

jobs:
release:
name: ${{ matrix.target }}
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
deb: true
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
deb: true
- os: ubuntu-latest
target: i686-unknown-linux-musl
deb: true
# - os: ubuntu-latest
# target: aarch64-linux-android
- 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
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get version
id: get_version
uses: SebRollen/[email protected]
with:
file: Cargo.toml
field: package.version

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}

- name: Setup cache
uses: Swatinem/[email protected]
with:
key: ${{ matrix.target }}

- name: Install cross
if: ${{ runner.os == 'Linux' }}
uses: actions-rs/cargo@v1
with:
command: install
args: --color=always --git=https://github.com/cross-rs/cross.git --locked --rev=02bf930e0cb0c6f1beffece0788f3932ecb2c7eb --verbose cross

- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target=${{ matrix.target }} --color=always --verbose
use-cross: ${{ runner.os == 'Linux' }}

- 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 CHANGELOG.md LICENSE README.md man/ \
-C contrib/ completions/ -C ../ \
-C target/${{ matrix.target }}/release/ nix4vscode |
gzip --best > \
nix4vscode-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.tar.gz
- name: Package (Windows)
if: runner.os == 'Windows'
run: |
7z a nix4vscode-${{ steps.get_version.outputs.value }}-${{ matrix.target }}.zip `
CHANGELOG.md LICENSE README.md ./man/ ./contrib/completions/ `
./target/${{ matrix.target }}/release/nix4vscode.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/master'
uses: softprops/action-gh-release@v2
with:
draft: true
files: |
*.deb
*.tar.gz
*.zip
name: ${{ steps.get_version.outputs.value }}
tag_name: ""

0 comments on commit 23d33ca

Please sign in to comment.