Skip to content

chore: add github workflow configs #1

chore: add github workflow configs

chore: add github workflow configs #1

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
name: Build on ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: this-is-c
asset_name: this-is-c-linux-amd64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: this-is-c.exe
asset_name: this-is-c-windows-amd64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: this-is-c
asset_name: this-is-c-macos-amd64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: this-is-c
asset_name: this-is-c-macos-arm64
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package binary (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar -czf ../../../${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
echo "ASSET_FILE=${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
- name: Package binary (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
echo "ASSET_FILE=${{ matrix.asset_name }}.zip" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.target }}
path: ${{ env.ASSET_FILE }}
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: binary-*
merge-multiple: true
path: dist
- name: Publish to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
draft: false
generate_release_notes: true