forked from People-11/eh2telegraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a87ca8c
commit 73c4002
Showing
1 changed file
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# GitHub Actions工作流配置文件 | ||
|
||
name: Build and Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" # 当推送符合模式v*.*.*的标签时触发工作流 | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} # 定义作业运行的操作系统 | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] # 定义操作系统矩阵 | ||
arch: [x86_64, aarch64] # 定义架构矩阵 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 # 检出仓库代码 | ||
|
||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 # 设置Rust工具链 | ||
with: | ||
toolchain: stable # 使用稳定版Rust工具链 | ||
profile: minimal # 使用最小化配置文件 | ||
override: true # 覆盖任何现有的Rust工具链设置 | ||
|
||
- name: Build project | ||
run: cargo build --release # 构建项目的发布版本 | ||
|
||
# 上传Linux x86_64平台的构建产物 | ||
- name: Upload artifact (Linux) | ||
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ubuntu-latest | ||
path: target/release/bot | ||
|
||
# 上传Linux aarch64平台的构建产物 | ||
- name: Upload artifact (Linux aarch64) | ||
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ubuntu-latest-bot-aarch64 | ||
path: target/release/bot | ||
|
||
# 上传Windows x86_64平台的构建产物 | ||
- name: Upload artifact (Windows) | ||
if: matrix.os == 'windows-latest' && matrix.arch == 'x86_64' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: windows-latest | ||
path: target/release/bot.exe | ||
|
||
# 上传Windows aarch64平台的构建产物 | ||
- name: Upload artifact (Windows aarch64) | ||
if: matrix.os == 'windows-latest' && matrix.arch == 'aarch64' | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: windows-latest-bot-aarch64 | ||
path: target/release/bot.exe | ||
|
||
release: | ||
runs-on: ubuntu-latest # 定义作业运行在Ubuntu系统上 | ||
needs: build # 依赖于build作业 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 # 检出仓库代码 | ||
|
||
# 下载Linux x86_64平台的构建产物 | ||
- name: Download artifact (Linux-x86_64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ubuntu-latest-bot | ||
path: artifacts/ubuntu | ||
|
||
# 下载Windows x86_64平台的构建产物 | ||
- name: Download artifact (Windows-x86_64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: windows-latest-bot | ||
path: artifacts/windows | ||
|
||
# 下载Linux aarch64平台的构建产物 | ||
- name: Download artifact (Linux-aarch64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ubuntu-latest-bot-aarch64 | ||
path: artifacts/ubuntu | ||
|
||
# 下载Windows aarch64平台的构建产物 | ||
- name: Download artifact (Windows-aarch64) | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: windows-latest-bot-aarch64 | ||
path: artifacts/windows | ||
|
||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1 # 创建GitHub release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # 使用GitHub令牌进行身份验证 | ||
with: | ||
tag_name: ${{ github.ref }} # 使用推送的标签名 | ||
release_name: Release ${{ github.ref }} # 使用推送的标签名作为发布名称 | ||
body: | | ||
Changes in this Release | ||
- First Change | ||
- Second Change # 发布说明 | ||
draft: false # 是否为草稿 | ||
prerelease: false # 是否为预发布 | ||
|
||
# 上传Linux x86_64平台的构建产物到发布页面 | ||
- name: Upload Linux x86_64 artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # 使用GitHub令牌进行身份验证 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 使用创建发布步骤生成的上传URL | ||
asset_path: artifacts/ubuntu/bot # 上传的文件路径 | ||
asset_name: bot-linux-x86_64 # 上传的文件名 | ||
asset_content_type: application/octet-stream # 文件内容类型 | ||
|
||
# 上传Windows x86_64平台的构建产物到发布页面 | ||
- name: Upload Windows x86_64 artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # 使用GitHub令牌进行身份验证 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 使用创建发布步骤生成的上传URL | ||
asset_path: artifacts/windows/bot.exe # 上传的文件路径 | ||
asset_name: bot-windows-x86_64.exe # 上传的文件名 | ||
asset_content_type: application/octet-stream # 文件内容类型 | ||
|
||
# 上传Linux aarch64平台的构建产物到发布页面 | ||
- name: Upload Linux aarch64 artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # 使用GitHub令牌进行身份验证 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 使用创建发布步骤生成的上传URL | ||
asset_path: artifacts/ubuntu/bot # 上传的文件路径 | ||
asset_name: bot-linux-aarch64 # 上传的文件名 | ||
asset_content_type: application/octet-stream # 文件内容类型 | ||
|
||
# 上传Windows aarch64平台的构建产物到发布页面 | ||
- name: Upload Windows aarch64 artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} # 使用GitHub令牌进行身份验证 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # 使用创建发布步骤生成的上传URL | ||
asset_path: artifacts/windows/bot.exe # 上传的文件路径 | ||
asset_name: bot-windows-aarch64.exe # 上传的文件名 | ||
asset_content_type: application/octet-stream # 文件内容类型 | ||
|