-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (95 loc) · 3.42 KB
/
release.yml
File metadata and controls
113 lines (95 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Build and Release
on:
push:
tags:
- 'v*' # 当推送以v开头的标签时触发,如 v0.1.2
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ExcelToXML ${{ github.ref_name }}
draft: false
prerelease: false
body: |
## ExcelToXML ${{ github.ref_name }}
自动构建的多平台二进制文件。
### 使用方法:
1. 下载对应您平台的二进制文件
2. 双击即可运行
### 支持平台:
- Windows (x64)
- macOS (arm64)
- Linux (x64)
### 更新日志:
打包脚本适配新包名
build-release:
name: Build ${{ matrix.target }}
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: excel-to-xml-${{ needs.build.outputs.version }}-linux-x86_64
- target: aarch64-apple-darwin
os: macos-latest
name: excel-to-xml-${{ needs.build.outputs.version }}-macos-arm64
- target: x86_64-pc-windows-msvc
os: windows-latest
name: excel-to-xml-${{ needs.build.outputs.version }}-windows-x86_64.exe
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../${{ matrix.name }}.tar.gz excel_to_xml
cd -
- name: Prepare binary (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.name }}.zip excel_to_xml.exe
cd -
- name: Upload Release Asset (Unix)
if: matrix.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build.outputs.upload_url }}
asset_path: ${{ matrix.name }}.tar.gz
asset_name: ${{ matrix.name }}.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.build.outputs.upload_url }}
asset_path: ${{ matrix.name }}.zip
asset_name: ${{ matrix.name }}.zip
asset_content_type: application/zip