Skip to content

Commit

Permalink
workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoChenFx committed Sep 6, 2024
1 parent d6fe4f9 commit dd82346
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Release

on:
push:
tags:
- "v*"

permissions: write-all
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: short

jobs:
build-and-release:
name: Build and Release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact_name: autocommit
asset_name: autocommit-linux-amd64
target: x86_64-unknown-linux-musl
- os: windows-latest
artifact_name: autocommit.exe
asset_name: autocommit-windows-amd64.exe
target: x86_64-pc-windows-msvc
- os: macos-latest
artifact_name: autocommit
asset_name: autocommit-macos-arm64
target: aarch64-apple-darwin
- os: macos-latest
artifact_name: autocommit
asset_name: autocommit-macos-amd64
target: x86_64-apple-darwin

steps:
- uses: actions/checkout@v2

- name: Install Rust Stable
uses: dtolnay/rust-toolchain@stable

- name: Add Rust Target
run: rustup target add ${{ matrix.target }}

- name: Build
run: cargo build --verbose --release --target ${{ matrix.target }}

- name: Strip binary (linux and macos)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: strip "target/${{ matrix.target }}/release/autocommit"

- name: Get the version
id: get_version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}

- name: Rename binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
mv ${{ matrix.artifact_name }} ${{ matrix.asset_name }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: target/${{ matrix.target }}/release/${{ matrix.asset_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit dd82346

Please sign in to comment.