Skip to content

v0.0.2

v0.0.2 #2

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get tag name
id: tag_name
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_name.outputs.TAG_NAME }}
name: PLM ${{ steps.tag_name.outputs.TAG_NAME }}
body: |
## PLM ${{ steps.tag_name.outputs.TAG_NAME }}
### 🚀 新功能
- 插件生命周期管理
- 配置管理系统
- CLI 工具
### 📦 下载
选择适合您操作系统的版本:
- **Linux (x86_64)**: `plm-${{ steps.tag_name.outputs.TAG_NAME }}-x86_64-unknown-linux-gnu.tar.gz`
- **macOS (Intel)**: `plm-${{ steps.tag_name.outputs.TAG_NAME }}-x86_64-apple-darwin.tar.gz`
- **macOS (Apple Silicon)**: `plm-${{ steps.tag_name.outputs.TAG_NAME }}-aarch64-apple-darwin.tar.gz`
- **Windows**: `plm-${{ steps.tag_name.outputs.TAG_NAME }}-x86_64-pc-windows-msvc.zip`
### 📋 安装方法
#### 一键安装 (推荐)
```bash
curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/scripts/install.sh | sh
```
#### 手动安装
**Linux/macOS:**
```bash
# 下载并解压
tar -xzf plm-${{ steps.tag_name.outputs.TAG_NAME }}-*.tar.gz
# 移动到系统路径
sudo mv plm /usr/local/bin/
# 验证安装
plm --version
```
**Windows:**
```powershell
# 解压 zip 文件
# 将 plm.exe 添加到 PATH 环境变量
# 验证安装
plm --version
```
### 🔧 使用方法
```bash
# 初始化项目
plm init --name my-project --path .
# 发现插件
plm discover
# 安装插件
plm install plugin-name --version 1.0.0
# 查看帮助
plm --help
```
draft: false
prerelease: false
build:
name: Build Release Binaries
needs: create-release
if: always() && (github.event_name == 'release' || needs.create-release.result == 'success')
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: tar.gz
- os: macos-latest
target: x86_64-apple-darwin
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build binary
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi
cargo build --release --target ${{ matrix.target }}
shell: bash
- name: Get tag name
id: tag_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Prepare binary (Unix)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
if [ -f plm ]; then
strip plm || true
tar -czf ../../../plm-${{ steps.tag_name.outputs.TAG_NAME }}-${{ matrix.target }}.tar.gz plm
else
echo "Binary not found!"
ls -la
exit 1
fi
- name: Prepare binary (Windows)
if: matrix.archive == 'zip'
run: |
cd target/${{ matrix.target }}/release
if (Test-Path plm.exe) {
Compress-Archive -Path plm.exe -DestinationPath ../../../plm-${{ steps.tag_name.outputs.TAG_NAME }}-${{ matrix.target }}.zip
} else {
Write-Host "Binary not found!"
Get-ChildItem
exit 1
}
shell: powershell
- name: Upload Release Assets
if: github.event_name == 'release' || needs.create-release.result == 'success'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_name.outputs.TAG_NAME }}
files: |
plm-${{ steps.tag_name.outputs.TAG_NAME }}-${{ matrix.target }}.*
publish-crates:
name: Publish to Crates.io
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
continue-on-error: true
- name: Publish to crates.io
run: cargo publish --dry-run
continue-on-error: true
update-homebrew:
name: Update Homebrew Formula
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
steps:
- name: Get tag name
id: tag_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Update Homebrew formula
run: |
echo "🍺 Homebrew formula update would be triggered here"
echo "Tag: ${{ steps.tag_name.outputs.TAG_NAME }}"
echo "Download URL: https://github.com/${{ github.repository }}/releases/download/${{ steps.tag_name.outputs.TAG_NAME }}/plm-${{ steps.tag_name.outputs.TAG_NAME }}-x86_64-apple-darwin.tar.gz"
# 这里可以添加实际的 Homebrew formula 更新逻辑
docker-build:
name: Build and Push Docker Image
runs-on: ubuntu-latest
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
continue-on-error: true
- name: Get tag name
id: tag_name
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
else
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false # 设置为 true 当您准备好推送到 Docker Hub
tags: |
plm/plm:latest
plm/plm:${{ steps.tag_name.outputs.TAG_NAME }}
cache-from: type=gha
cache-to: type=gha,mode=max
continue-on-error: true