Skip to content

Commit

Permalink
add github workflow to create release
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyiwen2019 committed Dec 19, 2024
1 parent 7c3c9b5 commit 922a86a
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and Release

on:
workflow_dispatch:
inputs:
branch:
required: true
type: string
default: main
tag_name:
required: true
type: string
default: latest
targets:
description: 'JSON array of target platforms to build [{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, ...]'
required: true
default: '[{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, {"os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu"}, {"os": "windows-latest", "target": "x86_64-pc-windows-msvc"}, {"os": "macos-latest", "target": "x86_64-apple-darwin"}]'

jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include: ${{ fromJson(inputs.targets) }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install target
run: rustup target add ${{ matrix.target }}

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

- name: Create release artifact
run: |
mkdir -p artifacts
cp target/${{ matrix.target }}/release/dt-main artifacts/ape-dts
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.tag_name }}
files: |
artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/ape-dts
asset_name: ape-dts-${{ github.run_id }}-${{ matrix.target }}
asset_content_type: application/octet-stream

0 comments on commit 922a86a

Please sign in to comment.