Skip to content

Commit 15e441f

Browse files
author
sehnsucht
committed
ci: tag标签发版
1 parent 83a013e commit 15e441f

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.github/actions/action.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Setup Version
2+
description: "Setup Version"
3+
outputs:
4+
APP_VERSION:
5+
description: "App Version"
6+
value: ${{ steps.version.outputs.APP_VERSION }}
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: "Write Version"
11+
id: version
12+
shell: bash
13+
run: |
14+
if [ "${{ github.ref_type }}" == "tag" ]; then
15+
APP_VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//')
16+
else
17+
APP_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
18+
fi
19+
echo $APP_VERSION
20+
echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_OUTPUT"

.github/workflows/lease.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Create Release
2+
3+
on:
4+
push: # 触发条件:当推送v开头的标签时触发
5+
tags:
6+
- 'v*'
7+
workflow_dispatch: # 手动触发工作流
8+
inputs:
9+
tag_version:
10+
description: "Tag Version" # 输入描述:标签版本
11+
required: true # 必填项
12+
jobs:
13+
build:
14+
runs-on: ubuntu-20.04
15+
16+
permissions:
17+
id-token: write
18+
contents: write
19+
attestations: write
20+
21+
steps:
22+
- name: 拉取代码
23+
uses: actions/checkout@v4
24+
25+
- name: 配置 Rust
26+
uses: moonrepo/setup-rust@v1
27+
28+
- name: 下载依赖
29+
run: |
30+
cargo build
31+
32+
- name: 构建项目
33+
run: trunk build --release
34+
35+
- name: 设置版本
36+
id: version
37+
uses: ./.github/actions/setup-version
38+
39+
- name: 生成 SHA-256 校验码
40+
run: shasum -a 256 ./target/wasm32-unknown-unknown/release/main.wasm > ./target/wasm32-unknown-unknown/release/main.wasm.sha256
41+
42+
- name: 创建 GitHub Release
43+
if: github.ref_type == 'tag' || github.event.inputs.tag_version != ''
44+
uses: softprops/action-gh-release@v2
45+
with:
46+
name: v${{ steps.version.outputs.APP_VERSION }}
47+
draft: false
48+
prerelease: true
49+
tag_name: v${{ steps.version.outputs.APP_VERSION }}
50+
files: |
51+
./target/wasm32-unknown-unknown/release/main.wasm
52+
./target/wasm32-unknown-unknown/release/main.wasm.sha256

0 commit comments

Comments
 (0)